jssm 5.45.2 → 5.46.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/dist/es6/jssm.d.ts +2 -1
  2. package/dist/es6/jssm.js +5 -0
  3. package/dist/es6/jssm_types.d.ts +6 -5
  4. package/dist/es6/version.js +1 -1
  5. package/dist/jssm.es5.cjs.js +1 -1
  6. package/jssm.d.ts +2 -1
  7. package/jssm_types.d.ts +6 -5
  8. package/package.json +1 -1
  9. package/.codeclimate.yml +0 -22
  10. package/.editorconfig +0 -12
  11. package/.eslintrc +0 -20
  12. package/.nycrc +0 -6
  13. package/.travis.yml +0 -9
  14. package/dist/jssm.es5.iife.js +0 -1
  15. package/jest-spec.config.js +0 -27
  16. package/jest-stoch.config.js +0 -27
  17. package/rollup.config.iife.js +0 -44
  18. package/rollup.config.js +0 -44
  19. package/src/demo/index.html +0 -38
  20. package/src/demo/style.css +0 -2
  21. package/src/ts/jssm-dot.peg +0 -928
  22. package/src/ts/jssm.ts +0 -1243
  23. package/src/ts/jssm_types.ts +0 -385
  24. package/src/ts/jssm_util.ts +0 -117
  25. package/src/ts/tests/actions.spec.ts +0 -167
  26. package/src/ts/tests/arrange.spec.ts +0 -72
  27. package/src/ts/tests/arrange.stoch.ts +0 -4
  28. package/src/ts/tests/array_box_if_string.spec.ts +0 -30
  29. package/src/ts/tests/array_transitions.spec.ts +0 -129
  30. package/src/ts/tests/arrow unicode.spec.ts +0 -88
  31. package/src/ts/tests/arrow.spec.ts +0 -124
  32. package/src/ts/tests/colors.spec.ts +0 -58
  33. package/src/ts/tests/comment.spec.ts +0 -134
  34. package/src/ts/tests/compile.spec.ts +0 -79
  35. package/src/ts/tests/constants.spec.ts +0 -98
  36. package/src/ts/tests/cycles.spec.ts +0 -153
  37. package/src/ts/tests/dot_preamble.spec.ts +0 -16
  38. package/src/ts/tests/embedded_sm.spec.ts +0 -36
  39. package/src/ts/tests/flow.spec.ts +0 -22
  40. package/src/ts/tests/forced transitions.spec.ts +0 -26
  41. package/src/ts/tests/general.spec.ts +0 -933
  42. package/src/ts/tests/graph node lists.spec.ts +0 -21
  43. package/src/ts/tests/histo.spec.ts +0 -24
  44. package/src/ts/tests/hooks.spec.ts +0 -209
  45. package/src/ts/tests/language.spec.ts +0 -37
  46. package/src/ts/tests/language_data/belarussian.json +0 -14
  47. package/src/ts/tests/language_data/bengali.json +0 -16
  48. package/src/ts/tests/language_data/emoji.json +0 -22
  49. package/src/ts/tests/language_data/english.json +0 -17
  50. package/src/ts/tests/language_data/french.json +0 -17
  51. package/src/ts/tests/language_data/german.json +0 -17
  52. package/src/ts/tests/language_data/hebrew.json +0 -16
  53. package/src/ts/tests/language_data/portuguese.json +0 -13
  54. package/src/ts/tests/language_data/russian.json +0 -13
  55. package/src/ts/tests/language_data/spanish.json +0 -17
  56. package/src/ts/tests/language_data/ukrainian.json +0 -19
  57. package/src/ts/tests/layout.spec.ts +0 -29
  58. package/src/ts/tests/machine_attributes.spec.ts +0 -398
  59. package/src/ts/tests/machine_name.spec.ts +0 -14
  60. package/src/ts/tests/named lists.spec.ts +0 -24
  61. package/src/ts/tests/nominated states.spec.ts +0 -133
  62. package/src/ts/tests/parse actions.spec.ts +0 -32
  63. package/src/ts/tests/parse.spec.ts +0 -94
  64. package/src/ts/tests/probability.spec.ts +0 -146
  65. package/src/ts/tests/r639.spec.ts +0 -27
  66. package/src/ts/tests/sample_select.spec.ts +0 -173
  67. package/src/ts/tests/seq.spec.ts +0 -14
  68. package/src/ts/tests/seq.stoch.ts +0 -83
  69. package/src/ts/tests/shapes.spec.ts +0 -63
  70. package/src/ts/tests/sm_tag.spec.ts +0 -37
  71. package/src/ts/tests/special characters.spec.ts +0 -39
  72. package/src/ts/tests/state_declaration.spec.ts +0 -214
  73. package/src/ts/tests/state_style.spec.ts +0 -82
  74. package/src/ts/tests/stop light.spec.ts +0 -157
  75. package/src/ts/tests/stripes.spec.ts +0 -52
  76. package/src/ts/tests/theme.spec.ts +0 -45
  77. package/src/ts/tests/weighted_histo_key.spec.ts +0 -22
  78. package/src/ts/tests/weighted_rand_select.spec.ts +0 -27
  79. package/src/ts/tests/weighted_sample_select.spec.ts +0 -24
  80. package/src/ts/version.ts +0 -3
  81. package/tree.txt +0 -1794
  82. package/tsconfig.json +0 -27
@@ -1,214 +0,0 @@
1
-
2
- /* eslint-disable max-len */
3
-
4
- import * as jssm from '../jssm';
5
-
6
- const sm = jssm.sm;
7
-
8
-
9
-
10
-
11
-
12
- describe("doesn't throw", () => {
13
-
14
- test('with no attributes', () =>
15
- expect(() => { const _foo = sm`state c: {}; a -> b;`; })
16
- .not.toThrow() );
17
-
18
- test('with just whitespace', () =>
19
- expect(() => { const _foo = sm`state c: { }; a -> b;`; })
20
- .not.toThrow() );
21
-
22
- test('with just node color', () =>
23
- expect(() => { const _foo = sm`state c: { color: red; }; a -> b;`; })
24
- .not.toThrow() );
25
-
26
- });
27
-
28
-
29
-
30
-
31
-
32
- describe('can read declaration', () => {
33
-
34
- const mach0 = sm`state c: { }; a -> b;`,
35
- mach1 = sm`state c: { color: red; }; a -> b;`,
36
- mach2 = sm`state c: { color: red; shape: circle; }; a -> b;`;
37
-
38
- test.todo('Incomplete test prototypes in state_declaration');
39
-
40
- // const machT = sm`c: { color: red; }; d: { shape: circle; }; a -> b;`;
41
-
42
- // const machP = sm`
43
- // c: { shape: circle; color: red; };
44
- // d: { shape: circle; color: red; };
45
- // a -> b;
46
- // `;
47
-
48
-
49
- describe('of w/ nothing', () => {
50
- const decls = mach0.state_declarations();
51
- describe('through .state_declarations/0 w nothing', () => {
52
-
53
- test('yielding map', () =>
54
- expect( decls instanceof Map ).toBe(true) );
55
-
56
- test('list having size 1', () =>
57
- expect( decls.size ).toBe(1) );
58
-
59
- test('props having length 0', () =>
60
- expect( decls.get('c').declarations.length ).toBe(0) );
61
-
62
- });
63
- });
64
-
65
-
66
- describe('of just w/ color', () => {
67
- const decls = mach1.state_declarations();
68
- describe('through .state_declarations/0 just state color', () => {
69
-
70
- test('yielding map', () =>
71
- expect(decls instanceof Map ).toBe(true) );
72
-
73
- test('list having size 1', () =>
74
- expect(decls.size).toBe(1) );
75
-
76
- test('props having length 1', () =>
77
- expect(decls.get('c').declarations.length ).toBe(1) );
78
-
79
- // todo whargarbl check the actual members comeback
80
- });
81
-
82
- test('through .state_declaration/1', () =>
83
- expect(mach1.state_declaration('c').declarations[0].value )
84
- .toBe('#ff0000ff') );
85
-
86
- });
87
-
88
-
89
- describe('of w/ color, shape', () => {
90
-
91
- test('through .state_declaration/1 red hex-8', () =>
92
- expect(mach2.state_declaration('c').declarations[0].value )
93
- .toBe('#ff0000ff') );
94
-
95
- test('through .state_declaration/1 circle', () =>
96
- expect(mach2.state_declaration('c').declarations[1].value )
97
- .toBe('circle') );
98
-
99
- test('through .state_declarations/0 size', () =>
100
- expect(mach2.state_declarations().size )
101
- .toBe(1) );
102
-
103
- test.todo('Re-enable once state_declarations/0 exposes type 3');
104
-
105
- test('through .state_declarations/0 declarations length', () =>
106
- expect(mach2.state_declarations().get('c').declarations.length )
107
- .toBe(2) );
108
-
109
- });
110
-
111
- test.todo('Not sure why these were commented out tbh');
112
-
113
- /*
114
- describe('of w/ color on c, shape on d', () => {
115
-
116
- test('through .state_declaration/1', () =>
117
- expect(machT.state_declaration('c') )
118
- .toBe('left') );
119
-
120
- test('through .state_declaration/1', () =>
121
- expect(machT.state_declaration('d') )
122
- .toBe('left') );
123
-
124
- test('through .state_declarations/0', () =>
125
- expect(machT.state_declarations() )
126
- .toBe('left') );
127
-
128
- });
129
-
130
-
131
- describe('of w/ color, shape on each c and d', () => {
132
-
133
- test('through .state_declaration/1', () =>
134
- expect(machP.state_declaration('c') )
135
- .toBe('left') );
136
-
137
- test('through .state_declaration/1', () =>
138
- expect(machP.state_declaration('d') )
139
- .toBe('left') );
140
-
141
- test('through .state_declarations/0', () =>
142
- expect(machP.state_declarations() )
143
- .toBe('left') );
144
-
145
- });
146
- */
147
- });
148
-
149
-
150
-
151
-
152
-
153
- describe('error catchery', () => {
154
-
155
- test('repeated declaration throws', () =>
156
- expect( () => { const _mach1 = sm`state c: { color: red; }; state c: { color: red; }; a -> b;`; } ) // eslint-disable-line no-unused-vars
157
- .toThrow()
158
- );
159
-
160
-
161
- describe('unknown state property', () => {
162
-
163
- const prestate = {
164
- "start_states":["b"],
165
- "transitions":[{"from":"b","to":"c","kind":"legal","forced_only":false,"main_path":false}],
166
- "state_declaration":[{"state":"a","declarations":[{"key":"urgle bergle","value":"circle"}]}]};
167
-
168
- test('throws', () =>
169
- expect( () => { const _m0 = new jssm.Machine(prestate as any); } )
170
- .toThrow() );
171
-
172
- });
173
-
174
-
175
- test('transfer state properties throws on unknown key', () =>
176
- expect( () => { jssm.transfer_state_properties({declarations: [{key: 'agsrhdtjfy', value: 'seven'}]} as any); } )
177
- .toThrow()
178
- );
179
-
180
- test('Cannot declare the same state twice', () =>
181
- expect( () => { const mach0 = sm`state c: { }; state c: { }; a -> b;`; } )
182
- .toThrow()
183
- );
184
-
185
- test('Cannot generate an existing state', () =>
186
- expect( () => {
187
- const errM = sm`a->c;state c:{};`;
188
- const errR = errM._new_state({name:'c'} as any);
189
- } )
190
- .toThrow()
191
- );
192
-
193
- test('Cannot generate an empty state name as string', () =>
194
- expect( () => {
195
- const errM = sm`state "":{};`;
196
- } )
197
- .toThrow()
198
- );
199
-
200
- describe('Cannot generate an empty state name as datastructure', () => {
201
-
202
- const prestate = {
203
- "start_states":["b"],
204
- "transitions":[{"from":"b","to":"c","kind":"legal","forced_only":false,"main_path":false}],
205
- "state_declaration":[{"state":""}]
206
- };
207
-
208
- test('throws', () =>
209
- expect( () => { const _m0 = new jssm.Machine(prestate as any); } )
210
- .toThrow() );
211
-
212
- });
213
-
214
- });
@@ -1,82 +0,0 @@
1
-
2
- import { Shapes, LineStyles } from './constants.spec';
3
-
4
- import { sm } from '../jssm';
5
-
6
-
7
-
8
-
9
-
10
- describe('State style', () => {
11
-
12
-
13
-
14
- Shapes.map(shape => {
15
-
16
- describe(shape, () => {
17
-
18
- test(`can set regular state to ${shape}`, () =>
19
- expect( () => {
20
- const _foo = sm`machine_name: bob; state: { shape: ${shape}; }; a->b;`;
21
- }).not.toThrow() );
22
-
23
- test(`can set start state to ${shape}`, () =>
24
- expect( () => {
25
- const _foo = sm`machine_name: bob; start_state: { shape: ${shape}; }; a->b;`;
26
- }).not.toThrow() );
27
-
28
- test(`can set end state to ${shape}`, () =>
29
- expect( () => {
30
- const _foo = sm`machine_name: bob; end_state: { shape: ${shape}; }; a->b;`;
31
- }).not.toThrow() );
32
-
33
- test(`can set specific state to ${shape}`, () =>
34
- expect( () => {
35
- const _foo = sm`machine_name: bob; a->b; state a: { shape: ${shape}; };`;
36
- }).not.toThrow() );
37
-
38
- });
39
-
40
- });
41
-
42
-
43
-
44
- LineStyles.map(linestyle => {
45
-
46
- // TODO FIXME it turns out state: , start_state: , and end_state: are on vestigial productions. fix it
47
-
48
- // test(`can set regular state border line style to ${linestyle}`, () =>
49
- // expect( () => {
50
- // const _foo = sm`machine_name: bob; state: { linestyle: ${linestyle}; }; a->b;`;
51
- // }).not.toThrow() );
52
-
53
- // test(`can set start state border line style to ${linestyle}`, () =>
54
- // expect( () => {
55
- // const _foo = sm`machine_name: bob; start_state: { linestyle: ${linestyle}; }; a->b;`;
56
- // }).not.toThrow() );
57
-
58
- // test(`can set end state border line style to ${linestyle}`, () =>
59
- // expect( () => {
60
- // const _foo = sm`machine_name: bob; end_state: { linestyle: ${linestyle}; }; a->b;`;
61
- // }).not.toThrow() );
62
-
63
- test(`can set specific state border line style to ${linestyle}`, () =>
64
- expect( () => {
65
- const _foo = sm`machine_name: bob; a->b; state a: { linestyle: ${linestyle}; }; `;
66
- }).not.toThrow() );
67
-
68
- test(`can set transition line style to ${linestyle}`, () =>
69
- expect( () => {
70
- const _foo = sm`machine_name: bob; a{ linestyle: ${linestyle}; }->b;`;
71
- }).not.toThrow() );
72
-
73
-
74
- })
75
-
76
-
77
-
78
- });
79
-
80
-
81
-
82
- test.todo('Read the actual values back out');
@@ -1,157 +0,0 @@
1
-
2
- /* eslint-disable max-len */
3
-
4
- import * as jssm from '../jssm';
5
-
6
-
7
-
8
-
9
-
10
- describe('Simple stop light', () => {
11
-
12
- const light = jssm.sm`Red 'Proceed' -> Green 'Proceed' -> Yellow 'Proceed' -> Red;`;
13
-
14
- const r_states = light.states();
15
-
16
- test('has the right state count', () =>
17
- expect(r_states.length).toBe(3));
18
-
19
- ['Red', 'Yellow', 'Green'].map(c =>
20
- test(`has state "${c}"`, () =>
21
- expect(r_states.includes(c)).toBe(true))
22
- );
23
-
24
- describe('- `proceed` walkthrough', () => {
25
-
26
- test('machine starts red', () => expect( light.state() ).toBe( "Red" ));
27
- test('proceed is true', () => expect( light.action('Proceed') ).toBe( true ));
28
- test('light is now green', () => expect( light.state() ).toBe( "Green" ));
29
- test('proceed is true 2', () => expect( light.action('Proceed') ).toBe( true ));
30
- test('light is now yellow', () => expect( light.state() ).toBe( "Yellow" ));
31
- test('proceed is true 3', () => expect( light.action('Proceed') ).toBe( true ));
32
- test('light is red again', () => expect( light.state() ).toBe( "Red" ));
33
-
34
- });
35
-
36
- describe('- mixed - `proceed` and `transition`', () => {
37
-
38
- test('machine starts red', () => expect( light.state() ).toBe("Red") );
39
- test('proceed is true', () => expect( light.action('Proceed') ).toBe( true ) );
40
- test('machine is now green', () => expect( light.state() ).toBe("Green") );
41
-
42
- test('refuses transition red', () => expect( light.transition('Red') ).toBe( false ) );
43
- test('green still green', () => expect( light.state() ).toBe("Green") );
44
- test('refuses transition green', () => expect( light.transition('Green') ).toBe( false ) );
45
- test('green still green', () => expect( light.state() ).toBe("Green") );
46
- test('accepts transition yellow', () => expect( light.transition('Yellow') ).toBe( true ) );
47
- test('green now yellow', () => expect( light.state() ).toBe("Yellow") );
48
-
49
- test('proceed is true', () => expect( light.action('Proceed') ).toBe( true ) );
50
- test('machine is now red', () => expect( light.state() ).toBe("Red") );
51
-
52
- test('refuses transition yellow', () => expect( light.transition('Yellow') ).toBe( false ) );
53
- test('green still green', () => expect( light.state() ).toBe("Red") );
54
- test('refuses transition red', () => expect( light.transition('Red') ).toBe( false ) );
55
- test('green still green', () => expect( light.state() ).toBe("Red") );
56
- test('accepts transition green', () => expect( light.transition('Green') ).toBe( true ) );
57
- test('red now green', () => expect( light.state() ).toBe("Green") );
58
-
59
- test('proceed is true', () => expect( light.action('Proceed') ).toBe( true ) );
60
- test('machine is now yellow', () => expect( light.state() ).toBe("Yellow") );
61
- test('proceed is true', () => expect( light.action('Proceed') ).toBe( true ) );
62
- test('machine is now red', () => expect( light.state() ).toBe("Red") );
63
-
64
- });
65
-
66
- });
67
-
68
-
69
-
70
-
71
-
72
-
73
-
74
- describe('Complex stop light', () => {
75
-
76
- const light2 = new jssm.Machine({
77
-
78
- start_states: ['off'],
79
-
80
- transitions:[
81
-
82
- { name:'turn_on', kind: 'legal', forced_only: false, main_path: false, action:'power_on', from:'off', to:'red'},
83
-
84
- { kind: 'legal', forced_only: false, main_path: false, action:'power_off', from:'red', to:'off' },
85
- { kind: 'legal', forced_only: false, main_path: false, action:'power_off', from:'yellow', to:'off' },
86
- { kind: 'legal', forced_only: false, main_path: false, action:'power_off', from:'green', to:'off' },
87
-
88
- { name:'switch_warn', kind: 'legal', forced_only: false, main_path: false, action:'proceed', from:'green', to:'yellow' },
89
- { name:'switch_halt', kind: 'legal', forced_only: false, main_path: false, action:'proceed', from:'yellow', to:'red' },
90
- { name:'switch_go', kind: 'legal', forced_only: false, main_path: false, action:'proceed', from:'red', to:'green' }
91
-
92
- ]
93
-
94
- });
95
-
96
- const r_states = light2.states();
97
-
98
- test('has the right state count', () =>
99
- expect(r_states.length).toBe(4));
100
-
101
- ['red', 'yellow', 'green', 'off'].map(c =>
102
- test(`has state "${c}"`, () =>
103
- expect(r_states.includes(c)).toBe(true))
104
- );
105
-
106
- const r_names = light2.list_named_transitions();
107
-
108
- test('has the right named transition count', () =>
109
- expect(r_names.size).toBe(4));
110
-
111
- ['turn_on', 'switch_warn', 'switch_halt', 'switch_go'].map(a =>
112
- test(`has named transition "${a}"`, () =>
113
- expect(r_names.has(a)).toBe(true))
114
- );
115
-
116
- test('has the right exit actions for red', () =>
117
- expect(['power_off', 'proceed']).toEqual(light2.list_exit_actions('red')) );
118
-
119
-
120
- describe('- `transition` walkthrough', () => {
121
-
122
- test('machine starts off', () => expect( light2.state() ).toBe("off") );
123
- test('off refuses green', () => expect( light2.transition('green') ).toBe(false) );
124
- test('off refuses yellow', () => expect( light2.transition('yellow') ).toBe(false) );
125
-
126
- test('off refuses proceed', () => expect( light2.action('proceed') ).toBe(false) );
127
-
128
- test('off accepts red', () => expect( light2.transition('red') ).toBe(true) );
129
- test('off is now red', () => expect( light2.state() ).toBe("red") );
130
- test('red refuses yellow', () => expect( light2.transition('yellow') ).toBe(false) );
131
- test('red still red', () => expect( light2.state() ).toBe("red") );
132
- test('red refuses red', () => expect( light2.transition('red') ).toBe(false) );
133
- test('red still red 2', () => expect( light2.state() ).toBe("red") );
134
-
135
- test('red accepts green', () => expect( light2.transition('green') ).toBe(true) );
136
- test('red now green', () => expect( light2.state() ).toBe("green") );
137
- test('green refuses red', () => expect( light2.transition('red') ).toBe(false) );
138
- test('green still green', () => expect( light2.state() ).toBe("green") );
139
- test('green refuses green', () => expect( light2.transition('green') ).toBe(false) );
140
- test('green still green 2', () => expect( light2.state() ).toBe("green") );
141
-
142
- test('green accepts yellow', () => expect( light2.transition('yellow') ).toBe(true) );
143
- test('green now yellow', () => expect( light2.state() ).toBe("yellow") );
144
- test('yellow refuses green', () => expect( light2.transition('green') ).toBe(false) );
145
- test('yellow still yellow', () => expect( light2.state() ).toBe("yellow") );
146
- test('yellow refuses yellow', () => expect( light2.transition('yellow') ).toBe(false) );
147
- test('yellow still yellow 2', () => expect( light2.state() ).toBe("yellow") );
148
-
149
- test('yellow accepts red', () => expect( light2.transition('red') ).toBe(true) );
150
- test('back to red', () => expect( light2.state() ).toBe("red") );
151
-
152
- test('proceed is true', () => expect( light2.action('proceed') ).toBe(true) );
153
- test('light is now green', () => expect( light2.state() ).toBe("green") );
154
-
155
- });
156
-
157
- });
@@ -1,52 +0,0 @@
1
-
2
- /* eslint-disable max-len */
3
-
4
- import * as jssm from '../jssm';
5
-
6
-
7
-
8
-
9
-
10
- describe('stripe strategies', () => {
11
-
12
-
13
-
14
- const is_v = (str, v) =>
15
- test(str, () =>
16
- expect( jssm.parse(str) ).toEqual(v)
17
- );
18
-
19
-
20
-
21
- describe('basic stripe', () => {
22
- is_v(
23
- '[a b c] -> +|1;',
24
- [{from: ['a','b','c'], key: 'transition', se: {kind: '->', to: {key: 'stripe', value: 1}}}]
25
- );
26
- });
27
-
28
- describe('negative stripe', () => {
29
- is_v(
30
- '[a b c] -> -|1;',
31
- [{from: ['a','b','c'], key: 'transition', se: {kind: '->', to: {key: 'stripe', value: -1}}}]
32
- );
33
- });
34
-
35
- describe('wide stripe', () => {
36
- is_v(
37
- '[a b c] -> +|2;',
38
- [{from: ['a','b','c'], key: 'transition', se: {kind: '->', to: {key: 'stripe', value: 2}}}]
39
- );
40
- });
41
-
42
-
43
-
44
- test('illegal fractional stripe throws', () => {
45
-
46
- expect( () =>
47
- jssm.parse('[a b c] -> +|2.5;')
48
- ).toThrow();
49
-
50
- });
51
-
52
- });
@@ -1,45 +0,0 @@
1
-
2
- import { Themes } from './constants.spec';
3
-
4
- import { sm } from '../jssm';
5
-
6
-
7
-
8
-
9
-
10
- const baseline = sm`theme: ocean; z -> q;`,
11
- baseline_theme = baseline.theme();
12
-
13
- test('Themes sound like the ocean', () =>
14
- expect(baseline_theme).toBe('ocean') );
15
-
16
-
17
-
18
- const no_baseline = sm`z -> q;`,
19
- no_baseline_theme = no_baseline.theme();
20
-
21
- test('No theme sounds like none', () =>
22
- expect(no_baseline_theme).toBe('default') );
23
-
24
-
25
-
26
-
27
-
28
- describe('Named themes', () => {
29
-
30
- Themes.map(thisTheme =>
31
- test(`Theme "${thisTheme}" parses as a theme`, () =>
32
- expect( () => { const _foo = sm`theme: ${thisTheme}; a-> b;`; }).not.toThrow() ) );
33
-
34
- Themes.map(thisTheme =>
35
- test(`Theme "${thisTheme}" shows correct theme`, () =>
36
- expect( sm`theme: ${thisTheme}; a-> b;`.theme() ).toBe(thisTheme) ) );
37
-
38
- Themes.map(thisTheme =>
39
- test(`Missing theme shows theme "default"`, () =>
40
- expect( sm`a-> b;`.theme() ).toBe("default") ) );
41
-
42
- test('Fake theme throws', () =>
43
- expect( () => { const _foo = sm`theme: zeghezgqqqqthirteen; a-> b;`; }).toThrow() );
44
-
45
- });
@@ -1,22 +0,0 @@
1
-
2
- import * as jssm from '../jssm';
3
-
4
-
5
-
6
-
7
-
8
- describe('weighted_histo_key/2', () => {
9
-
10
- const fruit = [ { label: 'apple', probability: 0.1 },
11
- { label: 'orange', probability: 0.4 },
12
- { label: 'banana', probability: 0.5 } ];
13
-
14
- const out = jssm.weighted_histo_key(10000, fruit, 'probability', 'label');
15
-
16
- test('produces a well formed probability map', () =>
17
- expect([... out.keys()].length).toBe(3)
18
- );
19
-
20
- });
21
-
22
- // stochable
@@ -1,27 +0,0 @@
1
-
2
- import * as jssm from '../jssm';
3
-
4
-
5
-
6
-
7
-
8
- describe('weighted_rand_select/2', () => {
9
-
10
- const fruit = [ { label: 'apple', probability: 0.1 },
11
- { label: 'orange', probability: 0.4 },
12
- { label: 'banana', probability: 0.5 } ];
13
-
14
- const acc = { apple: 0, orange: 0, banana: 0 };
15
-
16
- for (let i=0; i<10000; ++i) {
17
- acc[jssm.weighted_rand_select(fruit).label] = acc[jssm.weighted_rand_select(fruit).label] + 1;
18
- }
19
-
20
- test('banana baseline', () => expect( acc.banana > 3000 ).toBe(true) );
21
-
22
- test('requires an array', () => expect( () => jssm.weighted_rand_select( 'not_an_array' )).toThrow() );
23
- test('requires members to be objects', () => expect( () => jssm.weighted_rand_select( ['not_an_obj'] )).toThrow() );
24
-
25
- });
26
-
27
- // stochable
@@ -1,24 +0,0 @@
1
-
2
- import * as jssm from '../jssm';
3
-
4
-
5
-
6
-
7
-
8
- describe('weighted_sample_select/2', () => {
9
-
10
- const fruit = [ { label: 'apple', probability: 0.1 },
11
- { label: 'orange', probability: 0.4 },
12
- { label: 'banana', probability: 0.5 } ];
13
-
14
- const none = jssm.weighted_sample_select(0, fruit),
15
- one = jssm.weighted_sample_select(1, fruit),
16
- some = jssm.weighted_sample_select(2, fruit),
17
- over = jssm.weighted_sample_select(4, fruit);
18
-
19
- test('0 returns []', () => expect(none.length).toBe(0) );
20
- test('1 returns [any]', () => expect(one.length ).toBe(1) );
21
- test('2 returns [any,any]', () => expect(some.length).toBe(2) );
22
- test('4 returns [any,any,any,any]', () => expect(over.length).toBe(4) );
23
-
24
- });
package/src/ts/version.ts DELETED
@@ -1,3 +0,0 @@
1
-
2
- const version: string = "5.45.2";
3
- export { version };