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.
Files changed (93) hide show
  1. package/.codeclimate.yml +22 -22
  2. package/.editorconfig +12 -12
  3. package/.eslintrc +20 -20
  4. package/.nycrc +6 -6
  5. package/.travis.yml +8 -8
  6. package/LICENSE.md +21 -21
  7. package/README.md +997 -993
  8. package/dist/es6/jssm-dot.d.ts +6 -6
  9. package/dist/es6/jssm-dot.js +1 -1
  10. package/dist/es6/jssm.d.ts +100 -100
  11. package/dist/es6/jssm.js +792 -792
  12. package/dist/es6/jssm_types.d.ts +151 -151
  13. package/dist/es6/jssm_types.js +1 -1
  14. package/dist/es6/jssm_util.d.ts +8 -8
  15. package/dist/es6/jssm_util.js +34 -34
  16. package/dist/es6/version.d.ts +2 -2
  17. package/dist/es6/version.js +2 -2
  18. package/dist/jssm.es5.cjs.js +1 -1
  19. package/dist/jssm.es5.iife.js +1 -0
  20. package/jest-spec.config.js +27 -27
  21. package/jest-stoch.config.js +27 -27
  22. package/jssm-dot.d.ts +6 -6
  23. package/jssm.d.ts +100 -100
  24. package/jssm_types.d.ts +151 -151
  25. package/jssm_util.d.ts +8 -8
  26. package/package.json +125 -122
  27. package/rollup.config.iife.js +44 -44
  28. package/rollup.config.js +44 -44
  29. package/src/demo/index.html +38 -38
  30. package/src/demo/style.css +1 -1
  31. package/src/ts/jssm-dot.peg +928 -874
  32. package/src/ts/jssm.ts +1120 -1120
  33. package/src/ts/jssm_types.ts +346 -346
  34. package/src/ts/jssm_util.ts +100 -100
  35. package/src/ts/tests/actions.spec.ts +167 -167
  36. package/src/ts/tests/arrange.spec.ts +72 -72
  37. package/src/ts/tests/arrange.stoch.ts +4 -4
  38. package/src/ts/tests/array_box_if_string.spec.ts +30 -31
  39. package/src/ts/tests/array_transitions.spec.ts +129 -129
  40. package/src/ts/tests/arrow unicode.spec.ts +88 -88
  41. package/src/ts/tests/arrow.spec.ts +124 -124
  42. package/src/ts/tests/colors.spec.ts +58 -58
  43. package/src/ts/tests/comment.spec.ts +134 -134
  44. package/src/ts/tests/compile.spec.ts +79 -79
  45. package/src/ts/tests/constants.spec.ts +98 -98
  46. package/src/ts/tests/cycles.spec.ts +153 -153
  47. package/src/ts/tests/dot_preamble.spec.ts +16 -16
  48. package/src/ts/tests/embedded_sm.spec.ts +36 -36
  49. package/src/ts/tests/flow.spec.ts +22 -22
  50. package/src/ts/tests/forced transitions.spec.ts +26 -26
  51. package/src/ts/tests/general.spec.ts +933 -933
  52. package/src/ts/tests/graph node lists.spec.ts +21 -21
  53. package/src/ts/tests/histo.spec.ts +24 -24
  54. package/src/ts/tests/hooks.spec.ts +28 -0
  55. package/src/ts/tests/language.spec.ts +37 -37
  56. package/src/ts/tests/language_data/belarussian.json +13 -13
  57. package/src/ts/tests/language_data/bengali.json +15 -15
  58. package/src/ts/tests/language_data/emoji.json +21 -21
  59. package/src/ts/tests/language_data/english.json +16 -16
  60. package/src/ts/tests/language_data/french.json +16 -16
  61. package/src/ts/tests/language_data/german.json +16 -16
  62. package/src/ts/tests/language_data/hebrew.json +16 -16
  63. package/src/ts/tests/language_data/portuguese.json +12 -12
  64. package/src/ts/tests/language_data/russian.json +12 -12
  65. package/src/ts/tests/language_data/spanish.json +17 -17
  66. package/src/ts/tests/language_data/ukrainian.json +18 -18
  67. package/src/ts/tests/layout.spec.ts +29 -29
  68. package/src/ts/tests/machine_attributes.spec.ts +398 -398
  69. package/src/ts/tests/machine_name.spec.ts +14 -14
  70. package/src/ts/tests/named lists.spec.ts +24 -19
  71. package/src/ts/tests/nominated states.spec.ts +133 -133
  72. package/src/ts/tests/parse actions.spec.ts +32 -32
  73. package/src/ts/tests/parse.spec.ts +94 -94
  74. package/src/ts/tests/probability.spec.ts +146 -146
  75. package/src/ts/tests/r639.spec.ts +27 -27
  76. package/src/ts/tests/sample_select.spec.ts +173 -173
  77. package/src/ts/tests/seq.spec.ts +14 -16
  78. package/src/ts/tests/seq.stoch.ts +83 -0
  79. package/src/ts/tests/shapes.spec.ts +63 -63
  80. package/src/ts/tests/sm_tag.spec.ts +37 -37
  81. package/src/ts/tests/special characters.spec.ts +39 -39
  82. package/src/ts/tests/state_declaration.spec.ts +214 -200
  83. package/src/ts/tests/state_style.spec.ts +82 -39
  84. package/src/ts/tests/stop light.spec.ts +157 -157
  85. package/src/ts/tests/stripes.spec.ts +52 -52
  86. package/src/ts/tests/theme.spec.ts +45 -45
  87. package/src/ts/tests/weighted_histo_key.spec.ts +22 -22
  88. package/src/ts/tests/weighted_rand_select.spec.ts +27 -27
  89. package/src/ts/tests/weighted_sample_select.spec.ts +24 -26
  90. package/src/ts/version.ts +1 -1
  91. package/tree.txt +1794 -1794
  92. package/tsconfig.json +27 -27
  93. package/version.d.ts +2 -2
@@ -1,153 +1,153 @@
1
-
2
- /* eslint-disable max-len */
3
-
4
- import * as jssm from '../jssm';
5
-
6
-
7
-
8
-
9
-
10
- const testdata = [
11
-
12
- [
13
- 'basic cycle',
14
- '[a b c] -> +1;',
15
- [{from: ['a','b','c'], key: 'transition', se: {kind: '->', to: {key: 'cycle', value: 1}}}]
16
- ],
17
-
18
- [
19
- 'negative cycle',
20
- '[a b c] -> -1;',
21
- [{from: ['a','b','c'], key: 'transition', se: {kind: '->', to: {key: 'cycle', value: -1}}}]
22
- ],
23
-
24
- [
25
- 'nullary cycle',
26
- '[a b c] -> +0;',
27
- [{from: ['a','b','c'], key: 'transition', se: {kind: '->', to: {key: 'cycle', value: 0}}}]
28
- ],
29
-
30
- [
31
- 'wide cycle',
32
- '[a b c] -> +2;',
33
- [{from: ['a','b','c'], key: 'transition', se: {kind: '->', to: {key: 'cycle', value: 2}}}]
34
- ],
35
-
36
- [
37
- 'reverse basic cycle',
38
- '+1 <- [a b c];',
39
- [{from: {key: 'cycle', value: 1}, key: 'transition', se: {kind: '<-', to: ['a','b','c']}}]
40
- ],
41
-
42
- [
43
- 'reverse negative cycle',
44
- '-1 <- [a b c];',
45
- [{from: {key: 'cycle', value: -1}, key: 'transition', se: {kind: '<-', to: ['a','b','c']}}]
46
- ],
47
-
48
- [
49
- 'reverse nullary cycle',
50
- '+0 <- [a b c];',
51
- [{from: {key: 'cycle', value: 0}, key: 'transition', se: {kind: '<-', to: ['a','b','c']}}]
52
- ],
53
-
54
- [
55
- 'reverse wide cycle',
56
- '+2 <- [a b c];',
57
- [{from: {key: 'cycle', value: 2}, key: 'transition', se: {kind: '<-', to: ['a','b','c']}}]
58
- ],
59
-
60
- [
61
- 'bidi basic cycle',
62
- '+1 <- [a b c] -> +1;',
63
- [{from: {key: 'cycle', value: 1}, key: 'transition', se: {kind: '<-', se: {kind: '->', to: {key: 'cycle', value: 1}}, to: ['a','b','c']}}]
64
- ],
65
-
66
- [
67
- 'bidi negative cycle',
68
- '-1 <- [a b c] -> -1;',
69
- [{from: {key: 'cycle', value: -1}, key: 'transition', se: {kind: '<-', se: {kind: '->', to: {key: 'cycle', value: -1}}, to: ['a','b','c']}}]
70
- ],
71
-
72
- [
73
- 'bidi basic/negative cycle',
74
- '+1 <- [a b c] -> -1;',
75
- [{from: {key: 'cycle', value: 1}, key: 'transition', se: {kind: '<-', se: {kind: '->', to: {key: 'cycle', value: -1}}, to: ['a','b','c']}}]
76
- ],
77
-
78
- [
79
- 'bidi nullary cycle',
80
- '+0 <- [a b c] -> +0;',
81
- [{from: {key: 'cycle', value: 0}, key: 'transition', se: {kind: '<-', se: {kind: '->', to: {key: 'cycle', value: 0}}, to: ['a','b','c']}}]
82
- ],
83
-
84
- [
85
- 'bidi wide cycle',
86
- '+2 <- [a b c] -> -2;',
87
- [{from: {key: 'cycle', value: 2}, key: 'transition', se: {kind: '<-', se: {kind: '->', to: {key: 'cycle', value: -2}}, to: ['a','b','c']}}]
88
- ]
89
-
90
- ];
91
-
92
-
93
-
94
-
95
-
96
- describe('cycle strategies', () => {
97
-
98
-
99
- const is_v = (label, str, v) =>
100
- test(`${label} (strategy ${str})`, () =>
101
- expect( jssm.parse(str) ).toEqual(v) );
102
-
103
- testdata.map( ([ label, code, res ]) => is_v(label, code, res) );
104
-
105
- test.todo('cycle full parses');
106
-
107
- /*
108
- describe('full parse of 2-step cycle', () => {
109
- it('[a b] -> +1;', t => t.deepEqual(
110
- sm`[a b] -> +1;`.list_edges(),
111
- [{"from":"a","to":"b","kind":"legal","forced_only":false,"main_path":false},
112
- {"from":"b","to":"a","kind":"legal","forced_only":false,"main_path":false}]
113
- ));
114
- });
115
-
116
- describe('full parse of 5-step cycle', () => {
117
- it('[a b c d e] -> +1;', t => t.deepEqual(
118
- sm`[a b] -> +1;`.list_edges(),
119
- [{"from":"a","to":"b","kind":"legal","forced_only":false,"main_path":false},
120
- {"from":"b","to":"c","kind":"legal","forced_only":false,"main_path":false},
121
- {"from":"c","to":"d","kind":"legal","forced_only":false,"main_path":false},
122
- {"from":"d","to":"e","kind":"legal","forced_only":false,"main_path":false},
123
- {"from":"e","to":"a","kind":"legal","forced_only":false,"main_path":false}]
124
- ));
125
-
126
- describe('full parse of 5-step reverse cycle', () => {
127
- it('[a b c d e] -> -1;', t => t.deepEqual(
128
- sm`[a b] -> +1;`.list_edges(),
129
- [{"from":"a","to":"e","kind":"legal","forced_only":false,"main_path":false},
130
- {"from":"b","to":"a","kind":"legal","forced_only":false,"main_path":false},
131
- {"from":"c","to":"b","kind":"legal","forced_only":false,"main_path":false},
132
- {"from":"d","to":"c","kind":"legal","forced_only":false,"main_path":false},
133
- {"from":"e","to":"d","kind":"legal","forced_only":false,"main_path":false}]
134
- ));
135
- });
136
-
137
- describe('full parse of 5-step two-step cycle (star)', () => {
138
- it('[a b c d e] -> +2;', t => t.deepEqual(
139
- sm`[a b] -> +1;`.list_edges(),
140
- [{"from":"a","to":"c","kind":"legal","forced_only":false,"main_path":false},
141
- {"from":"b","to":"d","kind":"legal","forced_only":false,"main_path":false},
142
- {"from":"c","to":"e","kind":"legal","forced_only":false,"main_path":false},
143
- {"from":"d","to":"a","kind":"legal","forced_only":false,"main_path":false},
144
- {"from":"e","to":"b","kind":"legal","forced_only":false,"main_path":false}]
145
- ));
146
- });
147
- */
148
-
149
- });
150
-
151
- test('illegal fractional cycle throws', () => {
152
- expect( () => jssm.parse('[a b c] -> +2.5;') ).toThrow();
153
- });
1
+
2
+ /* eslint-disable max-len */
3
+
4
+ import * as jssm from '../jssm';
5
+
6
+
7
+
8
+
9
+
10
+ const testdata = [
11
+
12
+ [
13
+ 'basic cycle',
14
+ '[a b c] -> +1;',
15
+ [{from: ['a','b','c'], key: 'transition', se: {kind: '->', to: {key: 'cycle', value: 1}}}]
16
+ ],
17
+
18
+ [
19
+ 'negative cycle',
20
+ '[a b c] -> -1;',
21
+ [{from: ['a','b','c'], key: 'transition', se: {kind: '->', to: {key: 'cycle', value: -1}}}]
22
+ ],
23
+
24
+ [
25
+ 'nullary cycle',
26
+ '[a b c] -> +0;',
27
+ [{from: ['a','b','c'], key: 'transition', se: {kind: '->', to: {key: 'cycle', value: 0}}}]
28
+ ],
29
+
30
+ [
31
+ 'wide cycle',
32
+ '[a b c] -> +2;',
33
+ [{from: ['a','b','c'], key: 'transition', se: {kind: '->', to: {key: 'cycle', value: 2}}}]
34
+ ],
35
+
36
+ [
37
+ 'reverse basic cycle',
38
+ '+1 <- [a b c];',
39
+ [{from: {key: 'cycle', value: 1}, key: 'transition', se: {kind: '<-', to: ['a','b','c']}}]
40
+ ],
41
+
42
+ [
43
+ 'reverse negative cycle',
44
+ '-1 <- [a b c];',
45
+ [{from: {key: 'cycle', value: -1}, key: 'transition', se: {kind: '<-', to: ['a','b','c']}}]
46
+ ],
47
+
48
+ [
49
+ 'reverse nullary cycle',
50
+ '+0 <- [a b c];',
51
+ [{from: {key: 'cycle', value: 0}, key: 'transition', se: {kind: '<-', to: ['a','b','c']}}]
52
+ ],
53
+
54
+ [
55
+ 'reverse wide cycle',
56
+ '+2 <- [a b c];',
57
+ [{from: {key: 'cycle', value: 2}, key: 'transition', se: {kind: '<-', to: ['a','b','c']}}]
58
+ ],
59
+
60
+ [
61
+ 'bidi basic cycle',
62
+ '+1 <- [a b c] -> +1;',
63
+ [{from: {key: 'cycle', value: 1}, key: 'transition', se: {kind: '<-', se: {kind: '->', to: {key: 'cycle', value: 1}}, to: ['a','b','c']}}]
64
+ ],
65
+
66
+ [
67
+ 'bidi negative cycle',
68
+ '-1 <- [a b c] -> -1;',
69
+ [{from: {key: 'cycle', value: -1}, key: 'transition', se: {kind: '<-', se: {kind: '->', to: {key: 'cycle', value: -1}}, to: ['a','b','c']}}]
70
+ ],
71
+
72
+ [
73
+ 'bidi basic/negative cycle',
74
+ '+1 <- [a b c] -> -1;',
75
+ [{from: {key: 'cycle', value: 1}, key: 'transition', se: {kind: '<-', se: {kind: '->', to: {key: 'cycle', value: -1}}, to: ['a','b','c']}}]
76
+ ],
77
+
78
+ [
79
+ 'bidi nullary cycle',
80
+ '+0 <- [a b c] -> +0;',
81
+ [{from: {key: 'cycle', value: 0}, key: 'transition', se: {kind: '<-', se: {kind: '->', to: {key: 'cycle', value: 0}}, to: ['a','b','c']}}]
82
+ ],
83
+
84
+ [
85
+ 'bidi wide cycle',
86
+ '+2 <- [a b c] -> -2;',
87
+ [{from: {key: 'cycle', value: 2}, key: 'transition', se: {kind: '<-', se: {kind: '->', to: {key: 'cycle', value: -2}}, to: ['a','b','c']}}]
88
+ ]
89
+
90
+ ];
91
+
92
+
93
+
94
+
95
+
96
+ describe('cycle strategies', () => {
97
+
98
+
99
+ const is_v = (label, str, v) =>
100
+ test(`${label} (strategy ${str})`, () =>
101
+ expect( jssm.parse(str) ).toEqual(v) );
102
+
103
+ testdata.map( ([ label, code, res ]) => is_v(label, code, res) );
104
+
105
+ test.todo('cycle full parses');
106
+
107
+ /*
108
+ describe('full parse of 2-step cycle', () => {
109
+ it('[a b] -> +1;', t => t.deepEqual(
110
+ sm`[a b] -> +1;`.list_edges(),
111
+ [{"from":"a","to":"b","kind":"legal","forced_only":false,"main_path":false},
112
+ {"from":"b","to":"a","kind":"legal","forced_only":false,"main_path":false}]
113
+ ));
114
+ });
115
+
116
+ describe('full parse of 5-step cycle', () => {
117
+ it('[a b c d e] -> +1;', t => t.deepEqual(
118
+ sm`[a b] -> +1;`.list_edges(),
119
+ [{"from":"a","to":"b","kind":"legal","forced_only":false,"main_path":false},
120
+ {"from":"b","to":"c","kind":"legal","forced_only":false,"main_path":false},
121
+ {"from":"c","to":"d","kind":"legal","forced_only":false,"main_path":false},
122
+ {"from":"d","to":"e","kind":"legal","forced_only":false,"main_path":false},
123
+ {"from":"e","to":"a","kind":"legal","forced_only":false,"main_path":false}]
124
+ ));
125
+
126
+ describe('full parse of 5-step reverse cycle', () => {
127
+ it('[a b c d e] -> -1;', t => t.deepEqual(
128
+ sm`[a b] -> +1;`.list_edges(),
129
+ [{"from":"a","to":"e","kind":"legal","forced_only":false,"main_path":false},
130
+ {"from":"b","to":"a","kind":"legal","forced_only":false,"main_path":false},
131
+ {"from":"c","to":"b","kind":"legal","forced_only":false,"main_path":false},
132
+ {"from":"d","to":"c","kind":"legal","forced_only":false,"main_path":false},
133
+ {"from":"e","to":"d","kind":"legal","forced_only":false,"main_path":false}]
134
+ ));
135
+ });
136
+
137
+ describe('full parse of 5-step two-step cycle (star)', () => {
138
+ it('[a b c d e] -> +2;', t => t.deepEqual(
139
+ sm`[a b] -> +1;`.list_edges(),
140
+ [{"from":"a","to":"c","kind":"legal","forced_only":false,"main_path":false},
141
+ {"from":"b","to":"d","kind":"legal","forced_only":false,"main_path":false},
142
+ {"from":"c","to":"e","kind":"legal","forced_only":false,"main_path":false},
143
+ {"from":"d","to":"a","kind":"legal","forced_only":false,"main_path":false},
144
+ {"from":"e","to":"b","kind":"legal","forced_only":false,"main_path":false}]
145
+ ));
146
+ });
147
+ */
148
+
149
+ });
150
+
151
+ test('illegal fractional cycle throws', () => {
152
+ expect( () => jssm.parse('[a b c] -> +2.5;') ).toThrow();
153
+ });
@@ -1,16 +1,16 @@
1
-
2
- import { sm } from '../jssm';
3
-
4
-
5
-
6
-
7
-
8
- describe('Dot preamble', () => {
9
-
10
- test(`doesn't throw`, () =>
11
- expect( () => { const _foo = sm`dot_preamble: "x -> y;"; a-> b;`; }).not.toThrow() );
12
-
13
- test('parses correctly', () =>
14
- expect( sm`dot_preamble: "x -> y;"; a-> b;`.dot_preamble() ).toBe('x -> y;') );
15
-
16
- });
1
+
2
+ import { sm } from '../jssm';
3
+
4
+
5
+
6
+
7
+
8
+ describe('Dot preamble', () => {
9
+
10
+ test(`doesn't throw`, () =>
11
+ expect( () => { const _foo = sm`dot_preamble: "x -> y;"; a-> b;`; }).not.toThrow() );
12
+
13
+ test('parses correctly', () =>
14
+ expect( sm`dot_preamble: "x -> y;"; a-> b;`.dot_preamble() ).toBe('x -> y;') );
15
+
16
+ });
@@ -1,36 +1,36 @@
1
-
2
- import { sm } from '../jssm';
3
-
4
-
5
-
6
-
7
-
8
- const testdata = [
9
- 'a -> b;',
10
- 'flow: right; a -> b -> c -> d -> a;'
11
- ];
12
-
13
- const host = sm`x -> y;`;
14
-
15
-
16
-
17
-
18
-
19
- describe('Embedded sm parses the same as regular sm', () => {
20
-
21
- testdata.map(code => {
22
-
23
- test(`Self-match of \`${code}\``, () => {
24
- expect( sm`${code}` ).toEqual( host.sm`${code}` );
25
- });
26
-
27
- });
28
-
29
- });
30
-
31
-
32
-
33
-
34
-
35
- test.todo('Boy is this embedded sm matching thing ever a candidate for stochastics');
36
- // stochable
1
+
2
+ import { sm } from '../jssm';
3
+
4
+
5
+
6
+
7
+
8
+ const testdata = [
9
+ 'a -> b;',
10
+ 'flow: right; a -> b -> c -> d -> a;'
11
+ ];
12
+
13
+ const host = sm`x -> y;`;
14
+
15
+
16
+
17
+
18
+
19
+ describe('Embedded sm parses the same as regular sm', () => {
20
+
21
+ testdata.map(code => {
22
+
23
+ test(`Self-match of \`${code}\``, () => {
24
+ expect( sm`${code}` ).toEqual( host.sm`${code}` );
25
+ });
26
+
27
+ });
28
+
29
+ });
30
+
31
+
32
+
33
+
34
+
35
+ test.todo('Boy is this embedded sm matching thing ever a candidate for stochastics');
36
+ // stochable
@@ -1,22 +1,22 @@
1
-
2
- import { FlowDirections } from './constants.spec';
3
- import { sm } from '../jssm';
4
-
5
-
6
-
7
-
8
-
9
- describe('Flow directions', () => {
10
-
11
- FlowDirections.map( thisDir =>
12
- test(`Direction "${thisDir}" parses as a flow direction`, () =>
13
- expect( () => { const _foo = sm`flow: ${thisDir}; a-> b;`; }).not.toThrow() ) );
14
-
15
- FlowDirections.map( thisDir =>
16
- test(`Direction "${thisDir}" parses correctly`, () =>
17
- expect( sm`flow: ${thisDir}; a-> b;`.flow() ).toBe(thisDir) ) );
18
-
19
- test('Fake flow direction throws', () =>
20
- expect( () => { const _foo = sm`flow: yourFlowIsWhackSon; a-> b;`; } ).toThrow() );
21
-
22
- });
1
+
2
+ import { FlowDirections } from './constants.spec';
3
+ import { sm } from '../jssm';
4
+
5
+
6
+
7
+
8
+
9
+ describe('Flow directions', () => {
10
+
11
+ FlowDirections.map( thisDir =>
12
+ test(`Direction "${thisDir}" parses as a flow direction`, () =>
13
+ expect( () => { const _foo = sm`flow: ${thisDir}; a-> b;`; }).not.toThrow() ) );
14
+
15
+ FlowDirections.map( thisDir =>
16
+ test(`Direction "${thisDir}" parses correctly`, () =>
17
+ expect( sm`flow: ${thisDir}; a-> b;`.flow() ).toBe(thisDir) ) );
18
+
19
+ test('Fake flow direction throws', () =>
20
+ expect( () => { const _foo = sm`flow: yourFlowIsWhackSon; a-> b;`; } ).toThrow() );
21
+
22
+ });
@@ -1,26 +1,26 @@
1
-
2
- /* eslint-disable max-len */
3
-
4
- import { sm } from '../jssm';
5
-
6
-
7
-
8
-
9
-
10
- describe('reject and accept correctly', () => {
11
-
12
- const machine = sm` a ~> b -> c; `;
13
-
14
- test('starts in a', () => expect( machine.state() ).toBe('a') );
15
- test('rejects transition to b', () => expect( machine.transition('b') ).toBe(false) );
16
- test('still in a', () => expect( machine.state() ).toBe('a') );
17
- test('rejects transition to c', () => expect( machine.transition('c') ).toBe(false) );
18
- test('still in a 2', () => expect( machine.state() ).toBe('a') );
19
- test('rejects forced transition to c', () => expect( machine.force_transition('c') ).toBe(false) );
20
- test('still in a 3', () => expect( machine.state() ).toBe('a') );
21
- test('accepts forced transition to b', () => expect( machine.force_transition('b') ).toBe(true) );
22
- test('now in b', () => expect( machine.state() ).toBe('b') );
23
- test('accepts transition to c', () => expect( machine.transition('c') ).toBe(true) );
24
- test('now in c', () => expect( machine.state() ).toBe('c') );
25
-
26
- });
1
+
2
+ /* eslint-disable max-len */
3
+
4
+ import { sm } from '../jssm';
5
+
6
+
7
+
8
+
9
+
10
+ describe('reject and accept correctly', () => {
11
+
12
+ const machine = sm` a ~> b -> c; `;
13
+
14
+ test('starts in a', () => expect( machine.state() ).toBe('a') );
15
+ test('rejects transition to b', () => expect( machine.transition('b') ).toBe(false) );
16
+ test('still in a', () => expect( machine.state() ).toBe('a') );
17
+ test('rejects transition to c', () => expect( machine.transition('c') ).toBe(false) );
18
+ test('still in a 2', () => expect( machine.state() ).toBe('a') );
19
+ test('rejects forced transition to c', () => expect( machine.force_transition('c') ).toBe(false) );
20
+ test('still in a 3', () => expect( machine.state() ).toBe('a') );
21
+ test('accepts forced transition to b', () => expect( machine.force_transition('b') ).toBe(true) );
22
+ test('now in b', () => expect( machine.state() ).toBe('b') );
23
+ test('accepts transition to c', () => expect( machine.transition('c') ).toBe(true) );
24
+ test('now in c', () => expect( machine.state() ).toBe('c') );
25
+
26
+ });