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,173 +1,173 @@
|
|
|
1
|
-
|
|
2
|
-
import * as jssm from '../jssm';
|
|
3
|
-
|
|
4
|
-
const sm = jssm.sm;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
describe('weighted_sample_select/1', () => {
|
|
11
|
-
|
|
12
|
-
test.todo('wow is this hard to meaningfully test');
|
|
13
|
-
it('(0) generates []', () =>
|
|
14
|
-
expect( jssm.weighted_sample_select(0, [{item:'a',probability:2},{item:'a',probability:3}]) )
|
|
15
|
-
.toEqual( [] )
|
|
16
|
-
);
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
describe('has reasonable unweighted distribution', () => {
|
|
21
|
-
|
|
22
|
-
const unweighted = new jssm.Machine({
|
|
23
|
-
|
|
24
|
-
start_states: ['a'],
|
|
25
|
-
|
|
26
|
-
transitions: [
|
|
27
|
-
|
|
28
|
-
{ from: 'a', to: 'b', kind: 'legal', forced_only: false, main_path: false },
|
|
29
|
-
{ from: 'a', to: 'c', kind: 'legal', forced_only: false, main_path: false },
|
|
30
|
-
|
|
31
|
-
{ from: 'b', to: 'a', kind: 'legal', forced_only: false, main_path: false },
|
|
32
|
-
{ from: 'b', to: 'c', kind: 'legal', forced_only: false, main_path: false },
|
|
33
|
-
|
|
34
|
-
{ from: 'c', to: 'a', kind: 'legal', forced_only: false, main_path: false },
|
|
35
|
-
{ from: 'c', to: 'b', kind: 'legal', forced_only: false, main_path: false }
|
|
36
|
-
|
|
37
|
-
]
|
|
38
|
-
|
|
39
|
-
});
|
|
40
|
-
|
|
41
|
-
const res = unweighted.probabilistic_histo_walk(1500);
|
|
42
|
-
|
|
43
|
-
// statistically each should be around 500. raise alarms if they aren't 300.
|
|
44
|
-
test('a expects 500 requires 300', () =>
|
|
45
|
-
expect(res.get('a') >= 300)
|
|
46
|
-
.toBe(true) );
|
|
47
|
-
|
|
48
|
-
test('b expects 500 requires 300', () =>
|
|
49
|
-
expect(res.get('b') >= 300)
|
|
50
|
-
.toBe(true) );
|
|
51
|
-
|
|
52
|
-
test('c expects 500 requires 300', () =>
|
|
53
|
-
expect(res.get('c') >= 300)
|
|
54
|
-
.toBe(true) );
|
|
55
|
-
|
|
56
|
-
});
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
describe('has reasonable weighted distribution', () => {
|
|
61
|
-
|
|
62
|
-
const weighted = new jssm.Machine({
|
|
63
|
-
|
|
64
|
-
start_states: ['a'],
|
|
65
|
-
|
|
66
|
-
transitions: [
|
|
67
|
-
|
|
68
|
-
{ from: 'a', to: 'b', probability: 0.5, kind: 'legal', forced_only: false, main_path: false },
|
|
69
|
-
{ from: 'a', to: 'c', probability: 4, kind: 'legal', forced_only: false, main_path: false },
|
|
70
|
-
{ from: 'a', to: 'd', probability: 0.5, kind: 'legal', forced_only: false, main_path: false },
|
|
71
|
-
{ from: 'a', to: 'e', probability: 0.5, kind: 'legal', forced_only: false, main_path: false },
|
|
72
|
-
|
|
73
|
-
{ from: 'b', to: 'a', probability: 0.5, kind: 'legal', forced_only: false, main_path: false },
|
|
74
|
-
{ from: 'b', to: 'c', probability: 4, kind: 'legal', forced_only: false, main_path: false },
|
|
75
|
-
{ from: 'b', to: 'd', probability: 0.5, kind: 'legal', forced_only: false, main_path: false },
|
|
76
|
-
{ from: 'b', to: 'e', probability: 0.5, kind: 'legal', forced_only: false, main_path: false },
|
|
77
|
-
|
|
78
|
-
{ from: 'c', to: 'a', probability: 0.5, kind: 'legal', forced_only: false, main_path: false },
|
|
79
|
-
{ from: 'c', to: 'b', probability: 0.5, kind: 'legal', forced_only: false, main_path: false },
|
|
80
|
-
{ from: 'c', to: 'd', probability: 0.5, kind: 'legal', forced_only: false, main_path: false },
|
|
81
|
-
{ from: 'c', to: 'e', probability: 0.5, kind: 'legal', forced_only: false, main_path: false },
|
|
82
|
-
|
|
83
|
-
{ from: 'd', to: 'a', probability: 0.5, kind: 'legal', forced_only: false, main_path: false },
|
|
84
|
-
{ from: 'd', to: 'b', probability: 0.5, kind: 'legal', forced_only: false, main_path: false },
|
|
85
|
-
{ from: 'd', to: 'c', probability: 4, kind: 'legal', forced_only: false, main_path: false },
|
|
86
|
-
{ from: 'd', to: 'e', probability: 0.5, kind: 'legal', forced_only: false, main_path: false },
|
|
87
|
-
|
|
88
|
-
{ from: 'e', to: 'a', probability: 0.5, kind: 'legal', forced_only: false, main_path: false },
|
|
89
|
-
{ from: 'e', to: 'b', probability: 0.5, kind: 'legal', forced_only: false, main_path: false },
|
|
90
|
-
{ from: 'e', to: 'c', probability: 4, kind: 'legal', forced_only: false, main_path: false },
|
|
91
|
-
{ from: 'e', to: 'd', probability: 0.5, kind: 'legal', forced_only: false, main_path: false }
|
|
92
|
-
|
|
93
|
-
]
|
|
94
|
-
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
const res = weighted.probabilistic_histo_walk(2500);
|
|
98
|
-
|
|
99
|
-
// statistically each should be around 375, or 1050 for c. raise alarms if they aren't 250, or 800 for c.
|
|
100
|
-
test('a expects 375 requires 250', () =>
|
|
101
|
-
expect(res.get('a') >= 250)
|
|
102
|
-
.toBe(true) );
|
|
103
|
-
|
|
104
|
-
test('b expects 375 requires 250', () =>
|
|
105
|
-
expect(res.get('b') >= 250)
|
|
106
|
-
.toBe(true) );
|
|
107
|
-
|
|
108
|
-
test('c expects 1050 requires 800', () =>
|
|
109
|
-
expect(res.get('c') >= 800)
|
|
110
|
-
.toBe(true) );
|
|
111
|
-
|
|
112
|
-
test('d expects 375 requires 250', () =>
|
|
113
|
-
expect(res.get('c') >= 250)
|
|
114
|
-
.toBe(true) );
|
|
115
|
-
|
|
116
|
-
test('e expects 375 requires 250', () =>
|
|
117
|
-
expect(res.get('c') >= 250)
|
|
118
|
-
.toBe(true) );
|
|
119
|
-
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
describe('has reasonable weighted distribution in DSL', () => {
|
|
127
|
-
|
|
128
|
-
const weighted = sm`
|
|
129
|
-
a 0.5% -> [b d e];
|
|
130
|
-
b 0.5% -> [a d e];
|
|
131
|
-
c 0.5% -> [a b d e];
|
|
132
|
-
d 0.5% -> [a b e];
|
|
133
|
-
[a b d] <- 0.5% e;
|
|
134
|
-
[a b d e] 4% -> c;
|
|
135
|
-
`;
|
|
136
|
-
|
|
137
|
-
const res = weighted.probabilistic_histo_walk(2500);
|
|
138
|
-
|
|
139
|
-
// statistically each should be around 375, or 1050 for c. raise alarms if they aren't 250, or 800 for c.
|
|
140
|
-
test('a expects 375 requires 250', () =>
|
|
141
|
-
expect(res.get('a') >= 250)
|
|
142
|
-
.toBe(true) );
|
|
143
|
-
|
|
144
|
-
test('b expects 375 requires 250', () =>
|
|
145
|
-
expect(res.get('b') >= 250)
|
|
146
|
-
.toBe(true) );
|
|
147
|
-
|
|
148
|
-
test('c expects 1050 requires 800', () =>
|
|
149
|
-
expect(res.get('c') >= 800)
|
|
150
|
-
.toBe(true) );
|
|
151
|
-
|
|
152
|
-
test('d expects 375 requires 250', () =>
|
|
153
|
-
expect(res.get('c') >= 250)
|
|
154
|
-
.toBe(true) );
|
|
155
|
-
|
|
156
|
-
test('e expects 375 requires 250', () =>
|
|
157
|
-
expect(res.get('c') >= 250)
|
|
158
|
-
.toBe(true) );
|
|
159
|
-
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
// stochastics would help, eg "every returned item is a member" and "in a
|
|
163
|
-
// sufficient list any positive sample size is reasonable" and "always
|
|
164
|
-
// returns the right sample size" - whargarbl todo
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
// stochable
|
|
1
|
+
|
|
2
|
+
import * as jssm from '../jssm';
|
|
3
|
+
|
|
4
|
+
const sm = jssm.sm;
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
describe('weighted_sample_select/1', () => {
|
|
11
|
+
|
|
12
|
+
test.todo('wow is this hard to meaningfully test');
|
|
13
|
+
it('(0) generates []', () =>
|
|
14
|
+
expect( jssm.weighted_sample_select(0, [{item:'a',probability:2},{item:'a',probability:3}]) )
|
|
15
|
+
.toEqual( [] )
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
describe('has reasonable unweighted distribution', () => {
|
|
21
|
+
|
|
22
|
+
const unweighted = new jssm.Machine({
|
|
23
|
+
|
|
24
|
+
start_states: ['a'],
|
|
25
|
+
|
|
26
|
+
transitions: [
|
|
27
|
+
|
|
28
|
+
{ from: 'a', to: 'b', kind: 'legal', forced_only: false, main_path: false },
|
|
29
|
+
{ from: 'a', to: 'c', kind: 'legal', forced_only: false, main_path: false },
|
|
30
|
+
|
|
31
|
+
{ from: 'b', to: 'a', kind: 'legal', forced_only: false, main_path: false },
|
|
32
|
+
{ from: 'b', to: 'c', kind: 'legal', forced_only: false, main_path: false },
|
|
33
|
+
|
|
34
|
+
{ from: 'c', to: 'a', kind: 'legal', forced_only: false, main_path: false },
|
|
35
|
+
{ from: 'c', to: 'b', kind: 'legal', forced_only: false, main_path: false }
|
|
36
|
+
|
|
37
|
+
]
|
|
38
|
+
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
const res = unweighted.probabilistic_histo_walk(1500);
|
|
42
|
+
|
|
43
|
+
// statistically each should be around 500. raise alarms if they aren't 300.
|
|
44
|
+
test('a expects 500 requires 300', () =>
|
|
45
|
+
expect(res.get('a') >= 300)
|
|
46
|
+
.toBe(true) );
|
|
47
|
+
|
|
48
|
+
test('b expects 500 requires 300', () =>
|
|
49
|
+
expect(res.get('b') >= 300)
|
|
50
|
+
.toBe(true) );
|
|
51
|
+
|
|
52
|
+
test('c expects 500 requires 300', () =>
|
|
53
|
+
expect(res.get('c') >= 300)
|
|
54
|
+
.toBe(true) );
|
|
55
|
+
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
describe('has reasonable weighted distribution', () => {
|
|
61
|
+
|
|
62
|
+
const weighted = new jssm.Machine({
|
|
63
|
+
|
|
64
|
+
start_states: ['a'],
|
|
65
|
+
|
|
66
|
+
transitions: [
|
|
67
|
+
|
|
68
|
+
{ from: 'a', to: 'b', probability: 0.5, kind: 'legal', forced_only: false, main_path: false },
|
|
69
|
+
{ from: 'a', to: 'c', probability: 4, kind: 'legal', forced_only: false, main_path: false },
|
|
70
|
+
{ from: 'a', to: 'd', probability: 0.5, kind: 'legal', forced_only: false, main_path: false },
|
|
71
|
+
{ from: 'a', to: 'e', probability: 0.5, kind: 'legal', forced_only: false, main_path: false },
|
|
72
|
+
|
|
73
|
+
{ from: 'b', to: 'a', probability: 0.5, kind: 'legal', forced_only: false, main_path: false },
|
|
74
|
+
{ from: 'b', to: 'c', probability: 4, kind: 'legal', forced_only: false, main_path: false },
|
|
75
|
+
{ from: 'b', to: 'd', probability: 0.5, kind: 'legal', forced_only: false, main_path: false },
|
|
76
|
+
{ from: 'b', to: 'e', probability: 0.5, kind: 'legal', forced_only: false, main_path: false },
|
|
77
|
+
|
|
78
|
+
{ from: 'c', to: 'a', probability: 0.5, kind: 'legal', forced_only: false, main_path: false },
|
|
79
|
+
{ from: 'c', to: 'b', probability: 0.5, kind: 'legal', forced_only: false, main_path: false },
|
|
80
|
+
{ from: 'c', to: 'd', probability: 0.5, kind: 'legal', forced_only: false, main_path: false },
|
|
81
|
+
{ from: 'c', to: 'e', probability: 0.5, kind: 'legal', forced_only: false, main_path: false },
|
|
82
|
+
|
|
83
|
+
{ from: 'd', to: 'a', probability: 0.5, kind: 'legal', forced_only: false, main_path: false },
|
|
84
|
+
{ from: 'd', to: 'b', probability: 0.5, kind: 'legal', forced_only: false, main_path: false },
|
|
85
|
+
{ from: 'd', to: 'c', probability: 4, kind: 'legal', forced_only: false, main_path: false },
|
|
86
|
+
{ from: 'd', to: 'e', probability: 0.5, kind: 'legal', forced_only: false, main_path: false },
|
|
87
|
+
|
|
88
|
+
{ from: 'e', to: 'a', probability: 0.5, kind: 'legal', forced_only: false, main_path: false },
|
|
89
|
+
{ from: 'e', to: 'b', probability: 0.5, kind: 'legal', forced_only: false, main_path: false },
|
|
90
|
+
{ from: 'e', to: 'c', probability: 4, kind: 'legal', forced_only: false, main_path: false },
|
|
91
|
+
{ from: 'e', to: 'd', probability: 0.5, kind: 'legal', forced_only: false, main_path: false }
|
|
92
|
+
|
|
93
|
+
]
|
|
94
|
+
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
const res = weighted.probabilistic_histo_walk(2500);
|
|
98
|
+
|
|
99
|
+
// statistically each should be around 375, or 1050 for c. raise alarms if they aren't 250, or 800 for c.
|
|
100
|
+
test('a expects 375 requires 250', () =>
|
|
101
|
+
expect(res.get('a') >= 250)
|
|
102
|
+
.toBe(true) );
|
|
103
|
+
|
|
104
|
+
test('b expects 375 requires 250', () =>
|
|
105
|
+
expect(res.get('b') >= 250)
|
|
106
|
+
.toBe(true) );
|
|
107
|
+
|
|
108
|
+
test('c expects 1050 requires 800', () =>
|
|
109
|
+
expect(res.get('c') >= 800)
|
|
110
|
+
.toBe(true) );
|
|
111
|
+
|
|
112
|
+
test('d expects 375 requires 250', () =>
|
|
113
|
+
expect(res.get('c') >= 250)
|
|
114
|
+
.toBe(true) );
|
|
115
|
+
|
|
116
|
+
test('e expects 375 requires 250', () =>
|
|
117
|
+
expect(res.get('c') >= 250)
|
|
118
|
+
.toBe(true) );
|
|
119
|
+
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
describe('has reasonable weighted distribution in DSL', () => {
|
|
127
|
+
|
|
128
|
+
const weighted = sm`
|
|
129
|
+
a 0.5% -> [b d e];
|
|
130
|
+
b 0.5% -> [a d e];
|
|
131
|
+
c 0.5% -> [a b d e];
|
|
132
|
+
d 0.5% -> [a b e];
|
|
133
|
+
[a b d] <- 0.5% e;
|
|
134
|
+
[a b d e] 4% -> c;
|
|
135
|
+
`;
|
|
136
|
+
|
|
137
|
+
const res = weighted.probabilistic_histo_walk(2500);
|
|
138
|
+
|
|
139
|
+
// statistically each should be around 375, or 1050 for c. raise alarms if they aren't 250, or 800 for c.
|
|
140
|
+
test('a expects 375 requires 250', () =>
|
|
141
|
+
expect(res.get('a') >= 250)
|
|
142
|
+
.toBe(true) );
|
|
143
|
+
|
|
144
|
+
test('b expects 375 requires 250', () =>
|
|
145
|
+
expect(res.get('b') >= 250)
|
|
146
|
+
.toBe(true) );
|
|
147
|
+
|
|
148
|
+
test('c expects 1050 requires 800', () =>
|
|
149
|
+
expect(res.get('c') >= 800)
|
|
150
|
+
.toBe(true) );
|
|
151
|
+
|
|
152
|
+
test('d expects 375 requires 250', () =>
|
|
153
|
+
expect(res.get('c') >= 250)
|
|
154
|
+
.toBe(true) );
|
|
155
|
+
|
|
156
|
+
test('e expects 375 requires 250', () =>
|
|
157
|
+
expect(res.get('c') >= 250)
|
|
158
|
+
.toBe(true) );
|
|
159
|
+
|
|
160
|
+
});
|
|
161
|
+
|
|
162
|
+
// stochastics would help, eg "every returned item is a member" and "in a
|
|
163
|
+
// sufficient list any positive sample size is reasonable" and "always
|
|
164
|
+
// returns the right sample size" - whargarbl todo
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
// stochable
|
package/src/ts/tests/seq.spec.ts
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
import * as jssm from '../jssm';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
describe('seq/1', () => {
|
|
9
|
-
|
|
10
|
-
test('(0) generates []', () => expect( jssm.seq(0) ).toEqual( [] ) );
|
|
11
|
-
test('(1) generates [0]', () => expect( jssm.seq(1) ).toEqual( [0] ) );
|
|
12
|
-
test('(2) generates [0,1]', () => expect( jssm.seq(2) ).toEqual( [0,1] ) );
|
|
13
|
-
|
|
14
|
-
});
|
|
15
|
-
|
|
16
|
-
// stochable
|
|
1
|
+
|
|
2
|
+
import * as jssm from '../jssm';
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
describe('seq/1', () => {
|
|
9
|
+
|
|
10
|
+
test('(0) generates []', () => expect( jssm.seq(0) ).toEqual( [] ) );
|
|
11
|
+
test('(1) generates [0]', () => expect( jssm.seq(1) ).toEqual( [0] ) );
|
|
12
|
+
test('(2) generates [0,1]', () => expect( jssm.seq(2) ).toEqual( [0,1] ) );
|
|
13
|
+
|
|
14
|
+
});
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
|
|
2
|
+
import * as assert from 'assert';
|
|
3
|
+
import * as fc from 'fast-check';
|
|
4
|
+
import * as jssm from '../jssm';
|
|
5
|
+
|
|
6
|
+
const rand_cap = 10_000;
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
describe(`seq/1 over random sizes 0 - ${rand_cap.toLocaleString()}`, () => {
|
|
13
|
+
|
|
14
|
+
test(`Any non-negative size will create safely`, () => {
|
|
15
|
+
|
|
16
|
+
fc.assert(
|
|
17
|
+
fc.property(fc.integer(0, rand_cap), Size =>
|
|
18
|
+
expect( () => jssm.seq(Size) ).not.toThrow()
|
|
19
|
+
)
|
|
20
|
+
);
|
|
21
|
+
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
test(`Length will match the requested size`, () => {
|
|
25
|
+
|
|
26
|
+
fc.assert(
|
|
27
|
+
fc.property(fc.integer(0, rand_cap), Size =>
|
|
28
|
+
expect( jssm.seq(Size).length ).toBe(Size)
|
|
29
|
+
)
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
test(`The type will be object`, () => {
|
|
35
|
+
|
|
36
|
+
fc.assert(
|
|
37
|
+
fc.property(fc.integer(0, rand_cap), Size =>
|
|
38
|
+
expect( typeof jssm.seq(Size) ).toBe('object')
|
|
39
|
+
)
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
test(`Array.isArray will be yes`, () => {
|
|
45
|
+
|
|
46
|
+
fc.assert(
|
|
47
|
+
fc.property(fc.integer(0, rand_cap), Size =>
|
|
48
|
+
expect( Array.isArray(jssm.seq(Size)) ).toBe(true)
|
|
49
|
+
)
|
|
50
|
+
);
|
|
51
|
+
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
|
|
60
|
+
describe('seq/1 over wrong sizes', () => {
|
|
61
|
+
|
|
62
|
+
test(`Non-integer sizes must throw`, () => {
|
|
63
|
+
|
|
64
|
+
fc.assert(
|
|
65
|
+
fc.property(fc.nat(), Size => {
|
|
66
|
+
const useSize = Number.isInteger(Size)? Size + 0.5 : Size;
|
|
67
|
+
expect( () => jssm.seq(useSize) ).toThrow()
|
|
68
|
+
} )
|
|
69
|
+
);
|
|
70
|
+
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
test(`Negative sizes must throw`, () => {
|
|
74
|
+
|
|
75
|
+
fc.assert(
|
|
76
|
+
fc.property(fc.integer(-1 * rand_cap, -1), Size => {
|
|
77
|
+
expect( () => jssm.seq(Size) ).toThrow()
|
|
78
|
+
} )
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
});
|
|
@@ -1,63 +1,63 @@
|
|
|
1
|
-
|
|
2
|
-
import { Shapes } from './constants.spec';
|
|
3
|
-
|
|
4
|
-
import { sm } from '../jssm';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
describe('GraphViz Shapes', () => {
|
|
11
|
-
|
|
12
|
-
Shapes.map(shape => {
|
|
13
|
-
|
|
14
|
-
let mach = undefined;
|
|
15
|
-
|
|
16
|
-
test(`Shape "${shape}" parses as a shape`, () =>
|
|
17
|
-
expect( () => { mach = sm`state c: { shape: ${shape}; }; a -> b;`; }).not.toThrow() );
|
|
18
|
-
|
|
19
|
-
test(`Result shape ${shape} is what it's supposed to be`, () =>
|
|
20
|
-
expect( mach.state_declaration("c").shape ).toBe( shape ) );
|
|
21
|
-
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
test('handles parse end', () =>
|
|
25
|
-
expect( () => {
|
|
26
|
-
const _foo = sm`state c: { shape: thisIsNotAShapeSoItShouldThrow; }; a -> b;`;
|
|
27
|
-
}).toThrow() );
|
|
28
|
-
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
describe('Corners', () => {
|
|
36
|
-
|
|
37
|
-
test('rounded', () =>
|
|
38
|
-
expect(sm`state a: { corners: rounded; }; a->b;`.state_declaration("a").corners).toBe("rounded"));
|
|
39
|
-
|
|
40
|
-
test('lined', () =>
|
|
41
|
-
expect(sm`state a: { corners: lined; }; a->b;`.state_declaration("a").corners).toBe("lined"));
|
|
42
|
-
|
|
43
|
-
test('regular', () =>
|
|
44
|
-
expect(sm`state a: { corners: regular; }; a->b;`.state_declaration("a").corners).toBe("regular"));
|
|
45
|
-
|
|
46
|
-
});
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
describe('Line style', () => {
|
|
53
|
-
|
|
54
|
-
test('solid', () =>
|
|
55
|
-
expect(sm`state a: { linestyle: solid; }; a->b;`.state_declaration("a").linestyle).toBe("solid"));
|
|
56
|
-
|
|
57
|
-
test('dashed', () =>
|
|
58
|
-
expect(sm`state a: { linestyle: dashed; }; a->b;`.state_declaration("a").linestyle).toBe("dashed"));
|
|
59
|
-
|
|
60
|
-
test('dotted', () =>
|
|
61
|
-
expect(sm`state a: { linestyle: dotted; }; a->b;`.state_declaration("a").linestyle).toBe("dotted"));
|
|
62
|
-
|
|
63
|
-
});
|
|
1
|
+
|
|
2
|
+
import { Shapes } from './constants.spec';
|
|
3
|
+
|
|
4
|
+
import { sm } from '../jssm';
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
describe('GraphViz Shapes', () => {
|
|
11
|
+
|
|
12
|
+
Shapes.map(shape => {
|
|
13
|
+
|
|
14
|
+
let mach = undefined;
|
|
15
|
+
|
|
16
|
+
test(`Shape "${shape}" parses as a shape`, () =>
|
|
17
|
+
expect( () => { mach = sm`state c: { shape: ${shape}; }; a -> b;`; }).not.toThrow() );
|
|
18
|
+
|
|
19
|
+
test(`Result shape ${shape} is what it's supposed to be`, () =>
|
|
20
|
+
expect( mach.state_declaration("c").shape ).toBe( shape ) );
|
|
21
|
+
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
test('handles parse end', () =>
|
|
25
|
+
expect( () => {
|
|
26
|
+
const _foo = sm`state c: { shape: thisIsNotAShapeSoItShouldThrow; }; a -> b;`;
|
|
27
|
+
}).toThrow() );
|
|
28
|
+
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
describe('Corners', () => {
|
|
36
|
+
|
|
37
|
+
test('rounded', () =>
|
|
38
|
+
expect(sm`state a: { corners: rounded; }; a->b;`.state_declaration("a").corners).toBe("rounded"));
|
|
39
|
+
|
|
40
|
+
test('lined', () =>
|
|
41
|
+
expect(sm`state a: { corners: lined; }; a->b;`.state_declaration("a").corners).toBe("lined"));
|
|
42
|
+
|
|
43
|
+
test('regular', () =>
|
|
44
|
+
expect(sm`state a: { corners: regular; }; a->b;`.state_declaration("a").corners).toBe("regular"));
|
|
45
|
+
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
describe('Line style', () => {
|
|
53
|
+
|
|
54
|
+
test('solid', () =>
|
|
55
|
+
expect(sm`state a: { linestyle: solid; }; a->b;`.state_declaration("a").linestyle).toBe("solid"));
|
|
56
|
+
|
|
57
|
+
test('dashed', () =>
|
|
58
|
+
expect(sm`state a: { linestyle: dashed; }; a->b;`.state_declaration("a").linestyle).toBe("dashed"));
|
|
59
|
+
|
|
60
|
+
test('dotted', () =>
|
|
61
|
+
expect(sm`state a: { linestyle: dotted; }; a->b;`.state_declaration("a").linestyle).toBe("dotted"));
|
|
62
|
+
|
|
63
|
+
});
|
|
@@ -1,37 +1,37 @@
|
|
|
1
|
-
|
|
2
|
-
/* eslint-disable max-len */
|
|
3
|
-
|
|
4
|
-
import { sm } from '../jssm';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
describe('sm``', () => {
|
|
11
|
-
|
|
12
|
-
describe('simple sm`a->b;`', () => {
|
|
13
|
-
it('doesn\'t throw', () =>
|
|
14
|
-
expect(() => {
|
|
15
|
-
const _foo = sm`a -> b;`;
|
|
16
|
-
}).not.toThrow() );
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
describe('long and chain sm`a->b;c->d;e->f->g;h->i;`', () => {
|
|
20
|
-
it('doesn\'t throw', () =>
|
|
21
|
-
expect(() => {
|
|
22
|
-
const _foo = sm`a->b;c->d;e->f->g;h->i;`;
|
|
23
|
-
}).not.toThrow() );
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
describe('template tags`', () => {
|
|
27
|
-
it('doesn\'t throw', () =>
|
|
28
|
-
expect(() => {
|
|
29
|
-
const bar = 'c->d',
|
|
30
|
-
baz = 'b->h->i;f->h',
|
|
31
|
-
_foo = sm`a->b;${bar};e->f->g;${baz};`;
|
|
32
|
-
}).not.toThrow() );
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
// stochable
|
|
1
|
+
|
|
2
|
+
/* eslint-disable max-len */
|
|
3
|
+
|
|
4
|
+
import { sm } from '../jssm';
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
describe('sm``', () => {
|
|
11
|
+
|
|
12
|
+
describe('simple sm`a->b;`', () => {
|
|
13
|
+
it('doesn\'t throw', () =>
|
|
14
|
+
expect(() => {
|
|
15
|
+
const _foo = sm`a -> b;`;
|
|
16
|
+
}).not.toThrow() );
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
describe('long and chain sm`a->b;c->d;e->f->g;h->i;`', () => {
|
|
20
|
+
it('doesn\'t throw', () =>
|
|
21
|
+
expect(() => {
|
|
22
|
+
const _foo = sm`a->b;c->d;e->f->g;h->i;`;
|
|
23
|
+
}).not.toThrow() );
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
describe('template tags`', () => {
|
|
27
|
+
it('doesn\'t throw', () =>
|
|
28
|
+
expect(() => {
|
|
29
|
+
const bar = 'c->d',
|
|
30
|
+
baz = 'b->h->i;f->h',
|
|
31
|
+
_foo = sm`a->b;${bar};e->f->g;${baz};`;
|
|
32
|
+
}).not.toThrow() );
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
// stochable
|