functionalscript 0.0.424 → 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 (37) hide show
  1. package/com/cpp/test/build.cjs +1 -1
  2. package/com/cpp/{test.f.cjs → testlib.f.cjs} +1 -1
  3. package/com/cs/test/build.cjs +1 -1
  4. package/com/cs/{test.f.cjs → testlib.f.cjs} +1 -1
  5. package/com/rust/test.f.cjs +2 -4
  6. package/com/types/{test.f.cjs → testlib.f.cjs} +0 -0
  7. package/commonjs/build/test.f.cjs +2 -4
  8. package/commonjs/package/dependencies/test.f.cjs +1 -3
  9. package/commonjs/package/test.f.cjs +1 -5
  10. package/commonjs/path/test.f.cjs +158 -170
  11. package/commonjs/test.cjs +52 -61
  12. package/html/test.f.cjs +12 -13
  13. package/json/test.f.cjs +41 -37
  14. package/json/tokenizer/test.f.cjs +238 -296
  15. package/nodejs/version/test.f.cjs +1 -3
  16. package/package.json +1 -1
  17. package/sha2/test.f.cjs +37 -40
  18. package/text/test.f.cjs +1 -3
  19. package/text/utf16/test.f.cjs +96 -109
  20. package/text/utf8/test.f.cjs +116 -135
  21. package/types/array/test.f.cjs +84 -84
  22. package/types/btree/find/test.f.cjs +2 -2
  23. package/types/btree/remove/test.f.cjs +6 -3
  24. package/types/btree/set/test.f.cjs +372 -370
  25. package/types/btree/test.f.cjs +11 -7
  26. package/types/byteSet/module.f.cjs +2 -4
  27. package/types/byteSet/test.f.cjs +37 -40
  28. package/types/function/compare/module.f.cjs +1 -1
  29. package/types/function/compare/test.f.cjs +1 -3
  30. package/types/function/test.f.cjs +1 -3
  31. package/types/list/test.f.cjs +208 -219
  32. package/types/map/test.f.cjs +57 -57
  33. package/types/nibbleSet/test.f.cjs +37 -40
  34. package/types/number/test.f.cjs +24 -26
  35. package/types/object/test.f.cjs +12 -13
  36. package/types/option/test.f.cjs +1 -3
  37. package/types/range/test.f.cjs +1 -3
@@ -19,7 +19,7 @@ const stringify = sequence => jsonStr(list.toArray(sequence))
19
19
  /** @type {(node: btree.Node<string>) => (value: string) => btree.Node<string>} */
20
20
  const set = node => value => s.set(cmp(value))(() => value)(node)
21
21
 
22
- {
22
+ const valueTest1 = () => {
23
23
  /** @type {btree.Node<string>} */
24
24
  let _map = ['a']
25
25
  _map = set(_map)('b')
@@ -31,7 +31,7 @@ const set = node => value => s.set(cmp(value))(() => value)(node)
31
31
  if (result !== '["a","b","c","d","e","f"]') { throw result }
32
32
  }
33
33
 
34
- {
34
+ const valuesTest2 = () => {
35
35
  /** @type {btree.Node<string>} */
36
36
  let _map = ['1']
37
37
  for(let i = 2; i <= 10; i++)
@@ -40,7 +40,7 @@ const set = node => value => s.set(cmp(value))(() => value)(node)
40
40
  if (result !== '["1","100","16","25","36","4","49","64","81","9"]') { throw result }
41
41
  }
42
42
 
43
- {
43
+ const findTrue = () => {
44
44
  /** @type {btree.Node<string>} */
45
45
  let _map = ['a']
46
46
  _map = set(_map)('b')
@@ -49,7 +49,7 @@ const set = node => value => s.set(cmp(value))(() => value)(node)
49
49
  if (result !== 'b') { throw result }
50
50
  }
51
51
 
52
- {
52
+ const find = () => {
53
53
  /** @type {btree.Node<string>} */
54
54
  let _map = ['a']
55
55
  _map = set(_map)('b')
@@ -76,6 +76,10 @@ const test = () => {
76
76
  }
77
77
  }
78
78
 
79
- test()
80
-
81
- module.exports = {}
79
+ module.exports = {
80
+ valueTest1,
81
+ valuesTest2,
82
+ findTrue,
83
+ find,
84
+ test,
85
+ }
@@ -1,8 +1,6 @@
1
1
  /** @typedef {bigint} byteSet */
2
2
  /** @typedef {number} byte */
3
3
 
4
- const empty = 0n
5
-
6
4
  /** @type {(n: byte) => (s: byteSet) => boolean} */
7
5
  const has = n => s => ((s >> BigInt(n)) & 1n) === 1n
8
6
 
@@ -13,14 +11,14 @@ const set = n => s => s | (1n << BigInt(n))
13
11
  const unset = n => s => s & ~(1n << BigInt(n))
14
12
 
15
13
  /** @type {(r: readonly[number, number]) => (s: byteSet) => byteSet} */
16
- const setRange = r => s => s | ((1n << BigInt(r[1] - r[0] + 1)) - 1n << BigInt(r[0]))
14
+ const setRange = ([b, e]) => s => s | ((1n << BigInt(e - b + 1)) - 1n << BigInt(b))
17
15
 
18
16
  // how to define FA???
19
17
  // const stateA = [init, set] ????
20
18
 
21
19
  module.exports = {
22
20
  /** @readonly */
23
- empty,
21
+ empty: 0n,
24
22
  /** @readonly */
25
23
  has,
26
24
  /** @readonly */
@@ -1,44 +1,41 @@
1
1
  const _ = require('./module.f.cjs')
2
2
 
3
- {
4
- if (_.has(0)(_.empty)) { throw _.empty }
5
- if (_.has(1)(_.empty)) { throw _.empty }
6
- if (_.has(33)(_.empty)) { throw _.empty }
7
- }
8
-
9
- {
10
- const s = _.set(0)(_.empty)
11
- if (s !== 1n) { throw s }
12
- if (!_.has(0)(s)) { throw s }
13
- if (_.has(1)(s)) { throw s }
14
- if (_.has(33)(s)) { throw s }
15
- }
16
-
17
- {
18
- const s = _.set(33)(_.empty)
19
- if (s !== 8589934592n) { throw s }
20
- if (_.has(0)(s)) { throw s }
21
- if (_.has(1)(s)) { throw s }
22
- if (!_.has(33)(s)) { throw s }
23
- }
24
-
25
- {
26
- const a = _.set(0)(_.empty)
27
- const result = _.unset(0)(a)
28
- if (result !== 0n) { throw result }
29
- }
30
-
31
- {
32
- const a = _.set(255)(_.empty)
33
- const result = _.unset(255)(a)
34
- if (result !== 0n) { throw result }
35
- }
36
-
37
- {
38
- const result = _.setRange([2, 5])(_.empty)
39
- if (result !== 60n) { throw result }
40
- }
41
-
42
3
  module.exports = {
43
-
4
+ has: [
5
+ () => {
6
+ if (_.has(0)(_.empty)) { throw _.empty }
7
+ if (_.has(1)(_.empty)) { throw _.empty }
8
+ if (_.has(33)(_.empty)) { throw _.empty }
9
+ },
10
+ () => {
11
+ const s = _.set(0)(_.empty)
12
+ if (s !== 1n) { throw s }
13
+ if (!_.has(0)(s)) { throw s }
14
+ if (_.has(1)(s)) { throw s }
15
+ if (_.has(33)(s)) { throw s }
16
+ },
17
+ () => {
18
+ const s = _.set(33)(_.empty)
19
+ if (s !== 8589934592n) { throw s }
20
+ if (_.has(0)(s)) { throw s }
21
+ if (_.has(1)(s)) { throw s }
22
+ if (!_.has(33)(s)) { throw s }
23
+ }
24
+ ],
25
+ setRange: () => {
26
+ const result = _.setRange([2, 5])(_.empty)
27
+ if (result !== 60n) { throw result }
28
+ },
29
+ unset: [
30
+ () => {
31
+ const a = _.set(0)(_.empty)
32
+ const result = _.unset(0)(a)
33
+ if (result !== 0n) { throw result }
34
+ },
35
+ () => {
36
+ const a = _.set(255)(_.empty)
37
+ const result = _.unset(255)(a)
38
+ if (result !== 0n) { throw result }
39
+ }
40
+ ]
44
41
  }
@@ -25,7 +25,7 @@ const index5 = cmp => ([v0, v1]) => {
25
25
  }
26
26
 
27
27
  /** @type {<T>(a: T) => (b: T) => Sign} */
28
- const unsafeCmp = a => b => a < b ? -1 : a === b ? 0 : 1
28
+ const unsafeCmp = a => b => a < b ? -1 : a > b ? 1 : 0
29
29
 
30
30
  module.exports = {
31
31
  /** @readonly */
@@ -1,8 +1,6 @@
1
1
  const { unsafeCmp } = require('./module.f.cjs')
2
2
 
3
- {
3
+ module.exports = () => {
4
4
  const result = unsafeCmp(true)(false)
5
5
  if (result !== 1) { throw result }
6
6
  }
7
-
8
- module.exports = {}
@@ -1,6 +1,6 @@
1
1
  const { fn } = require('./module.f.cjs')
2
2
 
3
- {
3
+ module.exports = () => {
4
4
  /** @type {(x: string) => readonly[string]} */
5
5
  const f = x => [x]
6
6
  /** @type {(x: readonly[string]) => readonly[number]} */
@@ -13,5 +13,3 @@ const { fn } = require('./module.f.cjs')
13
13
  const result = r('hello')
14
14
  if (result !== 5) { throw r }
15
15
  }
16
-
17
- module.exports = {}