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
|
@@ -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
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "functionalscript",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.425",
|
|
4
4
|
"description": "FunctionalScript is a functional subset of JavaScript",
|
|
5
5
|
"main": "module.f.cjs",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"tsc": "tsc",
|
|
8
8
|
"test": "tsc && npm run test-only",
|
|
9
9
|
"version": "node ./nodejs/version/main.cjs",
|
|
10
|
-
"test-only": "node --trace-uncaught ./test.
|
|
10
|
+
"test-only": "node --trace-uncaught ./test.mjs"
|
|
11
11
|
},
|
|
12
12
|
"repository": {
|
|
13
13
|
"type": "git",
|
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
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @typedef {{
|
|
3
|
+
* readonly withFileTypes: true
|
|
4
|
+
* }} Options
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* @typedef {{
|
|
9
|
+
* readonly name: string
|
|
10
|
+
* readonly isDirectory: () => boolean
|
|
11
|
+
* }} Dirent
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* @typedef {{
|
|
16
|
+
* readonly readdir: (path: string, options: Options) => Promise<readonly Dirent[]>
|
|
17
|
+
* readonly readFile: (path: string, options: 'utf8') => Promise<Buffer>
|
|
18
|
+
* }} FsPromises
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
/** @type {FsPromises} */
|
|
22
|
+
const { readdir, readFile } = await import(globalThis.Deno ? 'https://deno.land/std/node/fs/promises.ts' : 'node:fs/promises')
|
|
23
|
+
|
|
24
|
+
/** @typedef {{ exports?: unknown }} Module */
|
|
25
|
+
|
|
26
|
+
/** @typedef {(name: string) => unknown} Require */
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* @typedef {{
|
|
30
|
+
* readonly[k in string]: Function
|
|
31
|
+
* }} FunctionMap
|
|
32
|
+
*/
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* @template T
|
|
36
|
+
* @typedef {readonly[string, T]} Entry
|
|
37
|
+
*/
|
|
38
|
+
|
|
39
|
+
/** @type {(a: Entry<Function>, b: Entry<Function>) => number} */
|
|
40
|
+
const cmp = ([a], [b]) => a < b ? -1 : a > b ? 1 : 0
|
|
41
|
+
|
|
42
|
+
/** @type {() => Promise<FunctionMap>} */
|
|
43
|
+
const load = async () => {
|
|
44
|
+
/** @type {(readonly[string, Function])[]} */
|
|
45
|
+
const map = []
|
|
46
|
+
/** @type {(path: string) => Promise<void>} */
|
|
47
|
+
const f = async p => {
|
|
48
|
+
for (const i of await readdir(p, { withFileTypes: true })) {
|
|
49
|
+
const { name } = i
|
|
50
|
+
if (!name.startsWith('.')) {
|
|
51
|
+
const file = `${p}/${name}`
|
|
52
|
+
if (i.isDirectory()) {
|
|
53
|
+
if (!['node_modules', 'target'].includes(name)) {
|
|
54
|
+
await f(file)
|
|
55
|
+
}
|
|
56
|
+
} else if (name.endsWith('.f.cjs')) {
|
|
57
|
+
console.log(`loading ${file}`)
|
|
58
|
+
const source = await readFile(file, 'utf8')
|
|
59
|
+
map.push([file, Function('module', 'require', `"use strict";${source}`)])
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
await f('.')
|
|
65
|
+
map.sort(cmp)
|
|
66
|
+
return Object.fromEntries(map)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const map = await load()
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* @typedef {{
|
|
73
|
+
* [k in string]: unknown
|
|
74
|
+
* }} ModuleMap
|
|
75
|
+
*/
|
|
76
|
+
|
|
77
|
+
const build = async () => {
|
|
78
|
+
/** @type {ModuleMap} */
|
|
79
|
+
const d = {}
|
|
80
|
+
/** @type {(base: readonly string[]) => (i: string) => (k: string) => unknown} */
|
|
81
|
+
const req = p => i => k => {
|
|
82
|
+
const relativePath = k.split('/')
|
|
83
|
+
const dif = relativePath.filter(v => v === '..').length
|
|
84
|
+
const path = [p.slice(0, p.length - dif), relativePath.filter(v => !['..', '.'].includes(v))]
|
|
85
|
+
.flat()
|
|
86
|
+
const pathStr = path.join('/')
|
|
87
|
+
const newBase = path.slice(0, path.length - 1)
|
|
88
|
+
const result = d[pathStr]
|
|
89
|
+
if (result === undefined) {
|
|
90
|
+
/** @type {Module} */
|
|
91
|
+
const me = {}
|
|
92
|
+
console.log(`${i}building ${pathStr}`)
|
|
93
|
+
map[pathStr](me, req(newBase)(`${i}| `))
|
|
94
|
+
const newResult = me.exports
|
|
95
|
+
d[pathStr] = newResult
|
|
96
|
+
return newResult
|
|
97
|
+
} else {
|
|
98
|
+
return result
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
const r = req(['.'])('')
|
|
102
|
+
for (const k of Object.keys(map)) {
|
|
103
|
+
r(k)
|
|
104
|
+
}
|
|
105
|
+
return d
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
const modules = await build()
|
|
109
|
+
|
|
110
|
+
const test = i => v => {
|
|
111
|
+
switch (typeof v) {
|
|
112
|
+
case 'function': {
|
|
113
|
+
if (v.length === 0) {
|
|
114
|
+
const r = v()
|
|
115
|
+
console.log(`${i}() passed`)
|
|
116
|
+
test(`${i}| `)(r)
|
|
117
|
+
}
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
case 'object': {
|
|
121
|
+
if (v instanceof Array) {
|
|
122
|
+
for (const v2 of v) {
|
|
123
|
+
test(`${i}| `)(v2)
|
|
124
|
+
}
|
|
125
|
+
} else {
|
|
126
|
+
for (const [k, v2] of Object.entries(v)) {
|
|
127
|
+
const i2 = `${i}| `
|
|
128
|
+
console.log(`${i}${k}:`)
|
|
129
|
+
test(i2)(v2)
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
for (const [k, v] of Object.entries(modules)) {
|
|
138
|
+
if (k.endsWith('test.f.cjs')) {
|
|
139
|
+
console.log(`testing ${k}`)
|
|
140
|
+
test('| ')(v)
|
|
141
|
+
}
|
|
142
|
+
}
|
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 = {}
|