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.
Files changed (46) hide show
  1. package/.github/workflows/bun.yml +1 -1
  2. package/.github/workflows/deno.yml +1 -1
  3. package/com/cpp/test/build.cjs +1 -1
  4. package/com/cpp/{test.f.cjs → testlib.f.cjs} +1 -1
  5. package/com/cs/test/build.cjs +1 -1
  6. package/com/cs/{test.f.cjs → testlib.f.cjs} +1 -1
  7. package/com/rust/test.f.cjs +2 -4
  8. package/com/types/{test.f.cjs → testlib.f.cjs} +0 -0
  9. package/commonjs/build/test.f.cjs +2 -4
  10. package/commonjs/package/dependencies/test.f.cjs +1 -3
  11. package/commonjs/package/test.f.cjs +1 -5
  12. package/commonjs/path/test.f.cjs +158 -170
  13. package/commonjs/test.cjs +52 -61
  14. package/html/test.f.cjs +12 -13
  15. package/json/test.f.cjs +41 -37
  16. package/json/tokenizer/test.f.cjs +238 -296
  17. package/nodejs/version/test.f.cjs +1 -3
  18. package/package.json +2 -2
  19. package/sha2/test.f.cjs +37 -40
  20. package/test.f.cjs +49 -86
  21. package/test.mjs +142 -0
  22. package/text/test.f.cjs +1 -3
  23. package/text/utf16/test.f.cjs +96 -109
  24. package/text/utf8/test.f.cjs +116 -135
  25. package/tsconfig.json +1 -1
  26. package/types/array/test.f.cjs +83 -85
  27. package/types/bigint/test.f.cjs +6 -6
  28. package/types/btree/find/test.f.cjs +2 -2
  29. package/types/btree/remove/test.f.cjs +6 -3
  30. package/types/btree/set/test.f.cjs +372 -370
  31. package/types/btree/test.f.cjs +11 -7
  32. package/types/byteSet/module.f.cjs +2 -4
  33. package/types/byteSet/test.f.cjs +37 -40
  34. package/types/function/compare/module.f.cjs +1 -1
  35. package/types/function/compare/test.f.cjs +1 -3
  36. package/types/function/test.f.cjs +1 -3
  37. package/types/list/test.f.cjs +208 -219
  38. package/types/map/test.f.cjs +57 -57
  39. package/types/nibbleSet/test.f.cjs +37 -40
  40. package/types/number/test.f.cjs +24 -26
  41. package/types/object/test.f.cjs +12 -13
  42. package/types/option/test.f.cjs +1 -3
  43. package/types/range/test.f.cjs +1 -3
  44. package/types/string/test.f.cjs +37 -40
  45. package/types/stringset/test.f.cjs +32 -33
  46. package/denotest.mjs +0 -96
@@ -12,4 +12,4 @@ jobs:
12
12
  steps:
13
13
  - uses: actions/checkout@v2
14
14
  - run: curl https://bun.sh/install | bash
15
- - run: /home/runner/.bun/bin/bun ./test.f.cjs
15
+ - run: /home/runner/.bun/bin/bun ./test.mjs
@@ -14,4 +14,4 @@ jobs:
14
14
  - uses: denoland/setup-deno@v1
15
15
  with:
16
16
  deno-version: v1.x
17
- - run: deno run --allow-read --allow-env ./denotest.mjs
17
+ - run: deno run --allow-read --allow-env --allow-net ./test.mjs
@@ -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('../test.f.cjs').result
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)
@@ -1,5 +1,5 @@
1
1
  const _ = require('./module.f.cjs')
2
- const library = require('../types/test.f.cjs')
2
+ const library = require('../types/testlib.f.cjs')
3
3
  const text = require('../../text/module.f.cjs')
4
4
  const { join } = require('../../types/module.f.cjs').string
5
5
 
@@ -1,6 +1,6 @@
1
1
  const fs = require('node:fs')
2
2
  const cp = require('node:child_process')
3
- const cs = require('../test.f.cjs').result
3
+ const cs = require('../testlib.f.cjs').result
4
4
 
5
5
  fs.writeFileSync('_result.cs', cs)
6
6
  try {
@@ -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/test.f.cjs')
3
+ const library = require('../types/testlib.f.cjs')
4
4
  const { join } = require('../../types/string/module.f.cjs')
5
5
 
6
6
  const f = () =>
@@ -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/test.f.cjs')
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
- require('./dependencies/test.f.cjs')
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 = {}
@@ -12,182 +12,170 @@ const stringify = g => {
12
12
  return json.stringify(identity)(g)
13
13
  }
14
14
 
15
- {
16
- const p = { name: '', version: '' }
17
- const result = _.parseLocal('')('./a')
18
- if (stringify(result) !== '{"external":false,"dir":false,"items":["a"]}') { throw result }
19
- }
20
-
21
- {
22
- const result = _.parseLocal('')('./a/')
23
- if (stringify(result) !== '{"external":false,"dir":true,"items":["a"]}') { throw result }
24
- }
25
-
26
- {
27
- const result = _.parseLocal('')('..')
28
- if (result !== undefined) { throw result }
29
- }
30
-
31
- {
32
- const result = _.parseLocal('a')('')
33
- if (stringify(result) !== '{"external":true,"dir":true,"items":[]}') { throw result }
34
- }
35
-
36
- {
37
- const result = _.parseLocal('')('./a/b/.././c')
38
- if (stringify(result) !== '{"external":false,"dir":false,"items":["a","c"]}') { throw result }
39
- }
40
-
41
- {
42
- const result = _.parseLocal('x/r')('./a/b/.././c')
43
- if (stringify(result) !== '{"external":false,"dir":false,"items":["x","r","a","c"]}') { throw result }
44
- }
45
-
46
- {
47
- const result = _.parseLocal('a')('a/b/.././c')
48
- if (stringify(result) !== '{"external":true,"dir":false,"items":["a","c"]}') { throw result }
49
- }
50
-
51
- {
52
- const result = _.parseLocal('')('./x/..')
53
- if (stringify(result) !== '{"external":false,"dir":true,"items":[]}') { throw result }
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
- const result = stringify(_.parseAndFind(p => at(p)(packages))({ package: '', path: ['a', 'b']})('../c'))
88
- if (result !== '{"id":{"package":"","path":["a","c"]},"source":"return \\"a/c\\""}') { throw result }
89
- }
90
-
91
- {
92
- /** @type {object.Map<package_.Package>} */
93
- const packages = {
94
- '': {
95
- dependency: x => {
96
- const path = `node_modules/${x}`
97
- return at(path)(packages) !== undefined ? path : undefined
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
- file: path => at(path)({
100
- 'index.js': 'return "index.js"',
101
- 'x/index.js': 'return "x/index.js"',
102
- 'x.js': 'return "x.js"',
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
- const result = stringify(_.parseAndFind(p => at(p)(packages))({ package: '', path: ['a', 'b']})('z/a/c'))
112
- if (result !== '{"id":{"package":"node_modules/z","path":["a","c","index.js"]},"source":"return \\"a/c\\""}') {
113
- throw result
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
- const result = stringify(_.parseAndFind(p => at(p)(packages))({ package: '', path: ['a', 'b']})('../..'))
118
- if (result !== '{"id":{"package":"","path":["index.js"]},"source":"return \\"index.js\\""}') { throw result }
119
- }
120
- {
121
- const result = stringify(_.parseAndFind(p => at(p)(packages))({ package: '', path: []})('./x'))
122
- if (result !== '{"id":{"package":"","path":["x.js"]},"source":"return \\"x.js\\""}') { throw result }
123
- }
124
- {
125
- const result = stringify(_.parseAndFind(p => at(p)(packages))({ package: '', path: []})('./x.js'))
126
- if (result !== '{"id":{"package":"","path":["x.js"]},"source":"return \\"x.js\\""}') { throw result }
127
- }
128
- {
129
- const result = stringify(_.parseAndFind(p => at(p)(packages))({ package: '', path: []})('./x/'))
130
- if (result !== '{"id":{"package":"","path":["x","index.js"]},"source":"return \\"x/index.js\\""}') { throw result }
131
- }
132
- {
133
- const result = stringify(_.parseAndFind(p => at(p)(packages))({ package: '', path: ['x', 'a']})('../'))
134
- if (result !== '{"id":{"package":"","path":["x","index.js"]},"source":"return \\"x/index.js\\""}') { throw result }
135
- }
136
- {
137
- const result = stringify(_.parseAndFind(p => at(p)(packages))({ package: '', path: ['x', 'a']})('..'))
138
- if (result !== '{"id":{"package":"","path":["x","index.js"]},"source":"return \\"x/index.js\\""}') { throw result }
139
- }
140
- }
141
-
142
- {
143
- /** @type {object.Map<package_.Package>} */
144
- const packages = {
145
- '': {
146
- dependency: x => {
147
- const path = `node_modules/${x}`
148
- return at(path)(packages) !== undefined ? path : undefined
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
- file: todo
151
- },
152
- 'node_modules/z/a': {
153
- dependency: () => todo(),
154
- file: path => at(path)({
155
- 'c/index.js': 'return "c/index.js"',
156
- 'c.js': 'return "c.js"'
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
- const result = stringify(_.parseAndFind(p => at(p)(packages))({ package: '', path: ['a', 'b']})('z/a/c'))
162
- if (result !== '{"id":{"package":"node_modules/z/a","path":["c.js"]},"source":"return \\"c.js\\""}') { throw result }
163
- }
164
- {
165
- const result = stringify(_.parseAndFind(p => at(p)(packages))({ package: '', path: ['a', 'b']})('z/a/c/'))
166
- if (result !== '{"id":{"package":"node_modules/z/a","path":["c","index.js"]},"source":"return \\"c/index.js\\""}') { throw result }
167
- }
168
- }
169
-
170
- {
171
- /** @type {object.Map<package_.Package>} */
172
- const packages = {
173
- '': {
174
- dependency: x => {
175
- const path = `node_modules/${x}`
176
- return at(path)(packages) !== undefined ? path : undefined
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
- file: todo
179
- },
180
- 'node_modules/z/a/c': {
181
- dependency: () => todo(),
182
- file: path => at(path)({
183
- '': 'throw',
184
- '.js': 'throw',
185
- 'index.js': 'return "a/c"'
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
- const result = stringify(_.parseAndFind(p => at(p)(packages))({package: '', path: ['a', 'b']})('z/a/c'))
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
- // ok:
5
- {
6
- const source = 'module.exports = "Hello world!"'
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] !== 179) { throw result }
58
- info = newInfo
59
- }
60
-
61
- {
62
- const source = 'module.exports = require("x") + 42'
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
- if (infox !== 1) { throw info }
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
- const r = _.htmlToString(['html', []])
5
- if (r !== '<!DOCTYPE html><html></html>') { throw r }
6
- }
7
-
8
- {
9
- /** @type {_.Element} */
10
- const x = ['div', {}, ['<div>&amp;</div>', ['a', { href: 'hello"' }, []]]]
11
- const s = _.htmlToString(x)
12
- if (s !== '<!DOCTYPE html><div>&lt;div&gt;&amp;amp;&lt;/div&gt;<a href="hello&quot;"></a></div>') { throw s }
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>&amp;</div>', ['a', { href: 'hello"' }, []]]]
11
+ const s = _.htmlToString(x)
12
+ if (s !== '<!DOCTYPE html><div>&lt;div&gt;&amp;amp;&lt;/div&gt;<a href="hello&quot;"></a></div>') { throw s }
13
+ }
14
+ }