jssm 5.45.2 → 5.48.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/dist/es6/jssm.d.ts +3 -1
- package/dist/es6/jssm.js +10 -0
- package/dist/es6/jssm_types.d.ts +6 -5
- package/dist/es6/version.js +1 -1
- package/dist/jssm.es5.cjs.js +1 -1
- package/jssm.d.ts +3 -1
- package/jssm_types.d.ts +6 -5
- package/package.json +1 -1
- package/.codeclimate.yml +0 -22
- package/.editorconfig +0 -12
- package/.eslintrc +0 -20
- package/.nycrc +0 -6
- package/.travis.yml +0 -9
- package/dist/jssm.es5.iife.js +0 -1
- package/jest-spec.config.js +0 -27
- package/jest-stoch.config.js +0 -27
- package/rollup.config.iife.js +0 -44
- package/rollup.config.js +0 -44
- package/src/demo/index.html +0 -38
- package/src/demo/style.css +0 -2
- package/src/ts/jssm-dot.peg +0 -928
- package/src/ts/jssm.ts +0 -1243
- package/src/ts/jssm_types.ts +0 -385
- package/src/ts/jssm_util.ts +0 -117
- package/src/ts/tests/actions.spec.ts +0 -167
- package/src/ts/tests/arrange.spec.ts +0 -72
- package/src/ts/tests/arrange.stoch.ts +0 -4
- package/src/ts/tests/array_box_if_string.spec.ts +0 -30
- package/src/ts/tests/array_transitions.spec.ts +0 -129
- package/src/ts/tests/arrow unicode.spec.ts +0 -88
- package/src/ts/tests/arrow.spec.ts +0 -124
- package/src/ts/tests/colors.spec.ts +0 -58
- package/src/ts/tests/comment.spec.ts +0 -134
- package/src/ts/tests/compile.spec.ts +0 -79
- package/src/ts/tests/constants.spec.ts +0 -98
- package/src/ts/tests/cycles.spec.ts +0 -153
- package/src/ts/tests/dot_preamble.spec.ts +0 -16
- package/src/ts/tests/embedded_sm.spec.ts +0 -36
- package/src/ts/tests/flow.spec.ts +0 -22
- package/src/ts/tests/forced transitions.spec.ts +0 -26
- package/src/ts/tests/general.spec.ts +0 -933
- package/src/ts/tests/graph node lists.spec.ts +0 -21
- package/src/ts/tests/histo.spec.ts +0 -24
- package/src/ts/tests/hooks.spec.ts +0 -209
- package/src/ts/tests/language.spec.ts +0 -37
- package/src/ts/tests/language_data/belarussian.json +0 -14
- package/src/ts/tests/language_data/bengali.json +0 -16
- package/src/ts/tests/language_data/emoji.json +0 -22
- package/src/ts/tests/language_data/english.json +0 -17
- package/src/ts/tests/language_data/french.json +0 -17
- package/src/ts/tests/language_data/german.json +0 -17
- package/src/ts/tests/language_data/hebrew.json +0 -16
- package/src/ts/tests/language_data/portuguese.json +0 -13
- package/src/ts/tests/language_data/russian.json +0 -13
- package/src/ts/tests/language_data/spanish.json +0 -17
- package/src/ts/tests/language_data/ukrainian.json +0 -19
- package/src/ts/tests/layout.spec.ts +0 -29
- package/src/ts/tests/machine_attributes.spec.ts +0 -398
- package/src/ts/tests/machine_name.spec.ts +0 -14
- package/src/ts/tests/named lists.spec.ts +0 -24
- package/src/ts/tests/nominated states.spec.ts +0 -133
- package/src/ts/tests/parse actions.spec.ts +0 -32
- package/src/ts/tests/parse.spec.ts +0 -94
- package/src/ts/tests/probability.spec.ts +0 -146
- package/src/ts/tests/r639.spec.ts +0 -27
- package/src/ts/tests/sample_select.spec.ts +0 -173
- package/src/ts/tests/seq.spec.ts +0 -14
- package/src/ts/tests/seq.stoch.ts +0 -83
- package/src/ts/tests/shapes.spec.ts +0 -63
- package/src/ts/tests/sm_tag.spec.ts +0 -37
- package/src/ts/tests/special characters.spec.ts +0 -39
- package/src/ts/tests/state_declaration.spec.ts +0 -214
- package/src/ts/tests/state_style.spec.ts +0 -82
- package/src/ts/tests/stop light.spec.ts +0 -157
- package/src/ts/tests/stripes.spec.ts +0 -52
- package/src/ts/tests/theme.spec.ts +0 -45
- package/src/ts/tests/weighted_histo_key.spec.ts +0 -22
- package/src/ts/tests/weighted_rand_select.spec.ts +0 -27
- package/src/ts/tests/weighted_sample_select.spec.ts +0 -24
- package/src/ts/version.ts +0 -3
- package/tree.txt +0 -1794
- package/tsconfig.json +0 -27
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
/* eslint-disable max-len */
|
|
3
|
-
|
|
4
|
-
import * as jssm from '../jssm';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
describe('probable exits for', () => {
|
|
11
|
-
|
|
12
|
-
const machine = new jssm.Machine({
|
|
13
|
-
start_states : ['off'],
|
|
14
|
-
transitions : [ { from: 'off', to: 'red', kind: 'legal', forced_only: false, main_path: false } ]
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
test('probable exits are an array', () =>
|
|
18
|
-
expect(Array.isArray(machine.probable_exits_for('off')) )
|
|
19
|
-
.toBe(true) );
|
|
20
|
-
|
|
21
|
-
test('one probable exit in example', () =>
|
|
22
|
-
expect(machine.probable_exits_for('off').length)
|
|
23
|
-
.toBe(1) );
|
|
24
|
-
|
|
25
|
-
test('exit is an object', () =>
|
|
26
|
-
expect(typeof machine.probable_exits_for('off')[0])
|
|
27
|
-
.toBe('object') );
|
|
28
|
-
|
|
29
|
-
test('exit 0 has a string from property', () =>
|
|
30
|
-
expect(typeof machine.probable_exits_for('off')[0].from )
|
|
31
|
-
.toBe('string') );
|
|
32
|
-
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
describe('probable action exits', () => {
|
|
40
|
-
|
|
41
|
-
const machine = new jssm.Machine({
|
|
42
|
-
start_states : ['off'],
|
|
43
|
-
transitions : [
|
|
44
|
-
{ from:'off', to:'red', action:'on', kind: 'legal', forced_only: false, main_path: false },
|
|
45
|
-
{ from:'red', to:'off', action:'off', kind: 'legal', forced_only: false, main_path: false }
|
|
46
|
-
]
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
test('probable action exits are an array', () =>
|
|
50
|
-
expect(Array.isArray(machine.probable_action_exits()) )
|
|
51
|
-
.toBe(true) );
|
|
52
|
-
|
|
53
|
-
test('probable action exit 1 is on', () =>
|
|
54
|
-
expect(machine.probable_action_exits()[0].action)
|
|
55
|
-
.toBe('on') );
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
test('probable action exits are an array 2', () =>
|
|
59
|
-
expect(Array.isArray(machine.probable_action_exits('off')) )
|
|
60
|
-
.toBe(true) );
|
|
61
|
-
|
|
62
|
-
test('probable action exit 1 is on 2', () =>
|
|
63
|
-
expect(machine.probable_action_exits('off')[0].action)
|
|
64
|
-
.toBe('on') );
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
test('probable action exits are an array 3', () =>
|
|
68
|
-
expect(Array.isArray(machine.probable_action_exits('red')) )
|
|
69
|
-
.toBe(true) );
|
|
70
|
-
|
|
71
|
-
test('probable action exit 1 is on 3', () =>
|
|
72
|
-
expect(machine.probable_action_exits('red')[0].action)
|
|
73
|
-
.toBe('off') );
|
|
74
|
-
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
describe('probabilistic_transition', () => {
|
|
82
|
-
|
|
83
|
-
const machine = new jssm.Machine({
|
|
84
|
-
start_states : ['off'],
|
|
85
|
-
transitions : [ { from: 'off', to: 'red', kind: 'legal', forced_only: false, main_path: false } ]
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
machine.probabilistic_transition();
|
|
89
|
-
|
|
90
|
-
test('solo after probabilistic is red', () =>
|
|
91
|
-
expect( machine.state() )
|
|
92
|
-
.toBe('red') );
|
|
93
|
-
|
|
94
|
-
});
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
describe('probabilistic_walk', () => {
|
|
101
|
-
|
|
102
|
-
const machine = new jssm.Machine({
|
|
103
|
-
start_states : ['off'],
|
|
104
|
-
transitions : [
|
|
105
|
-
{ from: 'off', to: 'red', kind: 'legal', forced_only: false, main_path: false },
|
|
106
|
-
{ from: 'red', to: 'off', kind: 'legal', forced_only: false, main_path: false }
|
|
107
|
-
]
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
machine.probabilistic_walk(3);
|
|
111
|
-
|
|
112
|
-
test('solo after probabilistic walk 3 is red', () =>
|
|
113
|
-
expect( machine.state() )
|
|
114
|
-
.toBe('red') );
|
|
115
|
-
|
|
116
|
-
});
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
describe('probabilistic_histo_walk', () => {
|
|
123
|
-
|
|
124
|
-
const machine = new jssm.Machine({
|
|
125
|
-
start_states : ['off'],
|
|
126
|
-
transitions : [
|
|
127
|
-
{ from: 'off', to: 'red', kind: 'legal', forced_only: false, main_path: false },
|
|
128
|
-
{ from: 'red', to: 'off', kind: 'legal', forced_only: false, main_path: false }
|
|
129
|
-
]
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
const histo = machine.probabilistic_histo_walk(3);
|
|
133
|
-
|
|
134
|
-
test('histo is a Map', () =>
|
|
135
|
-
expect(histo instanceof Map)
|
|
136
|
-
.toBe(true) );
|
|
137
|
-
|
|
138
|
-
test('histo red is 2', () =>
|
|
139
|
-
expect(histo.get('red'))
|
|
140
|
-
.toBe(2) );
|
|
141
|
-
|
|
142
|
-
test('histo off is 2', () =>
|
|
143
|
-
expect(histo.get('off'))
|
|
144
|
-
.toBe(2) );
|
|
145
|
-
|
|
146
|
-
});
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
const r639 = require('reduce-to-639-1').reduce;
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
test('should be en', () =>
|
|
9
|
-
expect(r639('EnglISh')).toBe('en') );
|
|
10
|
-
|
|
11
|
-
test('should be am', () =>
|
|
12
|
-
expect(r639('አማርኛ')).toBe('am') );
|
|
13
|
-
|
|
14
|
-
test('should be undef when wrong str', () =>
|
|
15
|
-
expect( r639('xyzzy') ).toBe(undefined) );
|
|
16
|
-
|
|
17
|
-
test('should be undef when empty str', () =>
|
|
18
|
-
expect( r639('') ).toBe(undefined) );
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
test.todo('commented out r639 things');
|
|
25
|
-
|
|
26
|
-
// describe(`r639 _`, async it => it('should be undef when unnamed', t => t.throws( async() => r639() )));
|
|
27
|
-
// describe(`r639 _`, async it => it('should be undef when false', t => t.throws( async() => r639(false) )));
|
|
@@ -1,173 +0,0 @@
|
|
|
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
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
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
|
-
});
|
|
@@ -1,83 +0,0 @@
|
|
|
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 +0,0 @@
|
|
|
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 +0,0 @@
|
|
|
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,39 +0,0 @@
|
|
|
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!');
|