functionalscript 0.0.423 → 0.0.426
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/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 +1 -1
- package/sha2/test.f.cjs +37 -40
- package/test.f.cjs +49 -86
- package/test.mjs +102 -28
- package/text/test.f.cjs +1 -3
- package/text/utf16/test.f.cjs +96 -109
- package/text/utf8/test.f.cjs +116 -135
- 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
|
@@ -77,7 +77,7 @@ const buffer = s => ({
|
|
|
77
77
|
toString: () => s
|
|
78
78
|
})
|
|
79
79
|
|
|
80
|
-
{
|
|
80
|
+
module.exports = () => {
|
|
81
81
|
/** @type {_.Node<string>} */
|
|
82
82
|
const node = {
|
|
83
83
|
child_process: { execSync: () => buffer("123\n456\n") },
|
|
@@ -89,5 +89,3 @@ const buffer = s => ({
|
|
|
89
89
|
const v = _.version(node)
|
|
90
90
|
if (v !== e) { throw [v, e] }
|
|
91
91
|
}
|
|
92
|
-
|
|
93
|
-
module.exports = {}
|
package/package.json
CHANGED
package/sha2/test.f.cjs
CHANGED
|
@@ -32,45 +32,42 @@ const stringify = a => json.stringify(sort)(a)
|
|
|
32
32
|
// console.log(result.map(toHexString))
|
|
33
33
|
// }
|
|
34
34
|
|
|
35
|
-
{
|
|
36
|
-
const hash = _.computeSha256([])(0)
|
|
37
|
-
const result = stringify(hash.map(toHexString))
|
|
38
|
-
if (result !== '["e3b0c442","98fc1c14","9afbf4c8","996fb924","27ae41e4","649b934c","a495991b","7852b855"]') { throw result }
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
{
|
|
42
|
-
const hash = _.computeSha224([])(0)
|
|
43
|
-
const result = stringify(hash.map(toHexString))
|
|
44
|
-
if (result !== '["d14a028c","2a3a2bc9","476102bb","288234c4","15a2b01f","828ea62a","c5b3e42f","bdd387cb"]') { throw result }
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
{
|
|
48
|
-
//[0x68656C6C, 0x6F20776F, 0x726C6400] represents phrase 'hello world'
|
|
49
|
-
const hash = _.computeSha256([0x68656C6C, 0x6F20776F, 0x726C6400])(88)
|
|
50
|
-
const result = stringify(hash.map(toHexString))
|
|
51
|
-
if (result !== '["b94d27b9","934d3e08","a52e52d7","da7dabfa","c484efe3","7a5380ee","9088f7ac","e2efcde9"]') { throw result }
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
{
|
|
55
|
-
//[0x68656C6C, 0x6F20776F, 0x726C6488] represents phrase 'hello world' with 1's at the end
|
|
56
|
-
const hash = _.computeSha256([0x68656C6C, 0x6F20776F, 0x726C64FF])(88)
|
|
57
|
-
const result = stringify(hash.map(toHexString))
|
|
58
|
-
if (result !== '["b94d27b9","934d3e08","a52e52d7","da7dabfa","c484efe3","7a5380ee","9088f7ac","e2efcde9"]') { throw result }
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
{
|
|
62
|
-
const input = Array(8).fill(0x31313131)
|
|
63
|
-
const result = _.computeSha256(input)(256)
|
|
64
|
-
if (toU32(result[0]) !== 0x8a83665f) { throw result[0] }
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
{
|
|
68
|
-
const input = Array(16).fill(0x31313131)
|
|
69
|
-
const hash = _.computeSha256(input)(512)
|
|
70
|
-
const result = stringify(hash.map(toHexString))
|
|
71
|
-
if (result !== '["3138bb9b","c78df27c","473ecfd1","410f7bd4","5ebac1f5","9cf3ff9c","fe4db77a","ab7aedd3"]') { throw result }
|
|
72
|
-
}
|
|
73
|
-
|
|
74
35
|
module.exports = {
|
|
75
|
-
|
|
36
|
+
empty: {
|
|
37
|
+
sha256: () => {
|
|
38
|
+
const hash = _.computeSha256([])(0)
|
|
39
|
+
const result = stringify(hash.map(toHexString))
|
|
40
|
+
if (result !== '["e3b0c442","98fc1c14","9afbf4c8","996fb924","27ae41e4","649b934c","a495991b","7852b855"]') { throw result }
|
|
41
|
+
},
|
|
42
|
+
sha224: () => {
|
|
43
|
+
const hash = _.computeSha224([])(0)
|
|
44
|
+
const result = stringify(hash.map(toHexString))
|
|
45
|
+
if (result !== '["d14a028c","2a3a2bc9","476102bb","288234c4","15a2b01f","828ea62a","c5b3e42f","bdd387cb"]') { throw result }
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
sha256: [
|
|
49
|
+
() => {
|
|
50
|
+
//[0x68656C6C, 0x6F20776F, 0x726C6400] represents phrase 'hello world'
|
|
51
|
+
const hash = _.computeSha256([0x68656C6C, 0x6F20776F, 0x726C6400])(88)
|
|
52
|
+
const result = stringify(hash.map(toHexString))
|
|
53
|
+
if (result !== '["b94d27b9","934d3e08","a52e52d7","da7dabfa","c484efe3","7a5380ee","9088f7ac","e2efcde9"]') { throw result }
|
|
54
|
+
},
|
|
55
|
+
() => {
|
|
56
|
+
//[0x68656C6C, 0x6F20776F, 0x726C6488] represents phrase 'hello world' with 1's at the end
|
|
57
|
+
const hash = _.computeSha256([0x68656C6C, 0x6F20776F, 0x726C64FF])(88)
|
|
58
|
+
const result = stringify(hash.map(toHexString))
|
|
59
|
+
if (result !== '["b94d27b9","934d3e08","a52e52d7","da7dabfa","c484efe3","7a5380ee","9088f7ac","e2efcde9"]') { throw result }
|
|
60
|
+
},
|
|
61
|
+
() => {
|
|
62
|
+
const input = Array(8).fill(0x31313131)
|
|
63
|
+
const result = _.computeSha256(input)(256)
|
|
64
|
+
if (toU32(result[0]) !== 0x8a83665f) { throw result[0] }
|
|
65
|
+
},
|
|
66
|
+
() => {
|
|
67
|
+
const input = Array(16).fill(0x31313131)
|
|
68
|
+
const hash = _.computeSha256(input)(512)
|
|
69
|
+
const result = stringify(hash.map(toHexString))
|
|
70
|
+
if (result !== '["3138bb9b","c78df27c","473ecfd1","410f7bd4","5ebac1f5","9cf3ff9c","fe4db77a","ab7aedd3"]') { throw result }
|
|
71
|
+
}
|
|
72
|
+
]
|
|
76
73
|
}
|
package/test.f.cjs
CHANGED
|
@@ -1,95 +1,58 @@
|
|
|
1
1
|
const i = require('./module.f.cjs')
|
|
2
2
|
|
|
3
|
-
require('./types/list/test.f.cjs')
|
|
4
|
-
require('./types/number/test.f.cjs')
|
|
5
|
-
require('./types/bigint/module.f.cjs')
|
|
6
|
-
require('./types/array/test.f.cjs')
|
|
7
|
-
require('./types/btree/test.f.cjs')
|
|
8
|
-
require('./types/byteSet/test.f.cjs')
|
|
9
|
-
require('./types/nibbleSet/test.f.cjs')
|
|
10
|
-
require('./sha2/test.f.cjs')
|
|
11
|
-
require('./types/map/test.f.cjs')
|
|
12
|
-
require('./json/test.f.cjs')
|
|
13
|
-
require('./types/string/test.f.cjs')
|
|
14
|
-
require('./json/tokenizer/test.f.cjs')
|
|
15
|
-
require('./types/object/test.f.cjs')
|
|
16
|
-
// require('./commonjs/test.cjs')
|
|
17
|
-
require('./commonjs/package/dependencies/test.f.cjs')
|
|
18
|
-
require('./commonjs/package/test.f.cjs')
|
|
19
|
-
require('./commonjs/path/test.f.cjs')
|
|
20
|
-
require('./types/function/test.f.cjs')
|
|
21
|
-
require('./types/function/compare/test.f.cjs')
|
|
22
|
-
require('./types/stringset/test.f.cjs')
|
|
23
|
-
require('./types/option/test.f.cjs')
|
|
24
|
-
require('./commonjs/build/test.f.cjs')
|
|
25
|
-
require('./types/range/test.f.cjs')
|
|
26
|
-
require('./html/test.f.cjs')
|
|
27
|
-
require('./text/test.f.cjs')
|
|
28
|
-
require('./text/utf8/test.f.cjs')
|
|
29
|
-
require('./text/utf16/test.f.cjs')
|
|
30
|
-
require('./com/cs/test.f.cjs')
|
|
31
|
-
require('./com/cpp/test.f.cjs')
|
|
32
|
-
require('./nodejs/version/test.f.cjs')
|
|
33
|
-
require('./com/rust/test.f.cjs')
|
|
34
|
-
|
|
35
3
|
/** @type {() => never} */
|
|
36
4
|
const assert = () => { throw 'assert' }
|
|
37
5
|
|
|
38
6
|
/** @type {(_: boolean) => void} */
|
|
39
7
|
const assert_if = c => { if (c) { throw 'assert_if' } }
|
|
40
8
|
|
|
41
|
-
{
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
{
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
{
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
9
|
+
module.exports = {
|
|
10
|
+
ctor: () => {
|
|
11
|
+
const c = (() => { })['constructor']
|
|
12
|
+
const f = c('return 5')
|
|
13
|
+
const result = f()
|
|
14
|
+
if (result !== 5) { throw 'function' }
|
|
15
|
+
},
|
|
16
|
+
ctorEmpty: () => {
|
|
17
|
+
/** @type {any} */
|
|
18
|
+
const o = {}
|
|
19
|
+
const c = o['constructor']
|
|
20
|
+
// console.log(c)
|
|
21
|
+
// console.log(c(()=>{}))
|
|
22
|
+
},
|
|
23
|
+
ctorUndefined: () => {
|
|
24
|
+
/** @type {any} */
|
|
25
|
+
const o = {
|
|
26
|
+
constructor: undefined
|
|
27
|
+
}
|
|
28
|
+
const c = o['constructor']
|
|
29
|
+
//console.log(c)
|
|
30
|
+
},
|
|
31
|
+
number: () => {
|
|
32
|
+
/** @type {any} */
|
|
33
|
+
const b = '42'
|
|
34
|
+
const r = Number(b)
|
|
35
|
+
//console.log(r)
|
|
36
|
+
},
|
|
37
|
+
properties: () => {
|
|
38
|
+
/** @type {any} */
|
|
39
|
+
const o = {}
|
|
40
|
+
//const c = o['constructor']
|
|
41
|
+
//const c = o['__proto__']
|
|
42
|
+
//const c = o['__defineGetter__']
|
|
43
|
+
//const c = o['__defineSetter__']
|
|
44
|
+
//const c = o['__lookupGetter__']
|
|
45
|
+
//const c = o['__lookupSetter__']
|
|
46
|
+
//const c = o['hasOwnProperty']
|
|
47
|
+
//const c = o['isPrototypeOf']
|
|
48
|
+
//const c = o['propertyIsEnumerable']
|
|
49
|
+
//const c = o['toString']
|
|
50
|
+
const c = o['valueOf']
|
|
51
|
+
//console.log(c)
|
|
52
|
+
},
|
|
53
|
+
getOwnPropertyDescriptor: () => {
|
|
54
|
+
const x = { 'a': 12 }
|
|
55
|
+
const c = Object.getOwnPropertyDescriptor(x, 'constructor')
|
|
56
|
+
const a = Object.getOwnPropertyDescriptor(x, 'a')
|
|
60
57
|
}
|
|
61
|
-
|
|
62
|
-
//console.log(c)
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
{
|
|
66
|
-
/** @type {any} */
|
|
67
|
-
const b = '42'
|
|
68
|
-
const r = Number(b)
|
|
69
|
-
//console.log(r)
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
{
|
|
73
|
-
/** @type {any} */
|
|
74
|
-
const o = {}
|
|
75
|
-
//const c = o['constructor']
|
|
76
|
-
//const c = o['__proto__']
|
|
77
|
-
//const c = o['__defineGetter__']
|
|
78
|
-
//const c = o['__defineSetter__']
|
|
79
|
-
//const c = o['__lookupGetter__']
|
|
80
|
-
//const c = o['__lookupSetter__']
|
|
81
|
-
//const c = o['hasOwnProperty']
|
|
82
|
-
//const c = o['isPrototypeOf']
|
|
83
|
-
//const c = o['propertyIsEnumerable']
|
|
84
|
-
//const c = o['toString']
|
|
85
|
-
const c = o['valueOf']
|
|
86
|
-
//console.log(c)
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
{
|
|
90
|
-
const x = { 'a': 12 }
|
|
91
|
-
const c = Object.getOwnPropertyDescriptor(x, 'constructor')
|
|
92
|
-
const a = Object.getOwnPropertyDescriptor(x, 'a')
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
module.exports = {}
|
|
58
|
+
}
|
package/test.mjs
CHANGED
|
@@ -21,9 +21,39 @@
|
|
|
21
21
|
/** @type {FsPromises} */
|
|
22
22
|
const { readdir, readFile } = await import(globalThis.Deno ? 'https://deno.land/std/node/fs/promises.ts' : 'node:fs/promises')
|
|
23
23
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
/**
|
|
25
|
+
* @typedef {{
|
|
26
|
+
* [k: in string]?: Module
|
|
27
|
+
* }} Dependencies
|
|
28
|
+
*/
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* @typedef {{
|
|
32
|
+
* dependencies: Dependencies
|
|
33
|
+
* exports?: unknown
|
|
34
|
+
* }} Module
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
/** @typedef {(name: string) => unknown} Require */
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* @typedef {{
|
|
41
|
+
* readonly[k in string]: Function
|
|
42
|
+
* }} FunctionMap
|
|
43
|
+
*/
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* @template T
|
|
47
|
+
* @typedef {readonly[string, T]} Entry
|
|
48
|
+
*/
|
|
49
|
+
|
|
50
|
+
/** @type {(a: Entry<Function>, b: Entry<Function>) => number} */
|
|
51
|
+
const cmp = ([a], [b]) => a < b ? -1 : a > b ? 1 : 0
|
|
52
|
+
|
|
53
|
+
/** @type {() => Promise<FunctionMap>} */
|
|
54
|
+
const load = async () => {
|
|
55
|
+
/** @type {(readonly[string, Function])[]} */
|
|
56
|
+
const map = []
|
|
27
57
|
/** @type {(path: string) => Promise<void>} */
|
|
28
58
|
const f = async p => {
|
|
29
59
|
for (const i of await readdir(p, { withFileTypes: true })) {
|
|
@@ -37,55 +67,56 @@ const load = async() => {
|
|
|
37
67
|
} else if (name.endsWith('.f.cjs')) {
|
|
38
68
|
console.log(`loading ${file}`)
|
|
39
69
|
const source = await readFile(file, 'utf8')
|
|
40
|
-
map[file
|
|
70
|
+
map.push([file, Function('module', 'require', `"use strict";${source}`)])
|
|
41
71
|
}
|
|
42
72
|
}
|
|
43
73
|
}
|
|
44
74
|
}
|
|
45
75
|
await f('.')
|
|
46
|
-
|
|
76
|
+
map.sort(cmp)
|
|
77
|
+
return Object.fromEntries(map)
|
|
47
78
|
}
|
|
48
79
|
|
|
49
80
|
const map = await load()
|
|
50
81
|
|
|
51
|
-
/** @typedef {{ exports?: unknown }} Module */
|
|
52
|
-
|
|
53
|
-
/** @typedef {(name: string) => unknown} Require */
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* @typedef {{
|
|
57
|
-
* [k in string]: Function
|
|
58
|
-
* }} FunctionMap
|
|
59
|
-
*/
|
|
60
|
-
|
|
61
82
|
/**
|
|
62
83
|
* @typedef {{
|
|
63
|
-
* [k in string]:
|
|
84
|
+
* [k in string]: Module
|
|
64
85
|
* }} ModuleMap
|
|
65
86
|
*/
|
|
66
87
|
|
|
67
88
|
const build = async () => {
|
|
68
89
|
/** @type {ModuleMap} */
|
|
69
90
|
const d = {}
|
|
70
|
-
/** @type {(base: readonly string[]) => (i: string) => (k: string) =>
|
|
71
|
-
const req =
|
|
91
|
+
/** @type {(base: readonly string[]) => (i: string) => (k: string) => readonly[string, Module]} */
|
|
92
|
+
const req = base => i => k => {
|
|
72
93
|
const relativePath = k.split('/')
|
|
73
94
|
const dif = relativePath.filter(v => v === '..').length
|
|
74
|
-
const path = [
|
|
95
|
+
const path = [base.slice(0, base.length - dif), relativePath.filter(v => !['..', '.'].includes(v))]
|
|
75
96
|
.flat()
|
|
76
97
|
const pathStr = path.join('/')
|
|
77
98
|
const newBase = path.slice(0, path.length - 1)
|
|
78
|
-
|
|
79
|
-
|
|
99
|
+
{
|
|
100
|
+
const module = d[pathStr]
|
|
101
|
+
if (module !== undefined) {
|
|
102
|
+
return [pathStr, module]
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
{
|
|
80
106
|
/** @type {Module} */
|
|
81
|
-
const
|
|
107
|
+
const module = {
|
|
108
|
+
dependencies: {}
|
|
109
|
+
}
|
|
82
110
|
console.log(`${i}building ${pathStr}`)
|
|
83
|
-
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
111
|
+
const getModule = req(newBase)(`${i}| `)
|
|
112
|
+
const newReq = s => {
|
|
113
|
+
const [p, result] = getModule(s)
|
|
114
|
+
module.dependencies[p] = result
|
|
115
|
+
return result.exports
|
|
116
|
+
}
|
|
117
|
+
map[pathStr](module, newReq)
|
|
118
|
+
d[pathStr] = module
|
|
119
|
+
return [pathStr, module]
|
|
89
120
|
}
|
|
90
121
|
}
|
|
91
122
|
const r = req(['.'])('')
|
|
@@ -96,3 +127,46 @@ const build = async () => {
|
|
|
96
127
|
}
|
|
97
128
|
|
|
98
129
|
const modules = await build()
|
|
130
|
+
|
|
131
|
+
// graph
|
|
132
|
+
|
|
133
|
+
for (const [k, v] of Object.entries(modules)) {
|
|
134
|
+
console.log(`: ${k}`)
|
|
135
|
+
console.log(Object.keys(v.dependencies))
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// test runner.
|
|
139
|
+
|
|
140
|
+
/** @type {(i: string) => (v: unknown) => void} */
|
|
141
|
+
const test = i => v => {
|
|
142
|
+
switch (typeof v) {
|
|
143
|
+
case 'function': {
|
|
144
|
+
if (v.length === 0) {
|
|
145
|
+
const r = v()
|
|
146
|
+
console.log(`${i}() passed`)
|
|
147
|
+
test(`${i}| `)(r)
|
|
148
|
+
}
|
|
149
|
+
return;
|
|
150
|
+
}
|
|
151
|
+
case 'object': {
|
|
152
|
+
if (v instanceof Array) {
|
|
153
|
+
for (const v2 of v) {
|
|
154
|
+
test(`${i}| `)(v2)
|
|
155
|
+
}
|
|
156
|
+
} else {
|
|
157
|
+
for (const [k, v2] of Object.entries(v)) {
|
|
158
|
+
console.log(`${i}${k}:`)
|
|
159
|
+
test(`${i}| `)(v2)
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
return;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
for (const [k, v] of Object.entries(modules)) {
|
|
168
|
+
if (k.endsWith('test.f.cjs')) {
|
|
169
|
+
console.log(`testing ${k}`)
|
|
170
|
+
test('| ')(v.exports)
|
|
171
|
+
}
|
|
172
|
+
}
|
package/text/test.f.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const _ = require('./module.f.cjs')
|
|
2
2
|
const { string: { join } } = require('../types/module.f.cjs')
|
|
3
3
|
|
|
4
|
-
{
|
|
4
|
+
module.exports = () => {
|
|
5
5
|
/** @type {_.Block} */
|
|
6
6
|
const text = [
|
|
7
7
|
'a',
|
|
@@ -15,5 +15,3 @@ const { string: { join } } = require('../types/module.f.cjs')
|
|
|
15
15
|
const result = join('\n')(_.flat(':')(text))
|
|
16
16
|
if (result !== 'a\nb\n:c\n::d\ne') { throw result }
|
|
17
17
|
}
|
|
18
|
-
|
|
19
|
-
module.exports = {}
|
package/text/utf16/test.f.cjs
CHANGED
|
@@ -6,113 +6,100 @@ const { list } = require('../../types/module.f.cjs')
|
|
|
6
6
|
/** @type {(a: readonly json.Unknown[]) => string} */
|
|
7
7
|
const stringify = a => json.stringify(sort)(a)
|
|
8
8
|
|
|
9
|
-
{
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
module.exports = {
|
|
10
|
+
toCodePointList: [
|
|
11
|
+
() => {
|
|
12
|
+
const result = stringify(list.toArray(encoding.toCodePointList([-1, 65536])))
|
|
13
|
+
if (result !== '[4294967295,4294967295]') { throw result }
|
|
14
|
+
},
|
|
15
|
+
() => {
|
|
16
|
+
const result = stringify(list.toArray(encoding.toCodePointList([0, 36, 8364, 55295, 57344, 65535])))
|
|
17
|
+
if (result !== '[0,36,8364,55295,57344,65535]') { throw result }
|
|
18
|
+
},
|
|
19
|
+
() => {
|
|
20
|
+
const result = stringify(list.toArray(encoding.toCodePointList([56320, 57343])))
|
|
21
|
+
if (result !== '[-2147427328,-2147426305]') { throw result }
|
|
22
|
+
},
|
|
23
|
+
() => {
|
|
24
|
+
const result = stringify(list.toArray(encoding.toCodePointList([55296, 56320, 55297, 56375, 55378, 57186, 56319, 57343])))
|
|
25
|
+
if (result !== '[65536,66615,150370,1114111]') { throw result }
|
|
26
|
+
},
|
|
27
|
+
() => {
|
|
28
|
+
const result = stringify(list.toArray(encoding.toCodePointList([55296, 55296])))
|
|
29
|
+
if (result !== '[-2147428352,-2147428352]') { throw result }
|
|
30
|
+
},
|
|
31
|
+
() => {
|
|
32
|
+
const result = stringify(list.toArray(encoding.toCodePointList([55296, 0])))
|
|
33
|
+
if (result !== '[-2147428352,0]') { throw result }
|
|
34
|
+
},
|
|
35
|
+
() => {
|
|
36
|
+
const result = stringify(list.toArray(encoding.toCodePointList([56320])))
|
|
37
|
+
if (result !== '[-2147427328]') { throw result }
|
|
38
|
+
},
|
|
39
|
+
() => {
|
|
40
|
+
const result = stringify(list.toArray(encoding.toCodePointList([56320, 0])))
|
|
41
|
+
if (result !== '[-2147427328,0]') { throw result }
|
|
42
|
+
}
|
|
43
|
+
],
|
|
44
|
+
fromCodePointList: [
|
|
45
|
+
() => {
|
|
46
|
+
const result = stringify(list.toArray(encoding.fromCodePointList([0])))
|
|
47
|
+
if (result !== '[0]') { throw result }
|
|
48
|
+
},
|
|
49
|
+
() => {
|
|
50
|
+
const result = stringify(list.toArray(encoding.fromCodePointList([0x24])))
|
|
51
|
+
if (result !== '[36]') { throw result }
|
|
52
|
+
},
|
|
53
|
+
() => {
|
|
54
|
+
const result = stringify(list.toArray(encoding.fromCodePointList([0x20AC])))
|
|
55
|
+
if (result !== '[8364]') { throw result }
|
|
56
|
+
},
|
|
57
|
+
() => {
|
|
58
|
+
const result = stringify(list.toArray(encoding.fromCodePointList([0xd7ff])))
|
|
59
|
+
if (result !== '[55295]') { throw result }
|
|
60
|
+
},
|
|
61
|
+
() => {
|
|
62
|
+
const result = stringify(list.toArray(encoding.fromCodePointList([0xe000])))
|
|
63
|
+
if (result !== '[57344]') { throw result }
|
|
64
|
+
},
|
|
65
|
+
() => {
|
|
66
|
+
const result = stringify(list.toArray(encoding.fromCodePointList([0xffff])))
|
|
67
|
+
if (result !== '[65535]') { throw result }
|
|
68
|
+
},
|
|
69
|
+
() => {
|
|
70
|
+
const result = stringify(list.toArray(encoding.fromCodePointList([0x10000])))
|
|
71
|
+
if (result !== '[55296,56320]') { throw result }
|
|
72
|
+
},
|
|
73
|
+
() => {
|
|
74
|
+
const result = stringify(list.toArray(encoding.fromCodePointList([0x10437])))
|
|
75
|
+
if (result !== '[55297,56375]') { throw result }
|
|
76
|
+
},
|
|
77
|
+
() => {
|
|
78
|
+
const result = stringify(list.toArray(encoding.fromCodePointList([0x24B62])))
|
|
79
|
+
if (result !== '[55378,57186]') { throw result }
|
|
80
|
+
},
|
|
81
|
+
() => {
|
|
82
|
+
const result = stringify(list.toArray(encoding.fromCodePointList([0x10ffff])))
|
|
83
|
+
if (result !== '[56319,57343]') { throw result }
|
|
84
|
+
},
|
|
85
|
+
() => {
|
|
86
|
+
const result = stringify(list.toArray(encoding.fromCodePointList([-1, 0xd800, 0xdfff, 0x110000])))
|
|
87
|
+
if (result !== '[65535,55296,57343,0]') { throw result }
|
|
88
|
+
}
|
|
89
|
+
],
|
|
90
|
+
string: [
|
|
91
|
+
() => {
|
|
92
|
+
const utf16List = encoding.stringToList("Hello world!😂🚜🚲")
|
|
93
|
+
const result = encoding.listToString(utf16List)
|
|
94
|
+
if (result !== "Hello world!😂🚜🚲") { throw result }
|
|
95
|
+
},
|
|
96
|
+
() => {
|
|
97
|
+
const a = encoding.stringToList("Hello world!😂🚜🚲")
|
|
98
|
+
const b = encoding.toCodePointList(a)
|
|
99
|
+
const c = encoding.fromCodePointList(b)
|
|
100
|
+
const result = encoding.listToString(c)
|
|
101
|
+
if (result !== "Hello world!😂🚜🚲") { throw result }
|
|
102
|
+
|
|
103
|
+
}
|
|
104
|
+
]
|
|
12
105
|
}
|
|
13
|
-
|
|
14
|
-
{
|
|
15
|
-
const result = stringify(list.toArray(encoding.toCodePointList([0, 36, 8364, 55295, 57344, 65535])))
|
|
16
|
-
if (result !== '[0,36,8364,55295,57344,65535]') { throw result }
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
{
|
|
20
|
-
const result = stringify(list.toArray(encoding.toCodePointList([56320, 57343])))
|
|
21
|
-
if (result !== '[-2147427328,-2147426305]') { throw result }
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
{
|
|
25
|
-
const result = stringify(list.toArray(encoding.toCodePointList([55296, 56320, 55297, 56375, 55378, 57186, 56319, 57343])))
|
|
26
|
-
if (result !== '[65536,66615,150370,1114111]') { throw result }
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
{
|
|
30
|
-
const result = stringify(list.toArray(encoding.toCodePointList([55296, 55296])))
|
|
31
|
-
if (result !== '[-2147428352,-2147428352]') { throw result }
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
{
|
|
35
|
-
const result = stringify(list.toArray(encoding.toCodePointList([55296, 0])))
|
|
36
|
-
if (result !== '[-2147428352,0]') { throw result }
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
{
|
|
40
|
-
const result = stringify(list.toArray(encoding.toCodePointList([56320])))
|
|
41
|
-
if (result !== '[-2147427328]') { throw result }
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
{
|
|
45
|
-
const result = stringify(list.toArray(encoding.toCodePointList([56320, 0])))
|
|
46
|
-
if (result !== '[-2147427328,0]') { throw result }
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
{
|
|
50
|
-
const result = stringify(list.toArray(encoding.fromCodePointList([0])))
|
|
51
|
-
if (result !== '[0]') { throw result }
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
{
|
|
55
|
-
const result = stringify(list.toArray(encoding.fromCodePointList([0x24])))
|
|
56
|
-
if (result !== '[36]') { throw result }
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
{
|
|
60
|
-
const result = stringify(list.toArray(encoding.fromCodePointList([0x20AC])))
|
|
61
|
-
if (result !== '[8364]') { throw result }
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
{
|
|
65
|
-
const result = stringify(list.toArray(encoding.fromCodePointList([0xd7ff])))
|
|
66
|
-
if (result !== '[55295]') { throw result }
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
{
|
|
70
|
-
const result = stringify(list.toArray(encoding.fromCodePointList([0xe000])))
|
|
71
|
-
if (result !== '[57344]') { throw result }
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
{
|
|
75
|
-
const result = stringify(list.toArray(encoding.fromCodePointList([0xffff])))
|
|
76
|
-
if (result !== '[65535]') { throw result }
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
{
|
|
80
|
-
const result = stringify(list.toArray(encoding.fromCodePointList([0x10000])))
|
|
81
|
-
if (result !== '[55296,56320]') { throw result }
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
{
|
|
85
|
-
const result = stringify(list.toArray(encoding.fromCodePointList([0x10437])))
|
|
86
|
-
if (result !== '[55297,56375]') { throw result }
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
{
|
|
90
|
-
const result = stringify(list.toArray(encoding.fromCodePointList([0x24B62])))
|
|
91
|
-
if (result !== '[55378,57186]') { throw result }
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
{
|
|
95
|
-
const result = stringify(list.toArray(encoding.fromCodePointList([0x10ffff])))
|
|
96
|
-
if (result !== '[56319,57343]') { throw result }
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
{
|
|
100
|
-
const result = stringify(list.toArray(encoding.fromCodePointList([-1, 0xd800, 0xdfff, 0x110000])))
|
|
101
|
-
if (result !== '[65535,55296,57343,0]') { throw result }
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
{
|
|
105
|
-
const utf16List = encoding.stringToList("Hello world!😂🚜🚲")
|
|
106
|
-
const result = encoding.listToString(utf16List)
|
|
107
|
-
if (result !== "Hello world!😂🚜🚲") { throw result }
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
{
|
|
111
|
-
const a = encoding.stringToList("Hello world!😂🚜🚲")
|
|
112
|
-
const b = encoding.toCodePointList(a)
|
|
113
|
-
const c = encoding.fromCodePointList(b)
|
|
114
|
-
const result = encoding.listToString(c)
|
|
115
|
-
if (result !== "Hello world!😂🚜🚲") { throw result }
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
module.exports = {}
|