functionalscript 0.32.4 → 0.33.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/fs/bnf/data/proof.f.d.ts +3 -0
- package/fs/bnf/data/proof.f.js +7 -0
- package/fs/cas/mcp/module.f.js +3 -1
- package/fs/cas/mcp/proof.f.js +16 -11
- package/fs/cas/module.f.d.ts +5 -19
- package/fs/cas/module.f.js +42 -54
- package/fs/cas/proof.f.js +15 -24
- package/fs/ci/config/module.f.d.ts +6 -6
- package/fs/ci/config/module.f.js +6 -6
- package/fs/ci/proof.f.js +8 -6
- package/fs/cli/proof.f.js +2 -12
- package/fs/djs/parser/module.f.d.ts +0 -5
- package/fs/djs/proof.f.js +5 -6
- package/fs/djs/serializer/module.f.d.ts +1 -3
- package/fs/djs/tokenizer-new/module.f.js +2 -1
- package/fs/djs/tokenizer-new/proof.f.d.ts +1 -0
- package/fs/djs/tokenizer-new/proof.f.js +101 -67
- package/fs/djs/transpiler/proof.f.js +10 -10
- package/fs/effects/node/proof.f.js +36 -36
- package/fs/effects/node/virtual/module.f.d.ts +16 -2
- package/fs/effects/node/virtual/module.f.js +72 -20
- package/fs/effects/node/virtual/proof.f.d.ts +4 -0
- package/fs/effects/node/virtual/proof.f.js +47 -14
- package/fs/emergent_testing/proof.f.js +3 -11
- package/fs/fjs/module.f.js +3 -3
- package/fs/fjs/proof.f.js +2 -11
- package/fs/js/tokenizer/module.f.d.ts +5 -0
- package/fs/js/tokenizer/module.f.js +13 -0
- package/fs/json/serializer/module.f.js +0 -1
- package/fs/text/sgr/proof.f.js +2 -11
- package/fs/types/bigint/module.f.d.ts +8 -15
- package/fs/types/bigint/module.f.js +9 -22
- package/fs/types/bigint/proof.f.d.ts +0 -2
- package/fs/types/bigint/proof.f.js +6 -16
- package/package.json +1 -1
|
@@ -38,6 +38,8 @@ const scanFunc = (input, state) => {
|
|
|
38
38
|
return [null, state];
|
|
39
39
|
if (isNlTag(input) && isWsTag(state[0]))
|
|
40
40
|
return [null, [input, []]];
|
|
41
|
+
if (isWsTag(input) && isNlTag(state[0]))
|
|
42
|
+
return [null, state];
|
|
41
43
|
const newState = [input, []];
|
|
42
44
|
if (state[0] === '') {
|
|
43
45
|
return [null, newState];
|
|
@@ -53,7 +55,7 @@ const operatorTags = new Set([
|
|
|
53
55
|
'>>>=', '>>>', '>>=', '>>', '>=', '>',
|
|
54
56
|
'<<<=', '<<<', '<<=', '<<', '<=', '<',
|
|
55
57
|
'+=', '++', '+', '-=', '--', '-',
|
|
56
|
-
'**=', '**', '*=', '*', '/=', '%=', '%',
|
|
58
|
+
'**=', '**', '*=', '*', '/=', '/', '%=', '%', // TODO: '/' here causes multi-char line comments (e.g. //ab\n) to fall through as two '/' operator tokens because the oneline rule only consumes one non-newline character (option vs repeat0Plus). Fix the comment rule to use repeat0Plus, or make filterFunc distinguish operator-branch '/' from slash characters inside comments.
|
|
57
59
|
'&&=', '&&', '&=', '&', '||=', '||', '|=', '|',
|
|
58
60
|
'^=', '^', '~', '??=', '??', '?.', '?',
|
|
59
61
|
'[', ']', '{', '}', '(', ')', ',', ':'
|
|
@@ -664,76 +666,108 @@ export const proof = {
|
|
|
664
666
|
// const result = tokenizeString('=a')
|
|
665
667
|
// if (result !== '[{"kind":"="},{"kind":"id","value":"a"},{"kind":"eof"}]') { throw result }
|
|
666
668
|
// },
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
669
|
+
() => {
|
|
670
|
+
const result = tokenizeString('-');
|
|
671
|
+
if (result !== '[{"kind":"-"},{"kind":"eof"}]') {
|
|
672
|
+
throw result;
|
|
673
|
+
}
|
|
674
|
+
},
|
|
671
675
|
// () => {
|
|
672
676
|
// const result = tokenizeString('1*2')
|
|
673
677
|
// if (result !== '[{"bf":[1n,0],"kind":"number","value":"1"},{"kind":"*"},{"bf":[2n,0],"kind":"number","value":"2"},{"kind":"eof"}]') { throw result }
|
|
674
678
|
// },
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
679
|
+
() => {
|
|
680
|
+
const result = tokenizeString('( )');
|
|
681
|
+
if (result !== '[{"kind":"("},{"kind":"ws"},{"kind":")"},{"kind":"eof"}]') {
|
|
682
|
+
throw result;
|
|
683
|
+
}
|
|
684
|
+
},
|
|
685
|
+
() => {
|
|
686
|
+
const result = tokenizeString('== != === !== > >= < <=');
|
|
687
|
+
if (result !== '[{"kind":"=="},{"kind":"ws"},{"kind":"!="},{"kind":"ws"},{"kind":"==="},{"kind":"ws"},{"kind":"!=="},{"kind":"ws"},{"kind":">"},{"kind":"ws"},{"kind":">="},{"kind":"ws"},{"kind":"<"},{"kind":"ws"},{"kind":"<="},{"kind":"eof"}]') {
|
|
688
|
+
throw result;
|
|
689
|
+
}
|
|
690
|
+
},
|
|
691
|
+
() => {
|
|
692
|
+
const result = tokenizeString('+ - * / % ++ -- **');
|
|
693
|
+
if (result !== '[{"kind":"+"},{"kind":"ws"},{"kind":"-"},{"kind":"ws"},{"kind":"*"},{"kind":"ws"},{"kind":"/"},{"kind":"ws"},{"kind":"%"},{"kind":"ws"},{"kind":"++"},{"kind":"ws"},{"kind":"--"},{"kind":"ws"},{"kind":"**"},{"kind":"eof"}]') {
|
|
694
|
+
throw result;
|
|
695
|
+
}
|
|
696
|
+
},
|
|
697
|
+
() => {
|
|
698
|
+
const result = tokenizeString('= += -= *= /= %= **=');
|
|
699
|
+
if (result !== '[{"kind":"="},{"kind":"ws"},{"kind":"+="},{"kind":"ws"},{"kind":"-="},{"kind":"ws"},{"kind":"*="},{"kind":"ws"},{"kind":"/="},{"kind":"ws"},{"kind":"%="},{"kind":"ws"},{"kind":"**="},{"kind":"eof"}]') {
|
|
700
|
+
throw result;
|
|
701
|
+
}
|
|
702
|
+
},
|
|
703
|
+
() => {
|
|
704
|
+
const result = tokenizeString('& | ^ ~ << >> >>>');
|
|
705
|
+
if (result !== '[{"kind":"&"},{"kind":"ws"},{"kind":"|"},{"kind":"ws"},{"kind":"^"},{"kind":"ws"},{"kind":"~"},{"kind":"ws"},{"kind":"<<"},{"kind":"ws"},{"kind":">>"},{"kind":"ws"},{"kind":">>>"},{"kind":"eof"}]') {
|
|
706
|
+
throw result;
|
|
707
|
+
}
|
|
708
|
+
},
|
|
709
|
+
() => {
|
|
710
|
+
const result = tokenizeString('&= |= ^= <<= >>= >>>=');
|
|
711
|
+
if (result !== '[{"kind":"&="},{"kind":"ws"},{"kind":"|="},{"kind":"ws"},{"kind":"^="},{"kind":"ws"},{"kind":"<<="},{"kind":"ws"},{"kind":">>="},{"kind":"ws"},{"kind":">>>="},{"kind":"eof"}]') {
|
|
712
|
+
throw result;
|
|
713
|
+
}
|
|
714
|
+
},
|
|
715
|
+
() => {
|
|
716
|
+
const result = tokenizeString('&& || ! ??');
|
|
717
|
+
if (result !== '[{"kind":"&&"},{"kind":"ws"},{"kind":"||"},{"kind":"ws"},{"kind":"!"},{"kind":"ws"},{"kind":"??"},{"kind":"eof"}]') {
|
|
718
|
+
throw result;
|
|
719
|
+
}
|
|
720
|
+
},
|
|
721
|
+
() => {
|
|
722
|
+
const result = tokenizeString('&&= ||= ??=');
|
|
723
|
+
if (result !== '[{"kind":"&&="},{"kind":"ws"},{"kind":"||="},{"kind":"ws"},{"kind":"??="},{"kind":"eof"}]') {
|
|
724
|
+
throw result;
|
|
725
|
+
}
|
|
726
|
+
},
|
|
727
|
+
() => {
|
|
728
|
+
const result = tokenizeString('? ?. . =>');
|
|
729
|
+
if (result !== '[{"kind":"?"},{"kind":"ws"},{"kind":"?."},{"kind":"ws"},{"kind":"."},{"kind":"ws"},{"kind":"=>"},{"kind":"eof"}]') {
|
|
730
|
+
throw result;
|
|
731
|
+
}
|
|
732
|
+
},
|
|
733
|
+
],
|
|
734
|
+
ws: [
|
|
735
|
+
() => {
|
|
736
|
+
const result = tokenizeString(' ');
|
|
737
|
+
if (result !== '[{"kind":"ws"},{"kind":"eof"}]') {
|
|
738
|
+
throw result;
|
|
739
|
+
}
|
|
740
|
+
},
|
|
741
|
+
() => {
|
|
742
|
+
const result = tokenizeString('\t');
|
|
743
|
+
if (result !== '[{"kind":"ws"},{"kind":"eof"}]') {
|
|
744
|
+
throw result;
|
|
745
|
+
}
|
|
746
|
+
},
|
|
747
|
+
() => {
|
|
748
|
+
const result = tokenizeString(' \t');
|
|
749
|
+
if (result !== '[{"kind":"ws"},{"kind":"eof"}]') {
|
|
750
|
+
throw result;
|
|
751
|
+
}
|
|
752
|
+
},
|
|
753
|
+
() => {
|
|
754
|
+
const result = tokenizeString('\n');
|
|
755
|
+
if (result !== '[{"kind":"nl"},{"kind":"eof"}]') {
|
|
756
|
+
throw result;
|
|
757
|
+
}
|
|
758
|
+
},
|
|
759
|
+
() => {
|
|
760
|
+
const result = tokenizeString('\r');
|
|
761
|
+
if (result !== '[{"kind":"nl"},{"kind":"eof"}]') {
|
|
762
|
+
throw result;
|
|
763
|
+
}
|
|
764
|
+
},
|
|
765
|
+
() => {
|
|
766
|
+
const result = tokenizeString(' \t\n\r ');
|
|
767
|
+
if (result !== '[{"kind":"nl"},{"kind":"eof"}]') {
|
|
768
|
+
throw result;
|
|
769
|
+
}
|
|
770
|
+
},
|
|
737
771
|
],
|
|
738
772
|
// id: [
|
|
739
773
|
// () => {
|
|
@@ -9,7 +9,7 @@ const run = (root) => (path) => {
|
|
|
9
9
|
};
|
|
10
10
|
export const proof = {
|
|
11
11
|
parse: () => {
|
|
12
|
-
const result = run({ a: utf8('export default 1') })('a');
|
|
12
|
+
const result = run({ a: [utf8('export default 1')] })('a');
|
|
13
13
|
if (result[0] === 'error') {
|
|
14
14
|
throw result[1];
|
|
15
15
|
}
|
|
@@ -19,7 +19,7 @@ export const proof = {
|
|
|
19
19
|
}
|
|
20
20
|
},
|
|
21
21
|
parseWithSubModule: () => {
|
|
22
|
-
const result = run({ a: { b: utf8('import c from "c"\nexport default c'), c: utf8('export default 2') } })('a/b');
|
|
22
|
+
const result = run({ a: { b: [utf8('import c from "c"\nexport default c')], c: [utf8('export default 2')] } })('a/b');
|
|
23
23
|
if (result[0] === 'error') {
|
|
24
24
|
throw result[1];
|
|
25
25
|
}
|
|
@@ -30,10 +30,10 @@ export const proof = {
|
|
|
30
30
|
},
|
|
31
31
|
parseWithSubModules: () => {
|
|
32
32
|
const result = run({
|
|
33
|
-
a: utf8('import b from "b"\nimport c from "c"\nexport default [b,c,b]'),
|
|
34
|
-
b: utf8('import d from "d"\nexport default [0,d]'),
|
|
35
|
-
c: utf8('import d from "d"\nexport default [1,d]'),
|
|
36
|
-
d: utf8('export default 2'),
|
|
33
|
+
a: [utf8('import b from "b"\nimport c from "c"\nexport default [b,c,b]')],
|
|
34
|
+
b: [utf8('import d from "d"\nexport default [0,d]')],
|
|
35
|
+
c: [utf8('import d from "d"\nexport default [1,d]')],
|
|
36
|
+
d: [utf8('export default 2')],
|
|
37
37
|
})('a');
|
|
38
38
|
if (result[0] === 'error') {
|
|
39
39
|
throw result[1];
|
|
@@ -44,7 +44,7 @@ export const proof = {
|
|
|
44
44
|
}
|
|
45
45
|
},
|
|
46
46
|
parseWithFileNotFoundError: () => {
|
|
47
|
-
const result = run({ a: utf8('import b from "b"\nexport default b') })('a');
|
|
47
|
+
const result = run({ a: [utf8('import b from "b"\nexport default b')] })('a');
|
|
48
48
|
if (result[0] !== 'error') {
|
|
49
49
|
throw result;
|
|
50
50
|
}
|
|
@@ -54,9 +54,9 @@ export const proof = {
|
|
|
54
54
|
},
|
|
55
55
|
parseWithCycleError: () => {
|
|
56
56
|
const result = run({
|
|
57
|
-
a: utf8('import b from "b"\nimport c from "c"\nexport default [b,c,b]'),
|
|
58
|
-
b: utf8('import c from "c"\nexport default c'),
|
|
59
|
-
c: utf8('import b from "b"\nexport default b'),
|
|
57
|
+
a: [utf8('import b from "b"\nimport c from "c"\nexport default [b,c,b]')],
|
|
58
|
+
b: [utf8('import c from "c"\nexport default c')],
|
|
59
|
+
c: [utf8('import b from "b"\nexport default b')],
|
|
60
60
|
})('a');
|
|
61
61
|
if (result[0] !== 'error') {
|
|
62
62
|
throw result;
|
|
@@ -51,7 +51,7 @@ export const proof = {
|
|
|
51
51
|
throw result;
|
|
52
52
|
}
|
|
53
53
|
const a = state.root.a;
|
|
54
|
-
if (a === undefined ||
|
|
54
|
+
if (a === undefined || Array.isArray(a)) {
|
|
55
55
|
throw a;
|
|
56
56
|
}
|
|
57
57
|
},
|
|
@@ -61,11 +61,11 @@ export const proof = {
|
|
|
61
61
|
throw result;
|
|
62
62
|
}
|
|
63
63
|
const tmp = state.root.tmp;
|
|
64
|
-
if (typeof tmp !== 'object') {
|
|
64
|
+
if (typeof tmp !== 'object' || Array.isArray(tmp)) {
|
|
65
65
|
throw state.root;
|
|
66
66
|
}
|
|
67
67
|
const cache = tmp.cache;
|
|
68
|
-
if (typeof cache !== 'object') {
|
|
68
|
+
if (typeof cache !== 'object' || Array.isArray(cache)) {
|
|
69
69
|
throw tmp;
|
|
70
70
|
}
|
|
71
71
|
},
|
|
@@ -84,7 +84,7 @@ export const proof = {
|
|
|
84
84
|
const initial = {
|
|
85
85
|
...emptyState,
|
|
86
86
|
root: {
|
|
87
|
-
hello: vec8(0x2an),
|
|
87
|
+
hello: [vec8(0x2an)],
|
|
88
88
|
},
|
|
89
89
|
};
|
|
90
90
|
const [state, [t, result]] = virtual(initial)(readFile('hello'));
|
|
@@ -104,7 +104,7 @@ export const proof = {
|
|
|
104
104
|
nested: () => {
|
|
105
105
|
const [_, [tag, result]] = virtual({
|
|
106
106
|
...emptyState,
|
|
107
|
-
root: { tmp: { cache: vec8(0x15n) } }
|
|
107
|
+
root: { tmp: { cache: [vec8(0x15n)] } }
|
|
108
108
|
})(readFile('tmp/cache'));
|
|
109
109
|
if (tag === 'error') {
|
|
110
110
|
throw result;
|
|
@@ -133,7 +133,7 @@ export const proof = {
|
|
|
133
133
|
const initial = {
|
|
134
134
|
...emptyState,
|
|
135
135
|
root: {
|
|
136
|
-
smallFile: vec8(0x2an),
|
|
136
|
+
smallFile: [vec8(0x2an)],
|
|
137
137
|
},
|
|
138
138
|
};
|
|
139
139
|
const [_, [t, result]] = virtual(initial)(readFile('smallFile'));
|
|
@@ -149,7 +149,7 @@ export const proof = {
|
|
|
149
149
|
ok: () => {
|
|
150
150
|
const [_, [t, result]] = virtual({
|
|
151
151
|
...emptyState,
|
|
152
|
-
root: { hello: utf8('Hello, world!') },
|
|
152
|
+
root: { hello: [utf8('Hello, world!')] },
|
|
153
153
|
})(readUtf8File('hello'));
|
|
154
154
|
if (t !== 'ok') {
|
|
155
155
|
throw result;
|
|
@@ -170,9 +170,9 @@ export const proof = {
|
|
|
170
170
|
const [_, [t, result]] = virtual({
|
|
171
171
|
...emptyState,
|
|
172
172
|
root: {
|
|
173
|
-
file: vec8(0x2an),
|
|
173
|
+
file: [vec8(0x2an)],
|
|
174
174
|
dir: {
|
|
175
|
-
a: empty
|
|
175
|
+
a: [empty]
|
|
176
176
|
},
|
|
177
177
|
},
|
|
178
178
|
})(readdir('', { recursive: true }));
|
|
@@ -192,9 +192,9 @@ export const proof = {
|
|
|
192
192
|
const [_, [t, result]] = virtual({
|
|
193
193
|
...emptyState,
|
|
194
194
|
root: {
|
|
195
|
-
file: vec8(0x2an),
|
|
195
|
+
file: [vec8(0x2an)],
|
|
196
196
|
dir: {
|
|
197
|
-
a: empty
|
|
197
|
+
a: [empty]
|
|
198
198
|
},
|
|
199
199
|
},
|
|
200
200
|
})(readdir('', {}));
|
|
@@ -216,7 +216,7 @@ export const proof = {
|
|
|
216
216
|
nested: () => {
|
|
217
217
|
const [_, [t, result]] = virtual({
|
|
218
218
|
...emptyState,
|
|
219
|
-
root: { tmp: { cache: vec8(0x15n) } }
|
|
219
|
+
root: { tmp: { cache: [vec8(0x15n)] } }
|
|
220
220
|
})(readdir('tmp', { recursive: true }));
|
|
221
221
|
if (t !== 'ok') {
|
|
222
222
|
throw result;
|
|
@@ -249,10 +249,10 @@ export const proof = {
|
|
|
249
249
|
throw result;
|
|
250
250
|
}
|
|
251
251
|
const file = state.root.hello;
|
|
252
|
-
if (!
|
|
252
|
+
if (!Array.isArray(file)) {
|
|
253
253
|
throw file;
|
|
254
254
|
}
|
|
255
|
-
if (uint(file) !== 0x2an) {
|
|
255
|
+
if (uint(file[0]) !== 0x2an) {
|
|
256
256
|
throw file;
|
|
257
257
|
}
|
|
258
258
|
},
|
|
@@ -260,17 +260,17 @@ export const proof = {
|
|
|
260
260
|
const [state, [t, result]] = virtual({
|
|
261
261
|
...emptyState,
|
|
262
262
|
root: {
|
|
263
|
-
hello: vec8(0x15n),
|
|
263
|
+
hello: [vec8(0x15n)],
|
|
264
264
|
},
|
|
265
265
|
})(writeFile('hello', vec8(0x2an)));
|
|
266
266
|
if (t !== 'ok') {
|
|
267
267
|
throw result;
|
|
268
268
|
}
|
|
269
269
|
const file = state.root.hello;
|
|
270
|
-
if (!
|
|
270
|
+
if (!Array.isArray(file)) {
|
|
271
271
|
throw file;
|
|
272
272
|
}
|
|
273
|
-
if (uint(file) !== 0x2an) {
|
|
273
|
+
if (uint(file[0]) !== 0x2an) {
|
|
274
274
|
throw file;
|
|
275
275
|
}
|
|
276
276
|
},
|
|
@@ -300,7 +300,7 @@ export const proof = {
|
|
|
300
300
|
throw result;
|
|
301
301
|
}
|
|
302
302
|
const tmp = state.root.tmp;
|
|
303
|
-
if (tmp === undefined ||
|
|
303
|
+
if (tmp === undefined || Array.isArray(tmp)) {
|
|
304
304
|
throw tmp;
|
|
305
305
|
}
|
|
306
306
|
},
|
|
@@ -311,10 +311,10 @@ export const proof = {
|
|
|
311
311
|
throw result;
|
|
312
312
|
}
|
|
313
313
|
const file = state.root.hello;
|
|
314
|
-
if (!
|
|
314
|
+
if (!Array.isArray(file)) {
|
|
315
315
|
throw file;
|
|
316
316
|
}
|
|
317
|
-
if (utf8ToString(file) !== 'Hello, world!') {
|
|
317
|
+
if (utf8ToString(file[0]) !== 'Hello, world!') {
|
|
318
318
|
throw file;
|
|
319
319
|
}
|
|
320
320
|
},
|
|
@@ -322,7 +322,7 @@ export const proof = {
|
|
|
322
322
|
one: () => {
|
|
323
323
|
const [state, [t, result]] = virtual({
|
|
324
324
|
...emptyState,
|
|
325
|
-
root: { hello: vec8(0x2an) },
|
|
325
|
+
root: { hello: [vec8(0x2an)] },
|
|
326
326
|
})(rm('hello'));
|
|
327
327
|
if (t !== 'ok') {
|
|
328
328
|
throw result;
|
|
@@ -334,13 +334,13 @@ export const proof = {
|
|
|
334
334
|
nested: () => {
|
|
335
335
|
const [state, [t, result]] = virtual({
|
|
336
336
|
...emptyState,
|
|
337
|
-
root: { tmp: { cache: vec8(0x15n) } },
|
|
337
|
+
root: { tmp: { cache: [vec8(0x15n)] } },
|
|
338
338
|
})(rm('tmp/cache'));
|
|
339
339
|
if (t !== 'ok') {
|
|
340
340
|
throw result;
|
|
341
341
|
}
|
|
342
342
|
const tmp = state.root.tmp;
|
|
343
|
-
if (typeof tmp !== 'object') {
|
|
343
|
+
if (typeof tmp !== 'object' || Array.isArray(tmp)) {
|
|
344
344
|
throw state.root;
|
|
345
345
|
}
|
|
346
346
|
if (tmp.cache !== undefined) {
|
|
@@ -376,8 +376,8 @@ export const proof = {
|
|
|
376
376
|
const [_, results] = virtual({
|
|
377
377
|
...emptyState,
|
|
378
378
|
root: {
|
|
379
|
-
a: vec8(0x2an),
|
|
380
|
-
b: vec8(0x15n),
|
|
379
|
+
a: [vec8(0x2an)],
|
|
380
|
+
b: [vec8(0x15n)],
|
|
381
381
|
},
|
|
382
382
|
})(both(readFile('a'))(readFile('b')));
|
|
383
383
|
if (results[0][0] !== 'ok') {
|
|
@@ -446,7 +446,7 @@ export const proof = {
|
|
|
446
446
|
fileOverFile: () => {
|
|
447
447
|
const [state, [t, result]] = virtual({
|
|
448
448
|
...emptyState,
|
|
449
|
-
root: { src: vec8(0x2an), dst: vec8(0x15n) },
|
|
449
|
+
root: { src: [vec8(0x2an)], dst: [vec8(0x15n)] },
|
|
450
450
|
})(rename('src', 'dst'));
|
|
451
451
|
if (t !== 'ok') {
|
|
452
452
|
throw result;
|
|
@@ -454,23 +454,23 @@ export const proof = {
|
|
|
454
454
|
if (state.root.src !== undefined) {
|
|
455
455
|
throw state.root;
|
|
456
456
|
}
|
|
457
|
-
if (!
|
|
457
|
+
if (!Array.isArray(state.root.dst)) {
|
|
458
458
|
throw state.root;
|
|
459
459
|
}
|
|
460
|
-
if (uint(state.root.dst) !== 0x2an) {
|
|
460
|
+
if (uint(state.root.dst[0]) !== 0x2an) {
|
|
461
461
|
throw state.root;
|
|
462
462
|
}
|
|
463
463
|
},
|
|
464
464
|
nestedRename: () => {
|
|
465
465
|
const [state, [t, result]] = virtual({
|
|
466
466
|
...emptyState,
|
|
467
|
-
root: { tmp: { src: vec8(0x2an) } },
|
|
467
|
+
root: { tmp: { src: [vec8(0x2an)] } },
|
|
468
468
|
})(rename('tmp/src', 'tmp/dst'));
|
|
469
469
|
if (t !== 'ok') {
|
|
470
470
|
throw result;
|
|
471
471
|
}
|
|
472
472
|
const tmp = state.root.tmp;
|
|
473
|
-
if (typeof tmp !== 'object') {
|
|
473
|
+
if (typeof tmp !== 'object' || Array.isArray(tmp)) {
|
|
474
474
|
throw state.root;
|
|
475
475
|
}
|
|
476
476
|
if (tmp.src !== undefined) {
|
|
@@ -480,12 +480,12 @@ export const proof = {
|
|
|
480
480
|
dirOverFile: () => {
|
|
481
481
|
const [state, [t, result]] = virtual({
|
|
482
482
|
...emptyState,
|
|
483
|
-
root: { src: {}, dst: vec8(0x15n) },
|
|
483
|
+
root: { src: {}, dst: [vec8(0x15n)] },
|
|
484
484
|
})(rename('src', 'dst'));
|
|
485
485
|
if (t !== 'error') {
|
|
486
486
|
throw result;
|
|
487
487
|
}
|
|
488
|
-
if (!
|
|
488
|
+
if (!Array.isArray(state.root.dst)) {
|
|
489
489
|
throw state.root;
|
|
490
490
|
}
|
|
491
491
|
},
|
|
@@ -500,8 +500,8 @@ export const proof = {
|
|
|
500
500
|
simple: () => {
|
|
501
501
|
const [_, [t, result]] = virtual({
|
|
502
502
|
...emptyState,
|
|
503
|
-
root: { file: vec8(
|
|
504
|
-
})(readBytes('file', 0,
|
|
503
|
+
root: { file: [vec8(0xabn)] },
|
|
504
|
+
})(readBytes('file', 0, 1));
|
|
505
505
|
if (t !== 'ok') {
|
|
506
506
|
throw result;
|
|
507
507
|
}
|
|
@@ -512,7 +512,7 @@ export const proof = {
|
|
|
512
512
|
withOffset: () => {
|
|
513
513
|
const [_, [t, result]] = virtual({
|
|
514
514
|
...emptyState,
|
|
515
|
-
root: { file: vec8(
|
|
515
|
+
root: { file: [vec8(0xabn), vec8(0xcdn)] },
|
|
516
516
|
})(readBytes('file', 1, 1));
|
|
517
517
|
if (t !== 'ok') {
|
|
518
518
|
throw result;
|
|
@@ -524,7 +524,7 @@ export const proof = {
|
|
|
524
524
|
oversizeChunk: () => {
|
|
525
525
|
const [_, [t, result]] = virtual({
|
|
526
526
|
...emptyState,
|
|
527
|
-
root: { file: vec8(0x2an) },
|
|
527
|
+
root: { file: [vec8(0x2an)] },
|
|
528
528
|
})(readBytes('file', 0, Number(2n ** 32n)));
|
|
529
529
|
if (t !== 'error') {
|
|
530
530
|
throw result;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type Vec } from '../../../types/bit_vec/module.f.ts';
|
|
2
2
|
import { type RunInstance } from '../../mock/module.f.ts';
|
|
3
|
-
import type { Module, NodeOp } from '../module.f.ts';
|
|
3
|
+
import type { Module, NodeOp, NodeProgramOptions } from '../module.f.ts';
|
|
4
4
|
/**
|
|
5
5
|
* In-memory JS module entry. When `import_` is called on the path, the
|
|
6
6
|
* function is invoked and its return value is the module value (with a
|
|
@@ -10,7 +10,7 @@ import type { Module, NodeOp } from '../module.f.ts';
|
|
|
10
10
|
* each import for closures/state.
|
|
11
11
|
*/
|
|
12
12
|
export type JsModule = () => Module;
|
|
13
|
-
export type Entity = Vec | Dir | JsModule;
|
|
13
|
+
export type Entity = readonly Vec[] | Dir | JsModule;
|
|
14
14
|
export type Dir = {
|
|
15
15
|
readonly [name in string]?: Entity;
|
|
16
16
|
};
|
|
@@ -33,3 +33,17 @@ export type State = {
|
|
|
33
33
|
};
|
|
34
34
|
export declare const emptyState: State;
|
|
35
35
|
export declare const virtual: RunInstance<NodeOp, State>;
|
|
36
|
+
/**
|
|
37
|
+
* Safe, inert defaults for every {@link NodeProgramOptions} field, intended for
|
|
38
|
+
* proof files that need to call a program without owning the full literal.
|
|
39
|
+
*
|
|
40
|
+
* Proofs spread-override only what their test cares about:
|
|
41
|
+
*
|
|
42
|
+
* ```ts
|
|
43
|
+
* const opts: NodeProgramOptions = { ...defaultNodeProgramOptions, args }
|
|
44
|
+
* ```
|
|
45
|
+
*
|
|
46
|
+
* Future additions to `NodeProgramOptions` only need a default added here,
|
|
47
|
+
* keeping unrelated proof files from churning.
|
|
48
|
+
*/
|
|
49
|
+
export declare const defaultNodeProgramOptions: NodeProgramOptions;
|