functionalscript 0.0.422 → 0.0.425
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/.github/workflows/bun.yml +1 -1
- package/.github/workflows/deno.yml +1 -1
- package/com/cpp/test/build.cjs +1 -1
- package/com/cpp/{test.f.cjs → testlib.f.cjs} +1 -1
- package/com/cs/test/build.cjs +1 -1
- package/com/cs/{test.f.cjs → testlib.f.cjs} +1 -1
- package/com/rust/test.f.cjs +2 -4
- package/com/types/{test.f.cjs → testlib.f.cjs} +0 -0
- package/commonjs/build/test.f.cjs +2 -4
- package/commonjs/package/dependencies/test.f.cjs +1 -3
- package/commonjs/package/test.f.cjs +1 -5
- package/commonjs/path/test.f.cjs +158 -170
- package/commonjs/test.cjs +52 -61
- package/html/test.f.cjs +12 -13
- package/json/test.f.cjs +41 -37
- package/json/tokenizer/test.f.cjs +238 -296
- package/nodejs/version/test.f.cjs +1 -3
- package/package.json +2 -2
- package/sha2/test.f.cjs +37 -40
- package/test.f.cjs +49 -86
- package/test.mjs +142 -0
- package/text/test.f.cjs +1 -3
- package/text/utf16/test.f.cjs +96 -109
- package/text/utf8/test.f.cjs +116 -135
- package/tsconfig.json +1 -1
- package/types/array/test.f.cjs +83 -85
- package/types/bigint/test.f.cjs +6 -6
- package/types/btree/find/test.f.cjs +2 -2
- package/types/btree/remove/test.f.cjs +6 -3
- package/types/btree/set/test.f.cjs +372 -370
- package/types/btree/test.f.cjs +11 -7
- package/types/byteSet/module.f.cjs +2 -4
- package/types/byteSet/test.f.cjs +37 -40
- package/types/function/compare/module.f.cjs +1 -1
- package/types/function/compare/test.f.cjs +1 -3
- package/types/function/test.f.cjs +1 -3
- package/types/list/test.f.cjs +208 -219
- package/types/map/test.f.cjs +57 -57
- package/types/nibbleSet/test.f.cjs +37 -40
- package/types/number/test.f.cjs +24 -26
- package/types/object/test.f.cjs +12 -13
- package/types/option/test.f.cjs +1 -3
- package/types/range/test.f.cjs +1 -3
- package/types/string/test.f.cjs +37 -40
- package/types/stringset/test.f.cjs +32 -33
- package/denotest.mjs +0 -96
package/com/cpp/test/build.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const fs = require('node:fs')
|
|
2
2
|
const cp = require('node:child_process')
|
|
3
3
|
const os = require('node:os');
|
|
4
|
-
const cpp = require('../
|
|
4
|
+
const cpp = require('../testlib.f.cjs').result
|
|
5
5
|
const { string: { join }, list: { flat } } = require('../../../types/module.f.cjs')
|
|
6
6
|
|
|
7
7
|
fs.writeFileSync('_result.hpp', cpp)
|
package/com/cs/test/build.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const _ = require('./module.f.cjs')
|
|
2
2
|
const text = require('../../text/module.f.cjs')
|
|
3
|
-
const library = require('../types/
|
|
3
|
+
const library = require('../types/testlib.f.cjs')
|
|
4
4
|
const { join } = require('../../types/string/module.f.cjs')
|
|
5
5
|
|
|
6
6
|
const f = () =>
|
package/com/rust/test.f.cjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
const { rust } = require('./module.f.cjs')
|
|
2
2
|
const { flat } = require('../../text/module.f.cjs')
|
|
3
3
|
const { join } = require('../../types/string/module.f.cjs')
|
|
4
|
-
const library = require('../types/
|
|
4
|
+
const library = require('../types/testlib.f.cjs')
|
|
5
5
|
|
|
6
|
-
{
|
|
6
|
+
module.exports = () => {
|
|
7
7
|
const e =
|
|
8
8
|
'#![allow(non_snake_case)]\n' +
|
|
9
9
|
'#[repr(C)]\n' +
|
|
@@ -74,5 +74,3 @@ const library = require('../types/test.f.cjs')
|
|
|
74
74
|
const r = join('\n')(flat(' ')(rust(library)))
|
|
75
75
|
if (r !== e) { throw [e, r] }
|
|
76
76
|
}
|
|
77
|
-
|
|
78
|
-
module.exports = {}
|
|
File without changes
|
|
@@ -69,7 +69,7 @@ const getOrBuild = _.getOrBuild
|
|
|
69
69
|
(packageGet)
|
|
70
70
|
(/** @type {module_.MapInterface<map.Map<module_.State>>} */(map))
|
|
71
71
|
|
|
72
|
-
{
|
|
72
|
+
module.exports = () => {
|
|
73
73
|
let [r, m] = getOrBuild({ package: '', path: ['index.js'] })(undefined)
|
|
74
74
|
if (JSON.stringify(r) !==
|
|
75
75
|
'["ok",{"exports":":index.js","requireMap":{"./a/":"/a/index.js","./b":"/b.js","x/r":"/node_modules/x/r.js"}}]'
|
|
@@ -82,12 +82,10 @@ const getOrBuild = _.getOrBuild
|
|
|
82
82
|
) {
|
|
83
83
|
throw r
|
|
84
84
|
}
|
|
85
|
-
[r, m] = getOrBuild({ package: '', path: ['c.js']})(m)
|
|
85
|
+
[r, m] = getOrBuild({ package: '', path: ['c.js'] })(m)
|
|
86
86
|
if (JSON.stringify(r) !==
|
|
87
87
|
'["error",["file not found"]]'
|
|
88
88
|
) {
|
|
89
89
|
throw r
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
|
-
|
|
93
|
-
module.exports = {}
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
const _ = require('./module.f.cjs')
|
|
2
2
|
|
|
3
|
-
{
|
|
3
|
+
module.exports = () => {
|
|
4
4
|
if (!_.isDependenciesJson(undefined)) { throw 'error' }
|
|
5
5
|
if (_.isDependenciesJson(null)) { throw 'error' }
|
|
6
6
|
if (!_.isDependenciesJson({})) { throw 'error' }
|
|
7
7
|
if (!_.isDependenciesJson({'a':'b'})) { throw 'error' }
|
|
8
8
|
if (_.isDependenciesJson({ 'a': 12 })) { throw 'error' }
|
|
9
9
|
}
|
|
10
|
-
|
|
11
|
-
module.exports = {}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
const _ = require('./module.f.cjs')
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
{
|
|
3
|
+
module.exports = () => {
|
|
6
4
|
if (_.isPackageJson(null)) { throw 'error' }
|
|
7
5
|
if (_.isPackageJson({})) { throw 'error' }
|
|
8
6
|
if (_.isPackageJson({name:'x',version:12})) { throw 'error' }
|
|
@@ -12,5 +10,3 @@ require('./dependencies/test.f.cjs')
|
|
|
12
10
|
if (_.isPackageJson({name:'b', version: "", dependencies: { x: 12} })) { throw 'error' }
|
|
13
11
|
if (!_.isPackageJson({name:'c', version: "", dependencies: { x: "12" } })) { throw 'error' }
|
|
14
12
|
}
|
|
15
|
-
|
|
16
|
-
module.exports = {}
|
package/commonjs/path/test.f.cjs
CHANGED
|
@@ -12,182 +12,170 @@ const stringify = g => {
|
|
|
12
12
|
return json.stringify(identity)(g)
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
{
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
{
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
{
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
{
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
{
|
|
57
|
-
if (_.parseGlobal(() => undefined)(false)(['a', 'b']) !== undefined) { throw 'error' }
|
|
58
|
-
if (_.parseGlobal(() => undefined)(false)(['b']) !== undefined) { throw 'error' }
|
|
59
|
-
if (_.parseGlobal(d => at(d)({ b: 'x' }))(false)(['d']) !== undefined) { throw 'error' }
|
|
60
|
-
{
|
|
61
|
-
const result = stringify(_.parseGlobal(d => at(d)({ b: 'x' }))(false)(['b']))
|
|
62
|
-
if (result !== '{"package":"x","items":[],"dir":false}') { throw result }
|
|
63
|
-
}
|
|
64
|
-
if (_.parseGlobal(d => at(d)({ 'b/r': 'x' }))(false)(['b']) !== undefined) { throw 'error' }
|
|
65
|
-
{
|
|
66
|
-
const result = stringify(_.parseGlobal(d => at(d)({ 'b/r': 'x' }))(false)(['b', 'r']))
|
|
67
|
-
if (result !== '{"package":"x","items":[],"dir":false}') { throw result }
|
|
68
|
-
}
|
|
69
|
-
{
|
|
70
|
-
const result = stringify(_.parseGlobal(d => at(d)({ 'b/r': 'x' }))(false)(['b', 'r', 'd', 't']))
|
|
71
|
-
if (result !== '{"package":"x","items":["d","t"],"dir":false}') { throw result }
|
|
72
|
-
}
|
|
73
|
-
{
|
|
74
|
-
const result = stringify(_.parseGlobal(d => at(d)({ 'b/r': 'x' }))(true)(['b', 'r', 'd', 't']))
|
|
75
|
-
if (result !== '{"package":"x","items":["d","t"],"dir":true}') { throw result }
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
{
|
|
80
|
-
/** @type {object.Map<package_.Package>} */
|
|
81
|
-
const packages = {
|
|
82
|
-
'': {
|
|
83
|
-
dependency: () => todo(),
|
|
84
|
-
file: path => at(path)({ 'a/c': 'return "a/c"' }),
|
|
15
|
+
module.exports = [
|
|
16
|
+
() => {
|
|
17
|
+
const p = { name: '', version: '' }
|
|
18
|
+
const result = _.parseLocal('')('./a')
|
|
19
|
+
if (stringify(result) !== '{"external":false,"dir":false,"items":["a"]}') { throw result }
|
|
20
|
+
},
|
|
21
|
+
() => {
|
|
22
|
+
const result = _.parseLocal('')('./a/')
|
|
23
|
+
if (stringify(result) !== '{"external":false,"dir":true,"items":["a"]}') { throw result }
|
|
24
|
+
},
|
|
25
|
+
() => {
|
|
26
|
+
const result = _.parseLocal('')('..')
|
|
27
|
+
if (result !== undefined) { throw result }
|
|
28
|
+
},
|
|
29
|
+
() => {
|
|
30
|
+
const result = _.parseLocal('a')('')
|
|
31
|
+
if (stringify(result) !== '{"external":true,"dir":true,"items":[]}') { throw result }
|
|
32
|
+
},
|
|
33
|
+
() => {
|
|
34
|
+
const result = _.parseLocal('')('./a/b/.././c')
|
|
35
|
+
if (stringify(result) !== '{"external":false,"dir":false,"items":["a","c"]}') { throw result }
|
|
36
|
+
},
|
|
37
|
+
() => {
|
|
38
|
+
const result = _.parseLocal('x/r')('./a/b/.././c')
|
|
39
|
+
if (stringify(result) !== '{"external":false,"dir":false,"items":["x","r","a","c"]}') { throw result }
|
|
40
|
+
},
|
|
41
|
+
() => {
|
|
42
|
+
const result = _.parseLocal('a')('a/b/.././c')
|
|
43
|
+
if (stringify(result) !== '{"external":true,"dir":false,"items":["a","c"]}') { throw result }
|
|
44
|
+
},
|
|
45
|
+
() => {
|
|
46
|
+
const result = _.parseLocal('')('./x/..')
|
|
47
|
+
if (stringify(result) !== '{"external":false,"dir":true,"items":[]}') { throw result }
|
|
48
|
+
},
|
|
49
|
+
() => {
|
|
50
|
+
if (_.parseGlobal(() => undefined)(false)(['a', 'b']) !== undefined) { throw 'error' }
|
|
51
|
+
if (_.parseGlobal(() => undefined)(false)(['b']) !== undefined) { throw 'error' }
|
|
52
|
+
if (_.parseGlobal(d => at(d)({ b: 'x' }))(false)(['d']) !== undefined) { throw 'error' }
|
|
53
|
+
{
|
|
54
|
+
const result = stringify(_.parseGlobal(d => at(d)({ b: 'x' }))(false)(['b']))
|
|
55
|
+
if (result !== '{"package":"x","items":[],"dir":false}') { throw result }
|
|
85
56
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
{
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
57
|
+
if (_.parseGlobal(d => at(d)({ 'b/r': 'x' }))(false)(['b']) !== undefined) { throw 'error' }
|
|
58
|
+
{
|
|
59
|
+
const result = stringify(_.parseGlobal(d => at(d)({ 'b/r': 'x' }))(false)(['b', 'r']))
|
|
60
|
+
if (result !== '{"package":"x","items":[],"dir":false}') { throw result }
|
|
61
|
+
}
|
|
62
|
+
{
|
|
63
|
+
const result = stringify(_.parseGlobal(d => at(d)({ 'b/r': 'x' }))(false)(['b', 'r', 'd', 't']))
|
|
64
|
+
if (result !== '{"package":"x","items":["d","t"],"dir":false}') { throw result }
|
|
65
|
+
}
|
|
66
|
+
{
|
|
67
|
+
const result = stringify(_.parseGlobal(d => at(d)({ 'b/r': 'x' }))(true)(['b', 'r', 'd', 't']))
|
|
68
|
+
if (result !== '{"package":"x","items":["d","t"],"dir":true}') { throw result }
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
() => {
|
|
72
|
+
/** @type {object.Map<package_.Package>} */
|
|
73
|
+
const packages = {
|
|
74
|
+
'': {
|
|
75
|
+
dependency: () => todo(),
|
|
76
|
+
file: path => at(path)({ 'a/c': 'return "a/c"' }),
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
const result = stringify(_.parseAndFind(p => at(p)(packages))({ package: '', path: ['a', 'b'] })('../c'))
|
|
80
|
+
if (result !== '{"id":{"package":"","path":["a","c"]},"source":"return \\"a/c\\""}') { throw result }
|
|
81
|
+
},
|
|
82
|
+
() => {
|
|
83
|
+
/** @type {object.Map<package_.Package>} */
|
|
84
|
+
const packages = {
|
|
85
|
+
'': {
|
|
86
|
+
dependency: x => {
|
|
87
|
+
const path = `node_modules/${x}`
|
|
88
|
+
return at(path)(packages) !== undefined ? path : undefined
|
|
89
|
+
},
|
|
90
|
+
file: path => at(path)({
|
|
91
|
+
'index.js': 'return "index.js"',
|
|
92
|
+
'x/index.js': 'return "x/index.js"',
|
|
93
|
+
'x.js': 'return "x.js"',
|
|
94
|
+
})
|
|
98
95
|
},
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
'
|
|
102
|
-
|
|
103
|
-
})
|
|
104
|
-
},
|
|
105
|
-
'node_modules/z': {
|
|
106
|
-
dependency: () => todo(),
|
|
107
|
-
file: path => at(path)({ 'a/c/index.js': 'return "a/c"' }),
|
|
96
|
+
'node_modules/z': {
|
|
97
|
+
dependency: () => todo(),
|
|
98
|
+
file: path => at(path)({ 'a/c/index.js': 'return "a/c"' }),
|
|
99
|
+
}
|
|
108
100
|
}
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
101
|
+
{
|
|
102
|
+
const result = stringify(_.parseAndFind(p => at(p)(packages))({ package: '', path: ['a', 'b'] })('z/a/c'))
|
|
103
|
+
if (result !== '{"id":{"package":"node_modules/z","path":["a","c","index.js"]},"source":"return \\"a/c\\""}') {
|
|
104
|
+
throw result
|
|
105
|
+
}
|
|
114
106
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
{
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
107
|
+
{
|
|
108
|
+
const result = stringify(_.parseAndFind(p => at(p)(packages))({ package: '', path: ['a', 'b'] })('../..'))
|
|
109
|
+
if (result !== '{"id":{"package":"","path":["index.js"]},"source":"return \\"index.js\\""}') { throw result }
|
|
110
|
+
}
|
|
111
|
+
{
|
|
112
|
+
const result = stringify(_.parseAndFind(p => at(p)(packages))({ package: '', path: [] })('./x'))
|
|
113
|
+
if (result !== '{"id":{"package":"","path":["x.js"]},"source":"return \\"x.js\\""}') { throw result }
|
|
114
|
+
}
|
|
115
|
+
{
|
|
116
|
+
const result = stringify(_.parseAndFind(p => at(p)(packages))({ package: '', path: [] })('./x.js'))
|
|
117
|
+
if (result !== '{"id":{"package":"","path":["x.js"]},"source":"return \\"x.js\\""}') { throw result }
|
|
118
|
+
}
|
|
119
|
+
{
|
|
120
|
+
const result = stringify(_.parseAndFind(p => at(p)(packages))({ package: '', path: [] })('./x/'))
|
|
121
|
+
if (result !== '{"id":{"package":"","path":["x","index.js"]},"source":"return \\"x/index.js\\""}') { throw result }
|
|
122
|
+
}
|
|
123
|
+
{
|
|
124
|
+
const result = stringify(_.parseAndFind(p => at(p)(packages))({ package: '', path: ['x', 'a'] })('../'))
|
|
125
|
+
if (result !== '{"id":{"package":"","path":["x","index.js"]},"source":"return \\"x/index.js\\""}') { throw result }
|
|
126
|
+
}
|
|
127
|
+
{
|
|
128
|
+
const result = stringify(_.parseAndFind(p => at(p)(packages))({ package: '', path: ['x', 'a'] })('..'))
|
|
129
|
+
if (result !== '{"id":{"package":"","path":["x","index.js"]},"source":"return \\"x/index.js\\""}') { throw result }
|
|
130
|
+
}
|
|
131
|
+
},
|
|
132
|
+
() => {
|
|
133
|
+
/** @type {object.Map<package_.Package>} */
|
|
134
|
+
const packages = {
|
|
135
|
+
'': {
|
|
136
|
+
dependency: x => {
|
|
137
|
+
const path = `node_modules/${x}`
|
|
138
|
+
return at(path)(packages) !== undefined ? path : undefined
|
|
139
|
+
},
|
|
140
|
+
file: todo
|
|
149
141
|
},
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
}),
|
|
142
|
+
'node_modules/z/a': {
|
|
143
|
+
dependency: () => todo(),
|
|
144
|
+
file: path => at(path)({
|
|
145
|
+
'c/index.js': 'return "c/index.js"',
|
|
146
|
+
'c.js': 'return "c.js"'
|
|
147
|
+
}),
|
|
148
|
+
}
|
|
158
149
|
}
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
{
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
150
|
+
{
|
|
151
|
+
const result = stringify(_.parseAndFind(p => at(p)(packages))({ package: '', path: ['a', 'b'] })('z/a/c'))
|
|
152
|
+
if (result !== '{"id":{"package":"node_modules/z/a","path":["c.js"]},"source":"return \\"c.js\\""}') { throw result }
|
|
153
|
+
}
|
|
154
|
+
{
|
|
155
|
+
const result = stringify(_.parseAndFind(p => at(p)(packages))({ package: '', path: ['a', 'b'] })('z/a/c/'))
|
|
156
|
+
if (result !== '{"id":{"package":"node_modules/z/a","path":["c","index.js"]},"source":"return \\"c/index.js\\""}') { throw result }
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
() => {
|
|
160
|
+
/** @type {object.Map<package_.Package>} */
|
|
161
|
+
const packages = {
|
|
162
|
+
'': {
|
|
163
|
+
dependency: x => {
|
|
164
|
+
const path = `node_modules/${x}`
|
|
165
|
+
return at(path)(packages) !== undefined ? path : undefined
|
|
166
|
+
},
|
|
167
|
+
file: todo
|
|
177
168
|
},
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
}),
|
|
169
|
+
'node_modules/z/a/c': {
|
|
170
|
+
dependency: () => todo(),
|
|
171
|
+
file: path => at(path)({
|
|
172
|
+
'': 'throw',
|
|
173
|
+
'.js': 'throw',
|
|
174
|
+
'index.js': 'return "a/c"'
|
|
175
|
+
}),
|
|
176
|
+
}
|
|
187
177
|
}
|
|
178
|
+
const result = stringify(_.parseAndFind(p => at(p)(packages))({ package: '', path: ['a', 'b'] })('z/a/c'))
|
|
179
|
+
if (result !== '{"id":{"package":"node_modules/z/a/c","path":["index.js"]},"source":"return \\"a/c\\""}') { throw result }
|
|
188
180
|
}
|
|
189
|
-
|
|
190
|
-
if (result !== '{"id":{"package":"node_modules/z/a/c","path":["index.js"]},"source":"return \\"a/c\\""}') { throw result }
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
module.exports = {}
|
|
181
|
+
]
|
package/commonjs/test.cjs
CHANGED
|
@@ -1,72 +1,63 @@
|
|
|
1
1
|
const _ = require('./module.cjs')
|
|
2
2
|
const run = require('./module/function/module.f.cjs')
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
{
|
|
6
|
-
|
|
7
|
-
const m = _.compile(source)
|
|
8
|
-
if (m[0] !== 'ok') { throw m }
|
|
9
|
-
const [result] = m[1](() => { throw 0 })(undefined)
|
|
10
|
-
if (result[0] !== 'ok') { throw result }
|
|
11
|
-
if (result[1] !== 'Hello world!') { throw result }
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
// compilation error:
|
|
15
|
-
{
|
|
16
|
-
const source = '+'
|
|
17
|
-
const m = _.compile(source)
|
|
18
|
-
if (m[0] !== 'error') { throw m }
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// compilation error with "use strict;":
|
|
22
|
-
{
|
|
23
|
-
const source = 'const x = 04'
|
|
24
|
-
const m = _.compile(source)
|
|
25
|
-
if (m[0] !== 'error') { throw m }
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// runtime error:
|
|
29
|
-
{
|
|
30
|
-
const source = 'a = 5'
|
|
31
|
-
const m = _.compile(source)
|
|
32
|
-
if (m[0] !== 'ok') { throw m }
|
|
33
|
-
const [result] = m[1](() => { throw 0 })(undefined)
|
|
34
|
-
if (result[0] !== 'error') { throw result }
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
//
|
|
38
|
-
{
|
|
39
|
-
const depSource = 'module.exports = 137'
|
|
40
|
-
const d = _.compile(depSource)
|
|
41
|
-
if (d[0] !== 'ok') { throw d }
|
|
42
|
-
|
|
43
|
-
/** @type {run.Require<number>} */
|
|
44
|
-
const req = path => prior => {
|
|
45
|
-
if (path !== 'm') { throw path }
|
|
46
|
-
return d[1](req)(prior + 1)
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
let info = 0
|
|
50
|
-
{
|
|
51
|
-
const source = 'module.exports = require("m") + 42'
|
|
4
|
+
module.exports = {
|
|
5
|
+
ok: () => {
|
|
6
|
+
const source = 'module.exports = "Hello world!"'
|
|
52
7
|
const m = _.compile(source)
|
|
53
8
|
if (m[0] !== 'ok') { throw m }
|
|
54
|
-
|
|
55
|
-
const [result, newInfo] = m[1](req)(info)
|
|
9
|
+
const [result] = m[1](() => { throw 0 })(undefined)
|
|
56
10
|
if (result[0] !== 'ok') { throw result }
|
|
57
|
-
if (result[1] !==
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
11
|
+
if (result[1] !== 'Hello world!') { throw result }
|
|
12
|
+
},
|
|
13
|
+
compilationError: () => {
|
|
14
|
+
const source = '+'
|
|
15
|
+
const m = _.compile(source)
|
|
16
|
+
if (m[0] !== 'error') { throw m }
|
|
17
|
+
},
|
|
18
|
+
compilationErrorStrict: () => {
|
|
19
|
+
const source = 'const x = 04'
|
|
20
|
+
const m = _.compile(source)
|
|
21
|
+
if (m[0] !== 'error') { throw m }
|
|
22
|
+
},
|
|
23
|
+
runtimeError: () => {
|
|
24
|
+
const source = 'a = 5'
|
|
63
25
|
const m = _.compile(source)
|
|
64
26
|
if (m[0] !== 'ok') { throw m }
|
|
65
|
-
|
|
66
|
-
const [result, infox] = m[1](req)(info)
|
|
27
|
+
const [result] = m[1](() => { throw 0 })(undefined)
|
|
67
28
|
if (result[0] !== 'error') { throw result }
|
|
68
|
-
|
|
29
|
+
},
|
|
30
|
+
test: () => {
|
|
31
|
+
const depSource = 'module.exports = 137'
|
|
32
|
+
const d = _.compile(depSource)
|
|
33
|
+
if (d[0] !== 'ok') { throw d }
|
|
34
|
+
|
|
35
|
+
/** @type {run.Require<number>} */
|
|
36
|
+
const req = path => prior => {
|
|
37
|
+
if (path !== 'm') { throw path }
|
|
38
|
+
return d[1](req)(prior + 1)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
let info = 0
|
|
42
|
+
{
|
|
43
|
+
const source = 'module.exports = require("m") + 42'
|
|
44
|
+
const m = _.compile(source)
|
|
45
|
+
if (m[0] !== 'ok') { throw m }
|
|
46
|
+
|
|
47
|
+
const [result, newInfo] = m[1](req)(info)
|
|
48
|
+
if (result[0] !== 'ok') { throw result }
|
|
49
|
+
if (result[1] !== 179) { throw result }
|
|
50
|
+
info = newInfo
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
{
|
|
54
|
+
const source = 'module.exports = require("x") + 42'
|
|
55
|
+
const m = _.compile(source)
|
|
56
|
+
if (m[0] !== 'ok') { throw m }
|
|
57
|
+
|
|
58
|
+
const [result, infox] = m[1](req)(info)
|
|
59
|
+
if (result[0] !== 'error') { throw result }
|
|
60
|
+
if (infox !== 1) { throw info }
|
|
61
|
+
}
|
|
69
62
|
}
|
|
70
63
|
}
|
|
71
|
-
|
|
72
|
-
module.exports = {}
|
package/html/test.f.cjs
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
1
|
const _ = require('./module.f.cjs')
|
|
2
2
|
|
|
3
|
-
{
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
{
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
module.exports = {}
|
|
3
|
+
module.exports = {
|
|
4
|
+
empty: () => {
|
|
5
|
+
const r = _.htmlToString(['html', []])
|
|
6
|
+
if (r !== '<!DOCTYPE html><html></html>') { throw r }
|
|
7
|
+
},
|
|
8
|
+
some: () => {
|
|
9
|
+
/** @type {_.Element} */
|
|
10
|
+
const x = ['div', {}, ['<div>&</div>', ['a', { href: 'hello"' }, []]]]
|
|
11
|
+
const s = _.htmlToString(x)
|
|
12
|
+
if (s !== '<!DOCTYPE html><div><div>&amp;</div><a href="hello""></a></div>') { throw s }
|
|
13
|
+
}
|
|
14
|
+
}
|