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,398 +1,398 @@
|
|
|
1
|
-
|
|
2
|
-
import { sm } from '../jssm';
|
|
3
|
-
|
|
4
|
-
const r639 = require('reduce-to-639-1').reduce;
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
test.todo('Most of this machine_attributes stuff should be rewritten as table-driven and/or stoch');
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
describe('machine_name', () => {
|
|
17
|
-
|
|
18
|
-
test('atom', () =>
|
|
19
|
-
expect(() => { const _foo = sm`machine_name: bob; a->b;`; })
|
|
20
|
-
.not.toThrow() );
|
|
21
|
-
|
|
22
|
-
test('quoted string', () =>
|
|
23
|
-
expect(() => { const _foo = sm`machine_name: "bo b"; a->b;`; })
|
|
24
|
-
.not.toThrow() );
|
|
25
|
-
|
|
26
|
-
test('retval correct', () =>
|
|
27
|
-
expect(sm`machine_name: testval; a->b;`.machine_name() )
|
|
28
|
-
.toBe('testval') );
|
|
29
|
-
|
|
30
|
-
});
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
describe('machine_language', () => {
|
|
37
|
-
|
|
38
|
-
const eachTest = (name, lang) => {
|
|
39
|
-
|
|
40
|
-
test(`${name} machine_language with transclusion is correct for sm\`machine_language: ${lang}; a->b;\``, () =>
|
|
41
|
-
expect( ((sm`machine_language: ${lang}; a->b;`).machine_language()) )
|
|
42
|
-
.toBe( r639(lang) ) );
|
|
43
|
-
|
|
44
|
-
test.todo('machine_attributes spec more available');
|
|
45
|
-
|
|
46
|
-
// test(`${name} machine_language with transclusion is correct for sm\`machine_language: "${lang}"; a->b;\``, () =>
|
|
47
|
-
// t.is(r639(lang), ((sm`machine_language: "${lang}"; a->b;`).machine_language()) ) );
|
|
48
|
-
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
test(`Eng hand-written is correct without quotes`, () =>
|
|
52
|
-
expect(((sm`machine_language: EnGlIsH; a->b;`).machine_language() ))
|
|
53
|
-
.toBe('en') );
|
|
54
|
-
|
|
55
|
-
test(`Eng hand-written is correct with quotes`, () =>
|
|
56
|
-
expect(((sm`machine_language: "EnGlIsH"; a->b;`).machine_language() ))
|
|
57
|
-
.toBe('en') );
|
|
58
|
-
|
|
59
|
-
test(`Amharic hand-written is correct without quotes`, () =>
|
|
60
|
-
expect(((sm`machine_language: አማርኛ; a->b;`).machine_language() ))
|
|
61
|
-
.toBe('am') );
|
|
62
|
-
|
|
63
|
-
test.todo('machine_attributes spec more available 2');
|
|
64
|
-
|
|
65
|
-
// test(`Amharic hand-written is correct with quotes`, () =>
|
|
66
|
-
// t.is('am', ((sm`machine_language: "አማርኛ"; a->b;`).machine_language()) ) );
|
|
67
|
-
|
|
68
|
-
eachTest('atom correct case', 'English');
|
|
69
|
-
eachTest('atom lowercase', 'english');
|
|
70
|
-
eachTest('atom mixedcase', 'eNGliSH');
|
|
71
|
-
eachTest('amharic', 'አማርኛ');
|
|
72
|
-
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
describe('machine_author', () => {
|
|
80
|
-
|
|
81
|
-
test('single atom', () =>
|
|
82
|
-
expect( () => { const _foo = sm`machine_author: bob; a->b;`; })
|
|
83
|
-
.not.toThrow() );
|
|
84
|
-
|
|
85
|
-
test('single quoted string', () =>
|
|
86
|
-
expect( () => { const _foo = sm`machine_author: "bo b"; a->b;`; })
|
|
87
|
-
.not.toThrow() );
|
|
88
|
-
|
|
89
|
-
test('atom list', () =>
|
|
90
|
-
expect( () => { const _foo = sm`machine_author: [bob dobbs]; a->b;`; })
|
|
91
|
-
.not.toThrow() );
|
|
92
|
-
|
|
93
|
-
test('quoted string list', () =>
|
|
94
|
-
expect( () => { const _foo = sm`machine_author: ["bo b" "do bbs"]; a->b;`; })
|
|
95
|
-
.not.toThrow() );
|
|
96
|
-
|
|
97
|
-
test('mixed list a/q', () =>
|
|
98
|
-
expect( () => { const _foo = sm`machine_author: [bob "do bbs"]; a->b;`; })
|
|
99
|
-
.not.toThrow() );
|
|
100
|
-
|
|
101
|
-
test('mixed list q/a', () =>
|
|
102
|
-
expect( () => { const _foo = sm`machine_author: ["bo b" dobbs]; a->b;`; })
|
|
103
|
-
.not.toThrow() );
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
test('single retval', () =>
|
|
107
|
-
expect(sm`machine_author: testval; a->b;`.machine_author() )
|
|
108
|
-
.toEqual(['testval']) );
|
|
109
|
-
|
|
110
|
-
test('multiple retval', () =>
|
|
111
|
-
expect(sm`machine_author: [bob david]; a->b;`.machine_author() )
|
|
112
|
-
.toEqual(['bob','david']) );
|
|
113
|
-
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
describe('machine_contributor', () => {
|
|
121
|
-
|
|
122
|
-
test('atom', () =>
|
|
123
|
-
expect( () => { const _ = sm`machine_contributor: bob; a->b;`; })
|
|
124
|
-
.not.toThrow() );
|
|
125
|
-
|
|
126
|
-
test('quoted string', () =>
|
|
127
|
-
expect( () => { const _ = sm`machine_contributor: "bo b"; a->b;`; })
|
|
128
|
-
.not.toThrow() );
|
|
129
|
-
|
|
130
|
-
test('atom list', () =>
|
|
131
|
-
expect( () => { const _ = sm`machine_contributor: [bob dobbs]; a->b;`; })
|
|
132
|
-
.not.toThrow() );
|
|
133
|
-
|
|
134
|
-
test('quoted string list', () =>
|
|
135
|
-
expect( () => { const _ = sm`machine_contributor: ["bo b" "do bbs"]; a->b;`; })
|
|
136
|
-
.not.toThrow() );
|
|
137
|
-
|
|
138
|
-
test('mixed list a/q', () =>
|
|
139
|
-
expect( () => { const _ = sm`machine_contributor: [bob "do bbs"]; a->b;`; })
|
|
140
|
-
.not.toThrow() );
|
|
141
|
-
|
|
142
|
-
test('mixed list q/a', () =>
|
|
143
|
-
expect( () => { const _ = sm`machine_contributor: ["bo b" dobbs]; a->b;`; })
|
|
144
|
-
.not.toThrow() );
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
test('single retval', () =>
|
|
148
|
-
expect(sm`machine_contributor: testval; a->b;`.machine_contributor() )
|
|
149
|
-
.toEqual(["testval"]) );
|
|
150
|
-
|
|
151
|
-
test('multiple retval', () =>
|
|
152
|
-
expect(sm`machine_contributor: [bob david]; a->b;`.machine_contributor() )
|
|
153
|
-
.toEqual(['bob','david']) );
|
|
154
|
-
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
describe('machine_comment', () => {
|
|
162
|
-
|
|
163
|
-
test('atom', () =>
|
|
164
|
-
expect( () => { const _foo = sm`machine_comment: bob; a->b;`; })
|
|
165
|
-
.not.toThrow() );
|
|
166
|
-
|
|
167
|
-
test('quoted string', () =>
|
|
168
|
-
expect( () => { const _foo = sm`machine_comment: "bo b"; a->b;`; })
|
|
169
|
-
.not.toThrow() );
|
|
170
|
-
|
|
171
|
-
test('retval correct', () =>
|
|
172
|
-
expect(sm`machine_comment: testval; a->b;`.machine_comment() )
|
|
173
|
-
.toBe("testval") );
|
|
174
|
-
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
describe('machine_definition', () => {
|
|
182
|
-
|
|
183
|
-
test('url', () =>
|
|
184
|
-
expect( () => { const _foo = sm`machine_definition: http://google.com/ ; a->b;`; })
|
|
185
|
-
.not.toThrow() );
|
|
186
|
-
|
|
187
|
-
test('url botched', () =>
|
|
188
|
-
expect( () => { const _foo = sm`machine_definition: "not a url"; a->b;`; })
|
|
189
|
-
.toThrow() );
|
|
190
|
-
|
|
191
|
-
test('retval correct', () =>
|
|
192
|
-
expect(sm`machine_definition: http://google.com/ ; a->b;`.machine_definition() )
|
|
193
|
-
.toBe("http://google.com/") );
|
|
194
|
-
|
|
195
|
-
});
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
describe('machine_version', () => {
|
|
202
|
-
|
|
203
|
-
test('semver 0.0.0', () =>
|
|
204
|
-
expect( () => { const _f = sm`machine_version: 0.0.0; a->b;`; })
|
|
205
|
-
.not.toThrow() );
|
|
206
|
-
|
|
207
|
-
test('semver 0.0.1', () =>
|
|
208
|
-
expect( () => { const _f = sm`machine_version: 0.0.1; a->b;`; })
|
|
209
|
-
.not.toThrow() );
|
|
210
|
-
|
|
211
|
-
test('semver 0.1.0', () =>
|
|
212
|
-
expect( () => { const _f = sm`machine_version: 0.1.0; a->b;`; })
|
|
213
|
-
.not.toThrow() );
|
|
214
|
-
|
|
215
|
-
test('semver 1.0.0', () =>
|
|
216
|
-
expect( () => { const _f = sm`machine_version: 1.0.0; a->b;`; })
|
|
217
|
-
.not.toThrow() );
|
|
218
|
-
|
|
219
|
-
test('semver 1.0.1', () =>
|
|
220
|
-
expect( () => { const _f = sm`machine_version: 1.0.1; a->b;`; })
|
|
221
|
-
.not.toThrow() );
|
|
222
|
-
|
|
223
|
-
test('semver 1.1.1', () =>
|
|
224
|
-
expect( () => { const _f = sm`machine_version: 1.1.1; a->b;`; })
|
|
225
|
-
.not.toThrow() );
|
|
226
|
-
|
|
227
|
-
test('semver 2.0.0', () =>
|
|
228
|
-
expect( () => { const _f = sm`machine_version: 2.0.0; a->b;`; })
|
|
229
|
-
.not.toThrow() );
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
test('semver notAS', () =>
|
|
233
|
-
expect(() => { const _f = sm`machine_version: "Not a semver"; a->b;`; })
|
|
234
|
-
.toThrow() );
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
test('retval correct', () =>
|
|
238
|
-
expect(sm`machine_version: 0.0.0; a->b;`.machine_version())
|
|
239
|
-
.toEqual({full:"0.0.0", major:0, minor:0, patch:0}) );
|
|
240
|
-
|
|
241
|
-
});
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
describe('machine_license', () => {
|
|
248
|
-
|
|
249
|
-
test('retval correct', () =>
|
|
250
|
-
expect( sm`machine_license: testval; a->b;`.machine_license() )
|
|
251
|
-
.toBe("testval") );
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
describe('near', () => {
|
|
255
|
-
|
|
256
|
-
test('Public domain', () =>
|
|
257
|
-
expect( () => { const _ = sm`machine_license:Public domain; a->b;`; })
|
|
258
|
-
.not.toThrow() );
|
|
259
|
-
|
|
260
|
-
test('MIT', () =>
|
|
261
|
-
expect( () => { const _ = sm`machine_license:MIT; a->b;`; })
|
|
262
|
-
.not.toThrow() );
|
|
263
|
-
|
|
264
|
-
test('BSD 2-clause', () =>
|
|
265
|
-
expect( () => { const _ = sm`machine_license:BSD 2-clause; a->b;`; })
|
|
266
|
-
.not.toThrow() );
|
|
267
|
-
|
|
268
|
-
test('BSD 3-clause', () =>
|
|
269
|
-
expect( () => { const _ = sm`machine_license:BSD 3-clause; a->b;`; })
|
|
270
|
-
.not.toThrow() );
|
|
271
|
-
|
|
272
|
-
test('Apache 2.0', () =>
|
|
273
|
-
expect( () => { const _ = sm`machine_license:Apache 2.0; a->b;`; })
|
|
274
|
-
.not.toThrow() );
|
|
275
|
-
|
|
276
|
-
test('Mozilla 2.0', () =>
|
|
277
|
-
expect( () => { const _ = sm`machine_license:Mozilla 2.0; a->b;`; })
|
|
278
|
-
.not.toThrow() );
|
|
279
|
-
|
|
280
|
-
test('GPL v2', () =>
|
|
281
|
-
expect( () => { const _ = sm`machine_license:GPL v2; a->b;`; })
|
|
282
|
-
.not.toThrow() );
|
|
283
|
-
|
|
284
|
-
test('GPL v3', () =>
|
|
285
|
-
expect( () => { const _ = sm`machine_license:GPL v3; a->b;`; })
|
|
286
|
-
.not.toThrow() );
|
|
287
|
-
|
|
288
|
-
test('LGPL v2.1', () =>
|
|
289
|
-
expect( () => { const _ = sm`machine_license:LGPL v2.1; a->b;`; })
|
|
290
|
-
.not.toThrow() );
|
|
291
|
-
|
|
292
|
-
test('LGPL v3.0', () =>
|
|
293
|
-
expect( () => { const _ = sm`machine_license:LGPL v3.0; a->b;`; })
|
|
294
|
-
.not.toThrow() );
|
|
295
|
-
|
|
296
|
-
});
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
describe('spaced', () => {
|
|
300
|
-
|
|
301
|
-
test('Public domain', () =>
|
|
302
|
-
expect( () => { const _ = sm`machine_license: Public domain ; a->b;`; })
|
|
303
|
-
.not.toThrow() );
|
|
304
|
-
|
|
305
|
-
test('MIT', () =>
|
|
306
|
-
expect( () => { const _ = sm`machine_license: MIT ; a->b;`; })
|
|
307
|
-
.not.toThrow() );
|
|
308
|
-
|
|
309
|
-
test('BSD 2-clause', () =>
|
|
310
|
-
expect( () => { const _ = sm`machine_license: BSD 2-clause ; a->b;`; })
|
|
311
|
-
.not.toThrow() );
|
|
312
|
-
|
|
313
|
-
test('BSD 3-clause', () =>
|
|
314
|
-
expect( () => { const _ = sm`machine_license: BSD 3-clause ; a->b;`; })
|
|
315
|
-
.not.toThrow() );
|
|
316
|
-
|
|
317
|
-
test('Apache 2.0', () =>
|
|
318
|
-
expect( () => { const _ = sm`machine_license: Apache 2.0 ; a->b;`; })
|
|
319
|
-
.not.toThrow() );
|
|
320
|
-
|
|
321
|
-
test('Mozilla 2.0', () =>
|
|
322
|
-
expect( () => { const _ = sm`machine_license: Mozilla 2.0 ; a->b;`; })
|
|
323
|
-
.not.toThrow() );
|
|
324
|
-
|
|
325
|
-
test('GPL v2', () =>
|
|
326
|
-
expect( () => { const _ = sm`machine_license: GPL v2 ; a->b;`; })
|
|
327
|
-
.not.toThrow() );
|
|
328
|
-
|
|
329
|
-
test('GPL v3', () =>
|
|
330
|
-
expect( () => { const _ = sm`machine_license: GPL v3 ; a->b;`; })
|
|
331
|
-
.not.toThrow() );
|
|
332
|
-
|
|
333
|
-
test('LGPL v2.1', () =>
|
|
334
|
-
expect( () => { const _ = sm`machine_license: LGPL v2.1 ; a->b;`; })
|
|
335
|
-
.not.toThrow() );
|
|
336
|
-
|
|
337
|
-
test('LGPL v3.0', () =>
|
|
338
|
-
expect( () => { const _ = sm`machine_license: LGPL v3.0 ; a->b;`; })
|
|
339
|
-
.not.toThrow() );
|
|
340
|
-
|
|
341
|
-
});
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
test('single atom', () =>
|
|
345
|
-
expect( () => { const _ = sm`machine_license: bob; a->b;`; })
|
|
346
|
-
.not.toThrow() );
|
|
347
|
-
|
|
348
|
-
test('single quoted string', () =>
|
|
349
|
-
expect( () => { const _ = sm`machine_license: "bo b"; a->b;`; })
|
|
350
|
-
.not.toThrow() );
|
|
351
|
-
|
|
352
|
-
});
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
describe('fsl_version', () => {
|
|
359
|
-
|
|
360
|
-
test('semver 0.0.0', () =>
|
|
361
|
-
expect( () => { const _f = sm`fsl_version: 0.0.0; a->b;`; })
|
|
362
|
-
.not.toThrow() );
|
|
363
|
-
|
|
364
|
-
test('semver 0.0.1', () =>
|
|
365
|
-
expect( () => { const _f = sm`fsl_version: 0.0.1; a->b;`; })
|
|
366
|
-
.not.toThrow() );
|
|
367
|
-
|
|
368
|
-
test('semver 0.1.0', () =>
|
|
369
|
-
expect( () => { const _f = sm`fsl_version: 0.1.0; a->b;`; })
|
|
370
|
-
.not.toThrow() );
|
|
371
|
-
|
|
372
|
-
test('semver 1.0.0', () =>
|
|
373
|
-
expect( () => { const _f = sm`fsl_version: 1.0.0; a->b;`; })
|
|
374
|
-
.not.toThrow() );
|
|
375
|
-
|
|
376
|
-
test('semver 1.0.1', () =>
|
|
377
|
-
expect( () => { const _f = sm`fsl_version: 1.0.1; a->b;`; })
|
|
378
|
-
.not.toThrow() );
|
|
379
|
-
|
|
380
|
-
test('semver 1.1.1', () =>
|
|
381
|
-
expect( () => { const _f = sm`fsl_version: 1.1.1; a->b;`; })
|
|
382
|
-
.not.toThrow() );
|
|
383
|
-
|
|
384
|
-
test('semver 2.0.0', () =>
|
|
385
|
-
expect( () => { const _f = sm`fsl_version: 2.0.0; a->b;`; })
|
|
386
|
-
.not.toThrow() );
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
test('semver notAS', () =>
|
|
390
|
-
expect(() => { const _f = sm`fsl_version: "Not a semver"; a->b;`; })
|
|
391
|
-
.toThrow() );
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
test('retval correct', () =>
|
|
395
|
-
expect(sm`fsl_version: 0.0.0; a->b;`.fsl_version())
|
|
396
|
-
.toEqual({full:"0.0.0", major:0, minor:0, patch:0}) );
|
|
397
|
-
|
|
398
|
-
});
|
|
1
|
+
|
|
2
|
+
import { sm } from '../jssm';
|
|
3
|
+
|
|
4
|
+
const r639 = require('reduce-to-639-1').reduce;
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
test.todo('Most of this machine_attributes stuff should be rewritten as table-driven and/or stoch');
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
describe('machine_name', () => {
|
|
17
|
+
|
|
18
|
+
test('atom', () =>
|
|
19
|
+
expect(() => { const _foo = sm`machine_name: bob; a->b;`; })
|
|
20
|
+
.not.toThrow() );
|
|
21
|
+
|
|
22
|
+
test('quoted string', () =>
|
|
23
|
+
expect(() => { const _foo = sm`machine_name: "bo b"; a->b;`; })
|
|
24
|
+
.not.toThrow() );
|
|
25
|
+
|
|
26
|
+
test('retval correct', () =>
|
|
27
|
+
expect(sm`machine_name: testval; a->b;`.machine_name() )
|
|
28
|
+
.toBe('testval') );
|
|
29
|
+
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
describe('machine_language', () => {
|
|
37
|
+
|
|
38
|
+
const eachTest = (name, lang) => {
|
|
39
|
+
|
|
40
|
+
test(`${name} machine_language with transclusion is correct for sm\`machine_language: ${lang}; a->b;\``, () =>
|
|
41
|
+
expect( ((sm`machine_language: ${lang}; a->b;`).machine_language()) )
|
|
42
|
+
.toBe( r639(lang) ) );
|
|
43
|
+
|
|
44
|
+
test.todo('machine_attributes spec more available');
|
|
45
|
+
|
|
46
|
+
// test(`${name} machine_language with transclusion is correct for sm\`machine_language: "${lang}"; a->b;\``, () =>
|
|
47
|
+
// t.is(r639(lang), ((sm`machine_language: "${lang}"; a->b;`).machine_language()) ) );
|
|
48
|
+
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
test(`Eng hand-written is correct without quotes`, () =>
|
|
52
|
+
expect(((sm`machine_language: EnGlIsH; a->b;`).machine_language() ))
|
|
53
|
+
.toBe('en') );
|
|
54
|
+
|
|
55
|
+
test(`Eng hand-written is correct with quotes`, () =>
|
|
56
|
+
expect(((sm`machine_language: "EnGlIsH"; a->b;`).machine_language() ))
|
|
57
|
+
.toBe('en') );
|
|
58
|
+
|
|
59
|
+
test(`Amharic hand-written is correct without quotes`, () =>
|
|
60
|
+
expect(((sm`machine_language: አማርኛ; a->b;`).machine_language() ))
|
|
61
|
+
.toBe('am') );
|
|
62
|
+
|
|
63
|
+
test.todo('machine_attributes spec more available 2');
|
|
64
|
+
|
|
65
|
+
// test(`Amharic hand-written is correct with quotes`, () =>
|
|
66
|
+
// t.is('am', ((sm`machine_language: "አማርኛ"; a->b;`).machine_language()) ) );
|
|
67
|
+
|
|
68
|
+
eachTest('atom correct case', 'English');
|
|
69
|
+
eachTest('atom lowercase', 'english');
|
|
70
|
+
eachTest('atom mixedcase', 'eNGliSH');
|
|
71
|
+
eachTest('amharic', 'አማርኛ');
|
|
72
|
+
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
describe('machine_author', () => {
|
|
80
|
+
|
|
81
|
+
test('single atom', () =>
|
|
82
|
+
expect( () => { const _foo = sm`machine_author: bob; a->b;`; })
|
|
83
|
+
.not.toThrow() );
|
|
84
|
+
|
|
85
|
+
test('single quoted string', () =>
|
|
86
|
+
expect( () => { const _foo = sm`machine_author: "bo b"; a->b;`; })
|
|
87
|
+
.not.toThrow() );
|
|
88
|
+
|
|
89
|
+
test('atom list', () =>
|
|
90
|
+
expect( () => { const _foo = sm`machine_author: [bob dobbs]; a->b;`; })
|
|
91
|
+
.not.toThrow() );
|
|
92
|
+
|
|
93
|
+
test('quoted string list', () =>
|
|
94
|
+
expect( () => { const _foo = sm`machine_author: ["bo b" "do bbs"]; a->b;`; })
|
|
95
|
+
.not.toThrow() );
|
|
96
|
+
|
|
97
|
+
test('mixed list a/q', () =>
|
|
98
|
+
expect( () => { const _foo = sm`machine_author: [bob "do bbs"]; a->b;`; })
|
|
99
|
+
.not.toThrow() );
|
|
100
|
+
|
|
101
|
+
test('mixed list q/a', () =>
|
|
102
|
+
expect( () => { const _foo = sm`machine_author: ["bo b" dobbs]; a->b;`; })
|
|
103
|
+
.not.toThrow() );
|
|
104
|
+
|
|
105
|
+
|
|
106
|
+
test('single retval', () =>
|
|
107
|
+
expect(sm`machine_author: testval; a->b;`.machine_author() )
|
|
108
|
+
.toEqual(['testval']) );
|
|
109
|
+
|
|
110
|
+
test('multiple retval', () =>
|
|
111
|
+
expect(sm`machine_author: [bob david]; a->b;`.machine_author() )
|
|
112
|
+
.toEqual(['bob','david']) );
|
|
113
|
+
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
describe('machine_contributor', () => {
|
|
121
|
+
|
|
122
|
+
test('atom', () =>
|
|
123
|
+
expect( () => { const _ = sm`machine_contributor: bob; a->b;`; })
|
|
124
|
+
.not.toThrow() );
|
|
125
|
+
|
|
126
|
+
test('quoted string', () =>
|
|
127
|
+
expect( () => { const _ = sm`machine_contributor: "bo b"; a->b;`; })
|
|
128
|
+
.not.toThrow() );
|
|
129
|
+
|
|
130
|
+
test('atom list', () =>
|
|
131
|
+
expect( () => { const _ = sm`machine_contributor: [bob dobbs]; a->b;`; })
|
|
132
|
+
.not.toThrow() );
|
|
133
|
+
|
|
134
|
+
test('quoted string list', () =>
|
|
135
|
+
expect( () => { const _ = sm`machine_contributor: ["bo b" "do bbs"]; a->b;`; })
|
|
136
|
+
.not.toThrow() );
|
|
137
|
+
|
|
138
|
+
test('mixed list a/q', () =>
|
|
139
|
+
expect( () => { const _ = sm`machine_contributor: [bob "do bbs"]; a->b;`; })
|
|
140
|
+
.not.toThrow() );
|
|
141
|
+
|
|
142
|
+
test('mixed list q/a', () =>
|
|
143
|
+
expect( () => { const _ = sm`machine_contributor: ["bo b" dobbs]; a->b;`; })
|
|
144
|
+
.not.toThrow() );
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
test('single retval', () =>
|
|
148
|
+
expect(sm`machine_contributor: testval; a->b;`.machine_contributor() )
|
|
149
|
+
.toEqual(["testval"]) );
|
|
150
|
+
|
|
151
|
+
test('multiple retval', () =>
|
|
152
|
+
expect(sm`machine_contributor: [bob david]; a->b;`.machine_contributor() )
|
|
153
|
+
.toEqual(['bob','david']) );
|
|
154
|
+
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
describe('machine_comment', () => {
|
|
162
|
+
|
|
163
|
+
test('atom', () =>
|
|
164
|
+
expect( () => { const _foo = sm`machine_comment: bob; a->b;`; })
|
|
165
|
+
.not.toThrow() );
|
|
166
|
+
|
|
167
|
+
test('quoted string', () =>
|
|
168
|
+
expect( () => { const _foo = sm`machine_comment: "bo b"; a->b;`; })
|
|
169
|
+
.not.toThrow() );
|
|
170
|
+
|
|
171
|
+
test('retval correct', () =>
|
|
172
|
+
expect(sm`machine_comment: testval; a->b;`.machine_comment() )
|
|
173
|
+
.toBe("testval") );
|
|
174
|
+
|
|
175
|
+
});
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
describe('machine_definition', () => {
|
|
182
|
+
|
|
183
|
+
test('url', () =>
|
|
184
|
+
expect( () => { const _foo = sm`machine_definition: http://google.com/ ; a->b;`; })
|
|
185
|
+
.not.toThrow() );
|
|
186
|
+
|
|
187
|
+
test('url botched', () =>
|
|
188
|
+
expect( () => { const _foo = sm`machine_definition: "not a url"; a->b;`; })
|
|
189
|
+
.toThrow() );
|
|
190
|
+
|
|
191
|
+
test('retval correct', () =>
|
|
192
|
+
expect(sm`machine_definition: http://google.com/ ; a->b;`.machine_definition() )
|
|
193
|
+
.toBe("http://google.com/") );
|
|
194
|
+
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
|
|
201
|
+
describe('machine_version', () => {
|
|
202
|
+
|
|
203
|
+
test('semver 0.0.0', () =>
|
|
204
|
+
expect( () => { const _f = sm`machine_version: 0.0.0; a->b;`; })
|
|
205
|
+
.not.toThrow() );
|
|
206
|
+
|
|
207
|
+
test('semver 0.0.1', () =>
|
|
208
|
+
expect( () => { const _f = sm`machine_version: 0.0.1; a->b;`; })
|
|
209
|
+
.not.toThrow() );
|
|
210
|
+
|
|
211
|
+
test('semver 0.1.0', () =>
|
|
212
|
+
expect( () => { const _f = sm`machine_version: 0.1.0; a->b;`; })
|
|
213
|
+
.not.toThrow() );
|
|
214
|
+
|
|
215
|
+
test('semver 1.0.0', () =>
|
|
216
|
+
expect( () => { const _f = sm`machine_version: 1.0.0; a->b;`; })
|
|
217
|
+
.not.toThrow() );
|
|
218
|
+
|
|
219
|
+
test('semver 1.0.1', () =>
|
|
220
|
+
expect( () => { const _f = sm`machine_version: 1.0.1; a->b;`; })
|
|
221
|
+
.not.toThrow() );
|
|
222
|
+
|
|
223
|
+
test('semver 1.1.1', () =>
|
|
224
|
+
expect( () => { const _f = sm`machine_version: 1.1.1; a->b;`; })
|
|
225
|
+
.not.toThrow() );
|
|
226
|
+
|
|
227
|
+
test('semver 2.0.0', () =>
|
|
228
|
+
expect( () => { const _f = sm`machine_version: 2.0.0; a->b;`; })
|
|
229
|
+
.not.toThrow() );
|
|
230
|
+
|
|
231
|
+
|
|
232
|
+
test('semver notAS', () =>
|
|
233
|
+
expect(() => { const _f = sm`machine_version: "Not a semver"; a->b;`; })
|
|
234
|
+
.toThrow() );
|
|
235
|
+
|
|
236
|
+
|
|
237
|
+
test('retval correct', () =>
|
|
238
|
+
expect(sm`machine_version: 0.0.0; a->b;`.machine_version())
|
|
239
|
+
.toEqual({full:"0.0.0", major:0, minor:0, patch:0}) );
|
|
240
|
+
|
|
241
|
+
});
|
|
242
|
+
|
|
243
|
+
|
|
244
|
+
|
|
245
|
+
|
|
246
|
+
|
|
247
|
+
describe('machine_license', () => {
|
|
248
|
+
|
|
249
|
+
test('retval correct', () =>
|
|
250
|
+
expect( sm`machine_license: testval; a->b;`.machine_license() )
|
|
251
|
+
.toBe("testval") );
|
|
252
|
+
|
|
253
|
+
|
|
254
|
+
describe('near', () => {
|
|
255
|
+
|
|
256
|
+
test('Public domain', () =>
|
|
257
|
+
expect( () => { const _ = sm`machine_license:Public domain; a->b;`; })
|
|
258
|
+
.not.toThrow() );
|
|
259
|
+
|
|
260
|
+
test('MIT', () =>
|
|
261
|
+
expect( () => { const _ = sm`machine_license:MIT; a->b;`; })
|
|
262
|
+
.not.toThrow() );
|
|
263
|
+
|
|
264
|
+
test('BSD 2-clause', () =>
|
|
265
|
+
expect( () => { const _ = sm`machine_license:BSD 2-clause; a->b;`; })
|
|
266
|
+
.not.toThrow() );
|
|
267
|
+
|
|
268
|
+
test('BSD 3-clause', () =>
|
|
269
|
+
expect( () => { const _ = sm`machine_license:BSD 3-clause; a->b;`; })
|
|
270
|
+
.not.toThrow() );
|
|
271
|
+
|
|
272
|
+
test('Apache 2.0', () =>
|
|
273
|
+
expect( () => { const _ = sm`machine_license:Apache 2.0; a->b;`; })
|
|
274
|
+
.not.toThrow() );
|
|
275
|
+
|
|
276
|
+
test('Mozilla 2.0', () =>
|
|
277
|
+
expect( () => { const _ = sm`machine_license:Mozilla 2.0; a->b;`; })
|
|
278
|
+
.not.toThrow() );
|
|
279
|
+
|
|
280
|
+
test('GPL v2', () =>
|
|
281
|
+
expect( () => { const _ = sm`machine_license:GPL v2; a->b;`; })
|
|
282
|
+
.not.toThrow() );
|
|
283
|
+
|
|
284
|
+
test('GPL v3', () =>
|
|
285
|
+
expect( () => { const _ = sm`machine_license:GPL v3; a->b;`; })
|
|
286
|
+
.not.toThrow() );
|
|
287
|
+
|
|
288
|
+
test('LGPL v2.1', () =>
|
|
289
|
+
expect( () => { const _ = sm`machine_license:LGPL v2.1; a->b;`; })
|
|
290
|
+
.not.toThrow() );
|
|
291
|
+
|
|
292
|
+
test('LGPL v3.0', () =>
|
|
293
|
+
expect( () => { const _ = sm`machine_license:LGPL v3.0; a->b;`; })
|
|
294
|
+
.not.toThrow() );
|
|
295
|
+
|
|
296
|
+
});
|
|
297
|
+
|
|
298
|
+
|
|
299
|
+
describe('spaced', () => {
|
|
300
|
+
|
|
301
|
+
test('Public domain', () =>
|
|
302
|
+
expect( () => { const _ = sm`machine_license: Public domain ; a->b;`; })
|
|
303
|
+
.not.toThrow() );
|
|
304
|
+
|
|
305
|
+
test('MIT', () =>
|
|
306
|
+
expect( () => { const _ = sm`machine_license: MIT ; a->b;`; })
|
|
307
|
+
.not.toThrow() );
|
|
308
|
+
|
|
309
|
+
test('BSD 2-clause', () =>
|
|
310
|
+
expect( () => { const _ = sm`machine_license: BSD 2-clause ; a->b;`; })
|
|
311
|
+
.not.toThrow() );
|
|
312
|
+
|
|
313
|
+
test('BSD 3-clause', () =>
|
|
314
|
+
expect( () => { const _ = sm`machine_license: BSD 3-clause ; a->b;`; })
|
|
315
|
+
.not.toThrow() );
|
|
316
|
+
|
|
317
|
+
test('Apache 2.0', () =>
|
|
318
|
+
expect( () => { const _ = sm`machine_license: Apache 2.0 ; a->b;`; })
|
|
319
|
+
.not.toThrow() );
|
|
320
|
+
|
|
321
|
+
test('Mozilla 2.0', () =>
|
|
322
|
+
expect( () => { const _ = sm`machine_license: Mozilla 2.0 ; a->b;`; })
|
|
323
|
+
.not.toThrow() );
|
|
324
|
+
|
|
325
|
+
test('GPL v2', () =>
|
|
326
|
+
expect( () => { const _ = sm`machine_license: GPL v2 ; a->b;`; })
|
|
327
|
+
.not.toThrow() );
|
|
328
|
+
|
|
329
|
+
test('GPL v3', () =>
|
|
330
|
+
expect( () => { const _ = sm`machine_license: GPL v3 ; a->b;`; })
|
|
331
|
+
.not.toThrow() );
|
|
332
|
+
|
|
333
|
+
test('LGPL v2.1', () =>
|
|
334
|
+
expect( () => { const _ = sm`machine_license: LGPL v2.1 ; a->b;`; })
|
|
335
|
+
.not.toThrow() );
|
|
336
|
+
|
|
337
|
+
test('LGPL v3.0', () =>
|
|
338
|
+
expect( () => { const _ = sm`machine_license: LGPL v3.0 ; a->b;`; })
|
|
339
|
+
.not.toThrow() );
|
|
340
|
+
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
|
|
344
|
+
test('single atom', () =>
|
|
345
|
+
expect( () => { const _ = sm`machine_license: bob; a->b;`; })
|
|
346
|
+
.not.toThrow() );
|
|
347
|
+
|
|
348
|
+
test('single quoted string', () =>
|
|
349
|
+
expect( () => { const _ = sm`machine_license: "bo b"; a->b;`; })
|
|
350
|
+
.not.toThrow() );
|
|
351
|
+
|
|
352
|
+
});
|
|
353
|
+
|
|
354
|
+
|
|
355
|
+
|
|
356
|
+
|
|
357
|
+
|
|
358
|
+
describe('fsl_version', () => {
|
|
359
|
+
|
|
360
|
+
test('semver 0.0.0', () =>
|
|
361
|
+
expect( () => { const _f = sm`fsl_version: 0.0.0; a->b;`; })
|
|
362
|
+
.not.toThrow() );
|
|
363
|
+
|
|
364
|
+
test('semver 0.0.1', () =>
|
|
365
|
+
expect( () => { const _f = sm`fsl_version: 0.0.1; a->b;`; })
|
|
366
|
+
.not.toThrow() );
|
|
367
|
+
|
|
368
|
+
test('semver 0.1.0', () =>
|
|
369
|
+
expect( () => { const _f = sm`fsl_version: 0.1.0; a->b;`; })
|
|
370
|
+
.not.toThrow() );
|
|
371
|
+
|
|
372
|
+
test('semver 1.0.0', () =>
|
|
373
|
+
expect( () => { const _f = sm`fsl_version: 1.0.0; a->b;`; })
|
|
374
|
+
.not.toThrow() );
|
|
375
|
+
|
|
376
|
+
test('semver 1.0.1', () =>
|
|
377
|
+
expect( () => { const _f = sm`fsl_version: 1.0.1; a->b;`; })
|
|
378
|
+
.not.toThrow() );
|
|
379
|
+
|
|
380
|
+
test('semver 1.1.1', () =>
|
|
381
|
+
expect( () => { const _f = sm`fsl_version: 1.1.1; a->b;`; })
|
|
382
|
+
.not.toThrow() );
|
|
383
|
+
|
|
384
|
+
test('semver 2.0.0', () =>
|
|
385
|
+
expect( () => { const _f = sm`fsl_version: 2.0.0; a->b;`; })
|
|
386
|
+
.not.toThrow() );
|
|
387
|
+
|
|
388
|
+
|
|
389
|
+
test('semver notAS', () =>
|
|
390
|
+
expect(() => { const _f = sm`fsl_version: "Not a semver"; a->b;`; })
|
|
391
|
+
.toThrow() );
|
|
392
|
+
|
|
393
|
+
|
|
394
|
+
test('retval correct', () =>
|
|
395
|
+
expect(sm`fsl_version: 0.0.0; a->b;`.fsl_version())
|
|
396
|
+
.toEqual({full:"0.0.0", major:0, minor:0, patch:0}) );
|
|
397
|
+
|
|
398
|
+
});
|