jssm 5.35.4 → 5.42.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.
- package/.codeclimate.yml +22 -22
- package/.editorconfig +12 -12
- package/.eslintrc +20 -20
- package/.nycrc +6 -6
- package/.travis.yml +8 -8
- package/LICENSE.md +21 -21
- package/README.md +997 -993
- package/dist/es6/jssm-dot.d.ts +6 -6
- package/dist/es6/jssm-dot.js +1 -1
- package/dist/es6/jssm.d.ts +100 -100
- package/dist/es6/jssm.js +792 -792
- package/dist/es6/jssm_types.d.ts +151 -151
- package/dist/es6/jssm_types.js +1 -1
- package/dist/es6/jssm_util.d.ts +8 -8
- package/dist/es6/jssm_util.js +34 -34
- package/dist/es6/version.d.ts +2 -2
- package/dist/es6/version.js +2 -2
- package/dist/jssm.es5.cjs.js +1 -1
- package/dist/jssm.es5.iife.js +1 -0
- package/jest-spec.config.js +27 -27
- package/jest-stoch.config.js +27 -27
- package/jssm-dot.d.ts +6 -6
- package/jssm.d.ts +100 -100
- package/jssm_types.d.ts +151 -151
- package/jssm_util.d.ts +8 -8
- package/package.json +125 -122
- package/rollup.config.iife.js +44 -44
- package/rollup.config.js +44 -44
- package/src/demo/index.html +38 -38
- package/src/demo/style.css +1 -1
- package/src/ts/jssm-dot.peg +928 -874
- package/src/ts/jssm.ts +1120 -1120
- package/src/ts/jssm_types.ts +346 -346
- package/src/ts/jssm_util.ts +100 -100
- package/src/ts/tests/actions.spec.ts +167 -167
- package/src/ts/tests/arrange.spec.ts +72 -72
- package/src/ts/tests/arrange.stoch.ts +4 -4
- package/src/ts/tests/array_box_if_string.spec.ts +30 -31
- package/src/ts/tests/array_transitions.spec.ts +129 -129
- package/src/ts/tests/arrow unicode.spec.ts +88 -88
- package/src/ts/tests/arrow.spec.ts +124 -124
- package/src/ts/tests/colors.spec.ts +58 -58
- package/src/ts/tests/comment.spec.ts +134 -134
- package/src/ts/tests/compile.spec.ts +79 -79
- package/src/ts/tests/constants.spec.ts +98 -98
- package/src/ts/tests/cycles.spec.ts +153 -153
- package/src/ts/tests/dot_preamble.spec.ts +16 -16
- package/src/ts/tests/embedded_sm.spec.ts +36 -36
- package/src/ts/tests/flow.spec.ts +22 -22
- package/src/ts/tests/forced transitions.spec.ts +26 -26
- package/src/ts/tests/general.spec.ts +933 -933
- package/src/ts/tests/graph node lists.spec.ts +21 -21
- package/src/ts/tests/histo.spec.ts +24 -24
- package/src/ts/tests/hooks.spec.ts +28 -0
- package/src/ts/tests/language.spec.ts +37 -37
- package/src/ts/tests/language_data/belarussian.json +13 -13
- package/src/ts/tests/language_data/bengali.json +15 -15
- package/src/ts/tests/language_data/emoji.json +21 -21
- package/src/ts/tests/language_data/english.json +16 -16
- package/src/ts/tests/language_data/french.json +16 -16
- package/src/ts/tests/language_data/german.json +16 -16
- package/src/ts/tests/language_data/hebrew.json +16 -16
- package/src/ts/tests/language_data/portuguese.json +12 -12
- package/src/ts/tests/language_data/russian.json +12 -12
- package/src/ts/tests/language_data/spanish.json +17 -17
- package/src/ts/tests/language_data/ukrainian.json +18 -18
- package/src/ts/tests/layout.spec.ts +29 -29
- package/src/ts/tests/machine_attributes.spec.ts +398 -398
- package/src/ts/tests/machine_name.spec.ts +14 -14
- package/src/ts/tests/named lists.spec.ts +24 -19
- package/src/ts/tests/nominated states.spec.ts +133 -133
- package/src/ts/tests/parse actions.spec.ts +32 -32
- package/src/ts/tests/parse.spec.ts +94 -94
- package/src/ts/tests/probability.spec.ts +146 -146
- package/src/ts/tests/r639.spec.ts +27 -27
- package/src/ts/tests/sample_select.spec.ts +173 -173
- package/src/ts/tests/seq.spec.ts +14 -16
- package/src/ts/tests/seq.stoch.ts +83 -0
- package/src/ts/tests/shapes.spec.ts +63 -63
- package/src/ts/tests/sm_tag.spec.ts +37 -37
- package/src/ts/tests/special characters.spec.ts +39 -39
- package/src/ts/tests/state_declaration.spec.ts +214 -200
- package/src/ts/tests/state_style.spec.ts +82 -39
- package/src/ts/tests/stop light.spec.ts +157 -157
- package/src/ts/tests/stripes.spec.ts +52 -52
- package/src/ts/tests/theme.spec.ts +45 -45
- package/src/ts/tests/weighted_histo_key.spec.ts +22 -22
- package/src/ts/tests/weighted_rand_select.spec.ts +27 -27
- package/src/ts/tests/weighted_sample_select.spec.ts +24 -26
- package/src/ts/version.ts +1 -1
- package/tree.txt +1794 -1794
- package/tsconfig.json +27 -27
- package/version.d.ts +2 -2
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
|
|
2
|
-
import { sm } from '../jssm';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const SpecialCharacters = ['\t', '\n', '\r', '\v'];
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
// TODO FIXME these seem to be failing?
|
|
15
|
-
|
|
16
|
-
describe('Special characters', () => {
|
|
17
|
-
|
|
18
|
-
test(`CONTAINS A FALSE TEST`, () =>
|
|
19
|
-
expect(true).toBe(true) // todo fixme whargarbl
|
|
20
|
-
);
|
|
21
|
-
|
|
22
|
-
// test(`Label "top\nbottom" parses correctly framed`, () =>
|
|
23
|
-
// expect( () => { const _foo = sm`"top\nbottom" -> b;`; }).not.toThrow() );
|
|
24
|
-
|
|
25
|
-
// SpecialCharacters.map(sc =>
|
|
26
|
-
// test(`Label "open${sc}shut" parses correctly framed`, () =>
|
|
27
|
-
// expect( () => { const _foo = sm`"open${sc}shut" -> b;`; }).not.toThrow() ) );
|
|
28
|
-
|
|
29
|
-
// SpecialCharacters.map(sc =>
|
|
30
|
-
// test(`Label "${sc}" parses correctly bare`, () =>
|
|
31
|
-
// expect( () => { const _foo = sm`"${sc}" -> b;`; }).not.toThrow() ) );
|
|
32
|
-
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
test.todo('Special characters tests are failing badly!');
|
|
1
|
+
|
|
2
|
+
import { sm } from '../jssm';
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
const SpecialCharacters = ['\t', '\n', '\r', '\v'];
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
// TODO FIXME these seem to be failing?
|
|
15
|
+
|
|
16
|
+
describe('Special characters', () => {
|
|
17
|
+
|
|
18
|
+
test(`CONTAINS A FALSE TEST`, () =>
|
|
19
|
+
expect(true).toBe(true) // todo fixme whargarbl
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
// test(`Label "top\nbottom" parses correctly framed`, () =>
|
|
23
|
+
// expect( () => { const _foo = sm`"top\nbottom" -> b;`; }).not.toThrow() );
|
|
24
|
+
|
|
25
|
+
// SpecialCharacters.map(sc =>
|
|
26
|
+
// test(`Label "open${sc}shut" parses correctly framed`, () =>
|
|
27
|
+
// expect( () => { const _foo = sm`"open${sc}shut" -> b;`; }).not.toThrow() ) );
|
|
28
|
+
|
|
29
|
+
// SpecialCharacters.map(sc =>
|
|
30
|
+
// test(`Label "${sc}" parses correctly bare`, () =>
|
|
31
|
+
// expect( () => { const _foo = sm`"${sc}" -> b;`; }).not.toThrow() ) );
|
|
32
|
+
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
test.todo('Special characters tests are failing badly!');
|
|
@@ -1,200 +1,214 @@
|
|
|
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
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
const
|
|
196
|
-
} )
|
|
197
|
-
.toThrow()
|
|
198
|
-
);
|
|
199
|
-
|
|
200
|
-
|
|
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,39 +1,82 @@
|
|
|
1
|
-
|
|
2
|
-
import { Shapes } from './constants.spec';
|
|
3
|
-
|
|
4
|
-
import { sm } from '../jssm';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
describe('State style', () => {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
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');
|