functionalscript 0.19.0 → 0.20.0

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 (219) hide show
  1. package/fs/asn.1/{test.f.d.ts → proof.f.d.ts} +1 -2
  2. package/fs/asn.1/{test.f.js → proof.f.js} +1 -1
  3. package/fs/base128/proof.f.d.ts +1 -0
  4. package/fs/base128/{test.f.js → proof.f.js} +1 -1
  5. package/fs/bnf/data/{test.f.d.ts → proof.f.d.ts} +1 -2
  6. package/fs/bnf/data/{test.f.js → proof.f.js} +1 -1
  7. package/fs/bnf/proof.f.d.ts +3 -0
  8. package/fs/bnf/{test.f.js → proof.f.js} +1 -1
  9. package/fs/cas/module.f.js +2 -12
  10. package/fs/cas/proof.f.d.ts +1 -0
  11. package/fs/cas/proof.f.js +1 -0
  12. package/fs/cbase32/{test.f.d.ts → proof.f.d.ts} +1 -2
  13. package/fs/cbase32/{test.f.js → proof.f.js} +1 -1
  14. package/fs/ci/node/module.f.js +12 -7
  15. package/fs/ci/{test.f.d.ts → proof.f.d.ts} +1 -2
  16. package/fs/ci/{test.f.js → proof.f.js} +1 -1
  17. package/fs/crypto/hmac/{test.f.d.ts → proof.f.d.ts} +1 -2
  18. package/fs/crypto/hmac/{test.f.js → proof.f.js} +1 -1
  19. package/fs/crypto/secp/{test.f.d.ts → proof.f.d.ts} +1 -2
  20. package/fs/crypto/secp/{test.f.js → proof.f.js} +1 -1
  21. package/fs/crypto/sha2/{test.f.d.ts → proof.f.d.ts} +1 -2
  22. package/fs/crypto/sha2/{test.f.js → proof.f.js} +1 -1
  23. package/fs/crypto/sign/{test.f.d.ts → proof.f.d.ts} +1 -2
  24. package/fs/crypto/sign/{test.f.js → proof.f.js} +1 -1
  25. package/fs/dev/module.f.d.ts +28 -2
  26. package/fs/dev/module.f.js +38 -22
  27. package/fs/dev/{test.f.d.ts → proof.f.d.ts} +5 -2
  28. package/fs/dev/{test.f.js → proof.f.js} +25 -2
  29. package/fs/dev/tf/module.f.d.ts +63 -5
  30. package/fs/dev/tf/module.f.js +77 -20
  31. package/fs/dev/tf/{test.f.d.ts → proof.f.d.ts} +26 -0
  32. package/fs/dev/tf/{test.f.js → proof.f.js} +76 -34
  33. package/fs/dev/tf/scenarios/async-subtests.fail.d.ts +4 -0
  34. package/fs/dev/tf/scenarios/async-subtests.fail.js +7 -0
  35. package/fs/dev/tf/scenarios/async-subtests.pass.d.ts +4 -0
  36. package/fs/dev/tf/scenarios/async-subtests.pass.js +7 -0
  37. package/fs/dev/tf/scenarios/async.fail.d.ts +1 -0
  38. package/fs/dev/tf/scenarios/async.fail.js +4 -0
  39. package/fs/dev/tf/scenarios/async.pass.d.ts +1 -0
  40. package/fs/dev/tf/scenarios/async.pass.js +3 -0
  41. package/fs/dev/tf/scenarios/thenable.pass.d.ts +3 -0
  42. package/fs/dev/tf/scenarios/thenable.pass.js +9 -0
  43. package/fs/dev/tf/scenarios/thenable2.pass.f.d.ts +3 -0
  44. package/fs/dev/tf/scenarios/thenable2.pass.f.js +3 -0
  45. package/fs/dev/version/proof.f.d.ts +3 -0
  46. package/fs/dev/version/{test.f.js → proof.f.js} +1 -1
  47. package/fs/djs/ast/{test.f.d.ts → proof.f.d.ts} +1 -2
  48. package/fs/djs/ast/{test.f.js → proof.f.js} +1 -1
  49. package/fs/djs/parser/{test.f.d.ts → proof.f.d.ts} +1 -2
  50. package/fs/djs/parser/{test.f.js → proof.f.js} +1 -1
  51. package/fs/djs/{test.f.d.ts → proof.f.d.ts} +1 -2
  52. package/fs/djs/{test.f.js → proof.f.js} +1 -1
  53. package/fs/djs/serializer/module.f.d.ts +2 -2
  54. package/fs/djs/serializer/module.f.js +47 -79
  55. package/fs/djs/serializer/{test.f.d.ts → proof.f.d.ts} +1 -2
  56. package/fs/djs/serializer/{test.f.js → proof.f.js} +8 -8
  57. package/fs/djs/tokenizer/{test.f.d.ts → proof.f.d.ts} +1 -2
  58. package/fs/djs/tokenizer/{test.f.js → proof.f.js} +1 -1
  59. package/fs/djs/tokenizer-new/{test.f.d.ts → proof.f.d.ts} +1 -2
  60. package/fs/djs/tokenizer-new/{test.f.js → proof.f.js} +1 -1
  61. package/fs/djs/transpiler/module.f.d.ts +15 -0
  62. package/fs/djs/transpiler/module.f.js +10 -2
  63. package/fs/djs/transpiler/{test.f.d.ts → proof.f.d.ts} +1 -2
  64. package/fs/djs/transpiler/{test.f.js → proof.f.js} +1 -1
  65. package/fs/fsc/{test.f.d.ts → proof.f.d.ts} +1 -2
  66. package/fs/fsc/{test.f.js → proof.f.js} +1 -1
  67. package/fs/fsm/proof.f.d.ts +4 -0
  68. package/fs/fsm/{test.f.js → proof.f.js} +1 -1
  69. package/fs/html/{test.f.d.ts → proof.f.d.ts} +1 -2
  70. package/fs/html/{test.f.js → proof.f.js} +1 -1
  71. package/fs/io/module.d.ts +1 -1
  72. package/fs/io/module.f.d.ts +3 -2
  73. package/fs/io/module.f.js +4 -3
  74. package/fs/io/module.js +19 -11
  75. package/fs/js/tokenizer/{test.f.d.ts → proof.f.d.ts} +1 -2
  76. package/fs/js/tokenizer/{test.f.js → proof.f.js} +1 -1
  77. package/fs/json/parser/{test.f.d.ts → proof.f.d.ts} +1 -2
  78. package/fs/json/parser/{test.f.js → proof.f.js} +1 -1
  79. package/fs/json/{test.f.d.ts → proof.f.d.ts} +1 -2
  80. package/fs/json/{test.f.js → proof.f.js} +1 -1
  81. package/fs/json/serializer/{test.f.d.ts → proof.f.d.ts} +1 -2
  82. package/fs/json/serializer/{test.f.js → proof.f.js} +1 -1
  83. package/fs/json/tokenizer/{test.f.d.ts → proof.f.d.ts} +1 -2
  84. package/fs/json/tokenizer/{test.f.js → proof.f.js} +1 -1
  85. package/fs/path/proof.f.d.ts +5 -0
  86. package/fs/path/{test.f.js → proof.f.js} +4 -3
  87. package/fs/sul/id/{test.f.d.ts → proof.f.d.ts} +1 -2
  88. package/fs/sul/id/{test.f.js → proof.f.js} +1 -1
  89. package/fs/sul/level/hash/{test.f.d.ts → proof.f.d.ts} +1 -2
  90. package/fs/sul/level/hash/{test.f.js → proof.f.js} +1 -1
  91. package/fs/sul/level/literal/{test.f.d.ts → proof.f.d.ts} +1 -2
  92. package/fs/sul/level/literal/{test.f.js → proof.f.js} +1 -1
  93. package/fs/sul/{test.f.d.ts → proof.f.d.ts} +1 -2
  94. package/fs/sul/{test.f.js → proof.f.js} +1 -1
  95. package/fs/text/ascii/proof.f.d.ts +3 -0
  96. package/fs/text/ascii/{test.f.js → proof.f.js} +1 -1
  97. package/fs/text/code_point/module.f.d.ts +28 -0
  98. package/fs/text/code_point/module.f.js +31 -0
  99. package/fs/text/{test.f.d.ts → proof.f.d.ts} +1 -2
  100. package/fs/text/{test.f.js → proof.f.js} +1 -1
  101. package/fs/text/sgr/proof.f.d.ts +1 -0
  102. package/fs/text/sgr/{test.f.js → proof.f.js} +1 -1
  103. package/fs/text/utf16/module.f.js +3 -53
  104. package/fs/text/utf16/{test.f.d.ts → proof.f.d.ts} +1 -2
  105. package/fs/text/utf16/{test.f.js → proof.f.js} +1 -1
  106. package/fs/text/utf8/module.f.js +3 -25
  107. package/fs/text/utf8/{test.f.d.ts → proof.f.d.ts} +1 -2
  108. package/fs/text/utf8/{test.f.js → proof.f.js} +1 -1
  109. package/fs/types/array/{test.f.d.ts → proof.f.d.ts} +1 -2
  110. package/fs/types/array/{test.f.js → proof.f.js} +1 -1
  111. package/fs/types/bigfloat/{test.f.d.ts → proof.f.d.ts} +1 -2
  112. package/fs/types/bigfloat/{test.f.js → proof.f.js} +1 -1
  113. package/fs/types/bigint/{test.f.d.ts → proof.f.d.ts} +1 -2
  114. package/fs/types/bigint/{test.f.js → proof.f.js} +1 -1
  115. package/fs/types/bit_vec/{test.f.d.ts → proof.f.d.ts} +1 -2
  116. package/fs/types/bit_vec/{test.f.js → proof.f.js} +1 -1
  117. package/fs/types/btree/find/proof.f.d.ts +1 -0
  118. package/fs/types/btree/find/{test.f.js → proof.f.js} +1 -1
  119. package/fs/types/btree/{test.f.d.ts → proof.f.d.ts} +1 -2
  120. package/fs/types/btree/{test.f.js → proof.f.js} +1 -1
  121. package/fs/types/btree/remove/proof.f.d.ts +4 -0
  122. package/fs/types/btree/remove/{test.f.js → proof.f.js} +1 -1
  123. package/fs/types/btree/set/proof.f.d.ts +1 -0
  124. package/fs/types/btree/set/{test.f.js → proof.f.js} +1 -1
  125. package/fs/types/btree/types/module.f.d.ts +8 -0
  126. package/fs/types/btree/types/module.f.js +8 -0
  127. package/fs/types/byte_set/{test.f.d.ts → proof.f.d.ts} +1 -2
  128. package/fs/types/byte_set/{test.f.js → proof.f.js} +1 -1
  129. package/fs/types/effects/module.f.d.ts +17 -0
  130. package/fs/types/effects/module.f.js +17 -0
  131. package/fs/types/effects/node/module.f.d.ts +54 -5
  132. package/fs/types/effects/node/module.f.js +4 -1
  133. package/fs/types/effects/node/{test.f.d.ts → proof.f.d.ts} +1 -2
  134. package/fs/types/effects/node/{test.f.js → proof.f.js} +1 -1
  135. package/fs/types/effects/node/virtual/module.f.js +1 -0
  136. package/fs/types/effects/proof.f.d.ts +11 -0
  137. package/fs/types/effects/proof.f.js +57 -0
  138. package/fs/types/function/compare/proof.f.d.ts +1 -0
  139. package/fs/types/function/compare/{test.f.js → proof.f.js} +1 -1
  140. package/fs/types/function/operator/proof.f.d.ts +12 -0
  141. package/fs/types/function/operator/{test.f.js → proof.f.js} +11 -10
  142. package/fs/types/function/proof.f.d.ts +1 -0
  143. package/fs/types/function/{test.f.js → proof.f.js} +1 -1
  144. package/fs/types/list/{test.f.d.ts → proof.f.d.ts} +1 -2
  145. package/fs/types/list/{test.f.js → proof.f.js} +1 -1
  146. package/fs/types/map/proof.f.d.ts +4 -0
  147. package/fs/types/map/{test.f.js → proof.f.js} +1 -1
  148. package/fs/types/monoid/{test.f.d.ts → proof.f.d.ts} +1 -2
  149. package/fs/types/monoid/{test.f.js → proof.f.js} +1 -1
  150. package/fs/types/nibble_set/{test.f.d.ts → proof.f.d.ts} +1 -2
  151. package/fs/types/nibble_set/{test.f.js → proof.f.js} +1 -1
  152. package/fs/types/nominal/proof.f.d.ts +4 -0
  153. package/fs/types/nominal/{test.f.js → proof.f.js} +1 -1
  154. package/fs/types/nullable/proof.f.d.ts +1 -0
  155. package/fs/types/nullable/{test.f.js → proof.f.js} +1 -1
  156. package/fs/types/number/{test.f.d.ts → proof.f.d.ts} +1 -2
  157. package/fs/types/number/{test.f.js → proof.f.js} +1 -1
  158. package/fs/types/object/{test.f.d.ts → proof.f.d.ts} +1 -2
  159. package/fs/types/object/{test.f.js → proof.f.js} +1 -1
  160. package/fs/types/ordered_map/{test.f.d.ts → proof.f.d.ts} +1 -2
  161. package/fs/types/ordered_map/{test.f.js → proof.f.js} +1 -1
  162. package/fs/types/patricia_trie/{test.f.d.ts → proof.f.d.ts} +1 -2
  163. package/fs/types/patricia_trie/{test.f.js → proof.f.js} +1 -1
  164. package/fs/types/prime_field/{test.f.d.ts → proof.f.d.ts} +1 -2
  165. package/fs/types/prime_field/{test.f.js → proof.f.js} +1 -1
  166. package/fs/types/range/proof.f.d.ts +1 -0
  167. package/fs/types/range/{test.f.js → proof.f.js} +1 -1
  168. package/fs/types/range_map/{test.f.d.ts → proof.f.d.ts} +1 -2
  169. package/fs/types/range_map/{test.f.js → proof.f.js} +1 -1
  170. package/fs/types/result/proof.f.d.ts +5 -0
  171. package/fs/types/result/{test.f.js → proof.f.js} +18 -2
  172. package/fs/types/rtti/parse/{test.f.d.ts → proof.f.d.ts} +1 -2
  173. package/fs/types/rtti/parse/{test.f.js → proof.f.js} +1 -1
  174. package/fs/types/rtti/{test.f.d.ts → proof.f.d.ts} +1 -2
  175. package/fs/types/rtti/{test.f.js → proof.f.js} +1 -1
  176. package/fs/types/rtti/ts/{test.f.d.ts → proof.f.d.ts} +1 -2
  177. package/fs/types/rtti/ts/{test.f.js → proof.f.js} +1 -1
  178. package/fs/types/rtti/validate/{test.f.d.ts → proof.f.d.ts} +1 -2
  179. package/fs/types/rtti/validate/{test.f.js → proof.f.js} +1 -1
  180. package/fs/types/sorted_list/{test.f.d.ts → proof.f.d.ts} +1 -2
  181. package/fs/types/sorted_list/{test.f.js → proof.f.js} +1 -1
  182. package/fs/types/sorted_set/{test.f.d.ts → proof.f.d.ts} +1 -2
  183. package/fs/types/sorted_set/{test.f.js → proof.f.js} +1 -1
  184. package/fs/types/string/{test.f.d.ts → proof.f.d.ts} +1 -2
  185. package/fs/types/string/{test.f.js → proof.f.js} +1 -1
  186. package/fs/types/string_set/{test.f.d.ts → proof.f.d.ts} +1 -2
  187. package/fs/types/string_set/{test.f.js → proof.f.js} +1 -1
  188. package/fs/types/ts/{test.f.d.ts → proof.f.d.ts} +20 -0
  189. package/fs/types/ts/{test.f.js → proof.f.js} +1 -0
  190. package/fs/types/uint8array/{test.f.d.ts → proof.f.d.ts} +1 -2
  191. package/fs/types/uint8array/{test.f.js → proof.f.js} +1 -1
  192. package/issues/demo/sample/{test.f.js → proof.f.js} +1 -1
  193. package/issues/{test.f.d.ts → proof.f.d.ts} +1 -2
  194. package/issues/{test.f.js → proof.f.js} +1 -1
  195. package/nanvm-lib/tests/{test.f.d.ts → proof.f.d.ts} +1 -2
  196. package/nanvm-lib/tests/{test.f.js → proof.f.js} +1 -1
  197. package/nanvm-lib/tests/vm/{test.f.d.ts → proof.f.d.ts} +1 -2
  198. package/nanvm-lib/tests/vm/{test.f.js → proof.f.js} +1 -1
  199. package/package.json +2 -2
  200. package/fs/base128/test.f.d.ts +0 -2
  201. package/fs/bnf/test.f.d.ts +0 -4
  202. package/fs/cas/test.f.d.ts +0 -2
  203. package/fs/cas/test.f.js +0 -1
  204. package/fs/dev/version/test.f.d.ts +0 -4
  205. package/fs/fsm/test.f.d.ts +0 -5
  206. package/fs/path/test.f.d.ts +0 -3
  207. package/fs/text/ascii/test.f.d.ts +0 -4
  208. package/fs/text/sgr/test.f.d.ts +0 -2
  209. package/fs/types/btree/find/test.f.d.ts +0 -2
  210. package/fs/types/btree/remove/test.f.d.ts +0 -5
  211. package/fs/types/btree/set/test.f.d.ts +0 -2
  212. package/fs/types/function/compare/test.f.d.ts +0 -2
  213. package/fs/types/function/operator/test.f.d.ts +0 -10
  214. package/fs/types/function/test.f.d.ts +0 -2
  215. package/fs/types/map/test.f.d.ts +0 -5
  216. package/fs/types/nominal/test.f.d.ts +0 -5
  217. package/fs/types/nullable/test.f.d.ts +0 -2
  218. package/fs/types/range/test.f.d.ts +0 -2
  219. package/fs/types/result/test.f.d.ts +0 -2
@@ -77,8 +77,15 @@ export type Module = {
77
77
  };
78
78
  export type Import = ['import', (path: string) => IoResult<Module>];
79
79
  export declare const import_: Func<Import>;
80
+ /** Named output streams accepted by the `Write` effect. */
80
81
  export type WriteConsoles = 'stdout' | 'stderr';
82
+ /**
83
+ * Raw byte write to a named output stream. Encoding-agnostic — callers supply
84
+ * a `Vec`. The Node runner maps each stream name to the appropriate fd and
85
+ * delegates to the OS via `stream.write()` with backpressure handling.
86
+ */
81
87
  export type Write = readonly ['write', (stream: WriteConsoles, data: Vec) => void];
88
+ /** Emits a `Write` effect to the given named stream. */
82
89
  export declare const write: Func<Write>;
83
90
  export type Console = (s: string) => Effect<Write, void>;
84
91
  /** Writes a line to `stdout`. Replaces the retired `Log` effect. */
@@ -87,12 +94,19 @@ export declare const log: Console;
87
94
  export declare const error: Console;
88
95
  export type Now = readonly ['now', () => number];
89
96
  export declare const now: Func<Now>;
97
+ /**
98
+ * The outcome of a `Sandbox` operation.
99
+ *
100
+ * `result` carries either `['ok', value]` or `['error', thrown]`. `duration`
101
+ * is a floating-point millisecond count with up to microsecond precision,
102
+ * matching `performance.now()` directly. Additional fields (allocated memory,
103
+ * max stack depth, coverage) may be added in future without breaking consumers.
104
+ */
90
105
  export type SandboxResult<T> = {
91
106
  readonly result: Result<T, unknown>;
92
107
  /**
93
- * Measured milliseconds but it's not limited to that.
94
- * Instead, they represent times as floating-point numbers
95
- * with up to microsecond precision.
108
+ * Elapsed time in milliseconds (microsecond precision via `performance.now()`).
109
+ * The virtual runner returns `0` for deterministic tests.
96
110
  */
97
111
  readonly duration: number;
98
112
  };
@@ -116,15 +130,36 @@ export type Sandbox = readonly ['sandbox', <T>(f: () => T) => SandboxResult<T>];
116
130
  * @see {@link SandboxResult}
117
131
  */
118
132
  export declare const sandbox: Func<Sandbox>;
133
+ /**
134
+ * Resolves the return value of a test function inside the effect runner.
135
+ * If `p` is a real `Promise`, it is awaited and rejections propagate as
136
+ * throws. If `p` is any other value it is returned as-is. Plain thenables
137
+ * (objects with a `.then` method that are not `instanceof Promise`) are
138
+ * treated as ordinary values — not awaited. See `fs/dev/tf/README.md`.
139
+ */
140
+ export type Await = readonly ['await', (p: unknown) => readonly [unknown]];
141
+ export declare const awaitIfPromise: (p: unknown) => Effect<Await, unknown>;
142
+ /**
143
+ * Signature of a framework test-registration function (e.g. `nodeTest.test`,
144
+ * `bunTest.test`, `pwTest`). Returns `Promise<void>` so async sub-tests can
145
+ * be awaited.
146
+ */
119
147
  export type TestFn = (name: string, options: {
120
148
  readonly expectFailure: boolean;
121
149
  }, fn: (t: TestContext) => Promise<void>) => Promise<void>;
150
+ /**
151
+ * A thin wrapper around a framework's `test` function. Passed through
152
+ * `registerModule` so nested test registration uses the appropriate context
153
+ * (e.g. `inlineContext` on Bun and Playwright, which do not support nested
154
+ * `test()` calls inside a callback).
155
+ */
122
156
  export type TestContext = {
123
157
  readonly test: TestFn;
124
158
  };
125
- export type Test = readonly ['test', (ctx: TestContext, name: string, expectFailure: boolean, test: (t: TestContext) => Effect<Test | All, void>) => void];
159
+ /** Effect operation that registers a named test with the active `TestContext`. */
160
+ export type Test = readonly ['test', (ctx: TestContext, name: string, expectFailure: boolean, test: (t: TestContext) => Effect<Test | All | Await, void>) => void];
126
161
  export declare const test: Func<Test>;
127
- export type NodeOp = All | Fetch | Fs | Http | Forever | Import | Now | Sandbox | Write | Test;
162
+ export type NodeOp = All | Await | Fetch | Fs | Http | Forever | Import | Now | Sandbox | Write | Test;
128
163
  export type NodeEffect<T> = Effect<NodeOp, T>;
129
164
  export type NodeOperationMap = ToAsyncOperationMap<NodeOp>;
130
165
  /**
@@ -133,7 +168,21 @@ export type NodeOperationMap = ToAsyncOperationMap<NodeOp>;
133
168
  export type Env = {
134
169
  readonly [k: string]: string | undefined;
135
170
  };
171
+ /** Identifies the JavaScript runtime detected at startup. */
136
172
  export type Engine = 'node' | 'bun' | 'playwright';
173
+ /**
174
+ * Runtime options passed to every `NodeProgram`.
175
+ *
176
+ * - `args`: command-line arguments (equivalent to `process.argv.slice(2)`).
177
+ * - `env`: process environment variables.
178
+ * - `std`: TTY flags for `stdout` and `stderr`, known at startup and used by
179
+ * `csiWrite` to decide whether to strip ANSI SGR sequences.
180
+ * - `testContext`: Node `--test` context; used by `register` on Node.
181
+ * - `bunTestContext`: Bun-compatible context that flattens nested tests inline,
182
+ * working around Bun's lack of nested `test()` support.
183
+ * - `playwrightTestContext`: Playwright context using the same inline strategy.
184
+ * - `engine`: runtime detected at startup; controls which context `register` selects.
185
+ */
137
186
  export type NodeProgramOptions = {
138
187
  readonly args: readonly string[];
139
188
  readonly env: Env;
@@ -8,7 +8,7 @@
8
8
  * @module
9
9
  */
10
10
  import { utf8 } from "../../../text/module.f.js";
11
- import { do_ } from "../module.f.js";
11
+ import { do_, pure } from "../module.f.js";
12
12
  const doAll = do_('all');
13
13
  /**
14
14
  * To run the operation `O` should be known by the runner/engine.
@@ -31,6 +31,7 @@ export const createServer = do_('createServer');
31
31
  export const listen = do_('listen');
32
32
  export const forever = do_('forever');
33
33
  export const import_ = do_('import');
34
+ /** Emits a `Write` effect to the given named stream. */
34
35
  export const write = do_('write');
35
36
  /**
36
37
  * Encodes `s + '\n'` as UTF-8 and emits a `Write` effect to `stream`.
@@ -61,4 +62,6 @@ export const now = do_('now');
61
62
  * @see {@link SandboxResult}
62
63
  */
63
64
  export const sandbox = do_('sandbox');
65
+ const awaitPromise = do_('await');
66
+ export const awaitIfPromise = (p) => awaitPromise(p).step(([x]) => pure(x));
64
67
  export const test = do_('test');
@@ -1,4 +1,4 @@
1
- declare const _default: {
1
+ export declare const proof: {
2
2
  map: () => void;
3
3
  fetch: () => void;
4
4
  mkdir: {
@@ -36,4 +36,3 @@ declare const _default: {
36
36
  error: () => void;
37
37
  };
38
38
  };
39
- export default _default;
@@ -2,7 +2,7 @@ import { empty, isVec, uint, vec8 } from "../../bit_vec/module.f.js";
2
2
  import { pure } from "../module.f.js";
3
3
  import { fetch, mkdir, now, readdir, readFile, rm, sandbox, writeFile } from "./module.f.js";
4
4
  import { emptyState, virtual } from "./virtual/module.f.js";
5
- export default {
5
+ export const proof = {
6
6
  map: () => {
7
7
  let e = readFile('hello').step(([k, v]) => {
8
8
  if (k === 'error') {
@@ -167,6 +167,7 @@ const map = {
167
167
  // exception in a fixture propagates loudly as a bug in the fixture.
168
168
  // See: issues/156-tf-virtual-tests.md
169
169
  sandbox: (state, f) => [state, f()],
170
+ await: (state, p) => [state, [p]],
170
171
  test: todo,
171
172
  write: (state, stream, data) => {
172
173
  const s = utf8ToString(data);
@@ -0,0 +1,11 @@
1
+ export declare const proof: {
2
+ foldStep: {
3
+ empty: () => void;
4
+ threadsState: () => void;
5
+ order: () => void;
6
+ };
7
+ forEachStep: {
8
+ empty: () => void;
9
+ runs: () => void;
10
+ };
11
+ };
@@ -0,0 +1,57 @@
1
+ import { foldStep, forEachStep, pure } from "./module.f.js";
2
+ export const proof = {
3
+ foldStep: {
4
+ empty: () => {
5
+ const e = foldStep((x) => (s) => pure(s + x))(10)([]);
6
+ const { value } = e;
7
+ if (value.length !== 1) {
8
+ throw value;
9
+ }
10
+ if (value[0] !== 10) {
11
+ throw value[0];
12
+ }
13
+ },
14
+ threadsState: () => {
15
+ const e = foldStep((x) => (s) => pure(s + x))(0)([1, 2, 3, 4]);
16
+ const { value } = e;
17
+ if (value.length !== 1) {
18
+ throw value;
19
+ }
20
+ if (value[0] !== 10) {
21
+ throw value[0];
22
+ }
23
+ },
24
+ order: () => {
25
+ const e = foldStep((x) => (s) => pure(s + x))('')(['a', 'b', 'c']);
26
+ const { value } = e;
27
+ if (value.length !== 1) {
28
+ throw value;
29
+ }
30
+ if (value[0] !== 'abc') {
31
+ throw value[0];
32
+ }
33
+ },
34
+ },
35
+ forEachStep: {
36
+ empty: () => {
37
+ const e = forEachStep(() => pure(undefined))([]);
38
+ const { value } = e;
39
+ if (value.length !== 1) {
40
+ throw value;
41
+ }
42
+ if (value[0] !== undefined) {
43
+ throw value[0];
44
+ }
45
+ },
46
+ runs: () => {
47
+ const e = forEachStep(() => pure(undefined))([1, 2, 3]);
48
+ const { value } = e;
49
+ if (value.length !== 1) {
50
+ throw value;
51
+ }
52
+ if (value[0] !== undefined) {
53
+ throw value[0];
54
+ }
55
+ },
56
+ },
57
+ };
@@ -0,0 +1 @@
1
+ export declare const proof: () => void;
@@ -1,5 +1,5 @@
1
1
  import { cmp } from "./module.f.js";
2
- export default () => {
2
+ export const proof = () => {
3
3
  {
4
4
  const result = cmp(true)(false);
5
5
  if (result !== 1) {
@@ -0,0 +1,12 @@
1
+ export declare const proof: {
2
+ joinTest: () => void;
3
+ concatTest: () => void;
4
+ logicalNotTest: () => void;
5
+ strictEqualTest: () => void;
6
+ additionTest: () => void;
7
+ minTest: () => void;
8
+ maxTest: () => void;
9
+ incrementTest: () => void;
10
+ foldToScanTest: () => void;
11
+ reduceToScanTest: () => void;
12
+ };
@@ -1,17 +1,17 @@
1
1
  import { join, concat, logicalNot, strictEqual, addition, min, max, increment, foldToScan, reduceToScan, } from "./module.f.js";
2
- export const joinTest = () => {
2
+ const joinTest = () => {
3
3
  const result = join(', ')('world')('hello');
4
4
  if (result !== 'hello, world') {
5
5
  throw result;
6
6
  }
7
7
  };
8
- export const concatTest = () => {
8
+ const concatTest = () => {
9
9
  const result = concat('world')('hello');
10
10
  if (result !== 'helloworld') {
11
11
  throw result;
12
12
  }
13
13
  };
14
- export const logicalNotTest = () => {
14
+ const logicalNotTest = () => {
15
15
  if (logicalNot(true) !== false) {
16
16
  throw 'expected false';
17
17
  }
@@ -19,7 +19,7 @@ export const logicalNotTest = () => {
19
19
  throw 'expected true';
20
20
  }
21
21
  };
22
- export const strictEqualTest = () => {
22
+ const strictEqualTest = () => {
23
23
  if (!strictEqual(1)(1)) {
24
24
  throw 'expected true';
25
25
  }
@@ -27,13 +27,13 @@ export const strictEqualTest = () => {
27
27
  throw 'expected false';
28
28
  }
29
29
  };
30
- export const additionTest = () => {
30
+ const additionTest = () => {
31
31
  const result = addition(3)(4);
32
32
  if (result !== 7) {
33
33
  throw result;
34
34
  }
35
35
  };
36
- export const minTest = () => {
36
+ const minTest = () => {
37
37
  if (min(3)(5) !== 3) {
38
38
  throw 'min(3)(5)';
39
39
  }
@@ -41,7 +41,7 @@ export const minTest = () => {
41
41
  throw 'min(7)(2)';
42
42
  }
43
43
  };
44
- export const maxTest = () => {
44
+ const maxTest = () => {
45
45
  if (max(3)(5) !== 5) {
46
46
  throw 'max(3)(5)';
47
47
  }
@@ -49,7 +49,7 @@ export const maxTest = () => {
49
49
  throw 'max(7)(2)';
50
50
  }
51
51
  };
52
- export const incrementTest = () => {
52
+ const incrementTest = () => {
53
53
  if (increment(4) !== 5) {
54
54
  throw 'increment(4)';
55
55
  }
@@ -57,7 +57,7 @@ export const incrementTest = () => {
57
57
  throw 'increment(0)';
58
58
  }
59
59
  };
60
- export const foldToScanTest = () => {
60
+ const foldToScanTest = () => {
61
61
  const scan = foldToScan(addition)(0);
62
62
  const [v1, scan2] = scan(3);
63
63
  if (v1 !== 3) {
@@ -68,7 +68,7 @@ export const foldToScanTest = () => {
68
68
  throw v2;
69
69
  }
70
70
  };
71
- export const reduceToScanTest = () => {
71
+ const reduceToScanTest = () => {
72
72
  const scan = reduceToScan(addition);
73
73
  const [v0, scan2] = scan(10);
74
74
  if (v0 !== 10) {
@@ -79,3 +79,4 @@ export const reduceToScanTest = () => {
79
79
  throw v1;
80
80
  }
81
81
  };
82
+ export const proof = { joinTest, concatTest, logicalNotTest, strictEqualTest, additionTest, minTest, maxTest, incrementTest, foldToScanTest, reduceToScanTest };
@@ -0,0 +1 @@
1
+ export declare const proof: () => void;
@@ -1,5 +1,5 @@
1
1
  import { fn } from "./module.f.js";
2
- export default () => {
2
+ export const proof = () => {
3
3
  const f = x => [x];
4
4
  const g = ([x]) => [x.length];
5
5
  const w = ([x]) => x;
@@ -1,4 +1,4 @@
1
- declare const _default: {
1
+ export declare const proof: {
2
2
  stringifyTest: () => void;
3
3
  cycle: () => void;
4
4
  countdown: () => void;
@@ -19,4 +19,3 @@ declare const _default: {
19
19
  isEmpty: (() => void)[];
20
20
  length: () => void;
21
21
  };
22
- export default _default;
@@ -321,7 +321,7 @@ const stress = () => ({
321
321
  }
322
322
  }
323
323
  });
324
- export default {
324
+ export const proof = {
325
325
  stringifyTest,
326
326
  cycle: cycleTest,
327
327
  countdown: countdownTest,
@@ -0,0 +1,4 @@
1
+ export declare const proof: {
2
+ set: () => void;
3
+ delete: () => void;
4
+ };
@@ -1,5 +1,5 @@
1
1
  import { mapSet, mapDelete } from "./module.f.js";
2
- export default {
2
+ export const proof = {
3
3
  set: () => {
4
4
  const map = mapSet(new Map(), 'a', 'b');
5
5
  if (map.get('a') !== 'b') {
@@ -1,5 +1,4 @@
1
- declare const _default: {
1
+ export declare const proof: {
2
2
  numberAdd: () => void;
3
3
  stringConcat: () => void;
4
4
  };
5
- export default _default;
@@ -1,5 +1,5 @@
1
1
  import { repeat } from "./module.f.js";
2
- export default {
2
+ export const proof = {
3
3
  numberAdd: () => {
4
4
  const add = {
5
5
  identity: 0,
@@ -1,4 +1,4 @@
1
- declare const _default: {
1
+ export declare const proof: {
2
2
  has: () => void;
3
3
  set: (() => void)[];
4
4
  unset: () => (() => void)[];
@@ -9,4 +9,3 @@ declare const _default: {
9
9
  universe: () => void;
10
10
  };
11
11
  };
12
- export default _default;
@@ -1,6 +1,6 @@
1
1
  import { every, map, countdown } from "../list/module.f.js";
2
2
  import { empty, has, set, setRange, unset, universe, complement } from "./module.f.js";
3
- export default {
3
+ export const proof = {
4
4
  has: () => {
5
5
  if (has(0)(empty)) {
6
6
  throw empty;
@@ -0,0 +1,4 @@
1
+ export declare const proof: {
2
+ pre: () => void;
3
+ nominal: () => void;
4
+ };
@@ -1,5 +1,5 @@
1
1
  import { asBase, asNominal } from "./module.f.js";
2
- export default {
2
+ export const proof = {
3
3
  pre: () => {
4
4
  const strA = asNominal(7560413859n); // "¢£"
5
5
  const strB = asNominal(7560413860n); // "¢¤"
@@ -0,0 +1 @@
1
+ export declare const proof: (() => void)[];
@@ -1,5 +1,5 @@
1
1
  import { map, match, toOption } from "./module.f.js";
2
- export default [
2
+ export const proof = [
3
3
  () => {
4
4
  const optionSq = map((v) => v * v);
5
5
  const sq3 = optionSq(3);
@@ -1,4 +1,4 @@
1
- declare const _default: {
1
+ export declare const proof: {
2
2
  sum: () => void;
3
3
  min: {
4
4
  empty: () => void;
@@ -9,4 +9,3 @@ declare const _default: {
9
9
  standard: () => void;
10
10
  countOnes: (() => void)[];
11
11
  };
12
- export default _default;
@@ -1,5 +1,5 @@
1
1
  import { sum, min, max, cmp, countOnes } from "./module.f.js";
2
- export default {
2
+ export const proof = {
3
3
  sum: () => {
4
4
  const result = sum([2, 3, 4, 5]);
5
5
  if (result !== 14) {
@@ -1,5 +1,4 @@
1
- declare const _default: {
1
+ export declare const proof: {
2
2
  ctor: () => void;
3
3
  property: () => void;
4
4
  };
5
- export default _default;
@@ -1,5 +1,5 @@
1
1
  import { at } from "./module.f.js";
2
- export default {
2
+ export const proof = {
3
3
  ctor: () => {
4
4
  const a = {};
5
5
  const value = at('constructor')(a);
@@ -1,5 +1,4 @@
1
- declare const _default: {
1
+ export declare const proof: {
2
2
  main: (() => void)[];
3
3
  stress: () => void;
4
4
  };
5
- export default _default;
@@ -1,6 +1,6 @@
1
1
  import { at, setReplace, setReduce, empty, entries, remove } from "./module.f.js";
2
2
  import { toArray } from "../list/module.f.js";
3
- export default {
3
+ export const proof = {
4
4
  main: [
5
5
  () => {
6
6
  let m = setReplace('a')(1)(null);
@@ -1,8 +1,7 @@
1
- declare const _default: {
1
+ export declare const proof: {
2
2
  empty: () => void;
3
3
  singleLeaf: () => void;
4
4
  twoLeaves: () => void;
5
5
  descending: () => void;
6
6
  ascending: () => void;
7
7
  };
8
- export default _default;
@@ -112,7 +112,7 @@ const ascending = () => runExample([
112
112
  [119n, 179n, 200n, 227n, 242n],
113
113
  [119n, 179n, 200n, 227n, 242n, 249n],
114
114
  ], [0, 0, 0, 2, 1, 0, 1, 0, 3, 0, 0, 1, 2, 0, 0, 0]);
115
- export default {
115
+ export const proof = {
116
116
  empty,
117
117
  singleLeaf,
118
118
  twoLeaves,
@@ -1,4 +1,4 @@
1
- declare const _default: {
1
+ export declare const proof: {
2
2
  prime_field_test: () => {
3
3
  neg: () => void;
4
4
  sub: () => void;
@@ -10,4 +10,3 @@ declare const _default: {
10
10
  sqrt: () => void;
11
11
  };
12
12
  };
13
- export default _default;
@@ -1,5 +1,5 @@
1
1
  import { prime_field, sqrt } from "./module.f.js";
2
- export default {
2
+ export const proof = {
3
3
  prime_field_test: () => {
4
4
  const p = 0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2fn;
5
5
  const f = prime_field(p);
@@ -0,0 +1 @@
1
+ export declare const proof: () => void;
@@ -1,5 +1,5 @@
1
1
  import { contains } from "./module.f.js";
2
- export default () => {
2
+ export const proof = () => {
3
3
  if (!contains([0, 5])(1)) {
4
4
  throw 1;
5
5
  }
@@ -1,7 +1,6 @@
1
- declare const _default: {
1
+ export declare const proof: {
2
2
  example: () => void;
3
3
  merge: (() => void)[];
4
4
  get: () => (() => void)[];
5
5
  fromRange: () => (() => void)[];
6
6
  };
7
- export default _default;
@@ -11,7 +11,7 @@ const op = {
11
11
  equal: equal(strictEqual),
12
12
  def: []
13
13
  };
14
- export default {
14
+ export const proof = {
15
15
  example: () => {
16
16
  const rmOps = rangeMap({
17
17
  union: a => b => a | b,
@@ -0,0 +1,5 @@
1
+ export declare const proof: {
2
+ example: () => void;
3
+ invertTest: () => void;
4
+ unwrapError: () => void;
5
+ };
@@ -1,5 +1,5 @@
1
1
  import { error, ok, unwrap, invert } from "./module.f.js";
2
- export const example = () => {
2
+ const example = () => {
3
3
  const success = ok(42);
4
4
  const failure = error('Something went wrong');
5
5
  if (unwrap(success) !== 42) {
@@ -14,7 +14,7 @@ export const example = () => {
14
14
  throw 'error';
15
15
  }
16
16
  };
17
- export const invertTest = () => {
17
+ const invertTest = () => {
18
18
  const [k0, v0] = invert(ok(42));
19
19
  if (k0 !== 'error' || v0 !== 42) {
20
20
  throw [k0, v0];
@@ -24,3 +24,19 @@ export const invertTest = () => {
24
24
  throw [k1, v1];
25
25
  }
26
26
  };
27
+ const unwrapError = () => {
28
+ let caught = false;
29
+ try {
30
+ unwrap(error('oops'));
31
+ }
32
+ catch (e) {
33
+ if (e !== 'oops') {
34
+ throw e;
35
+ }
36
+ caught = true;
37
+ }
38
+ if (!caught) {
39
+ throw 'expected throw';
40
+ }
41
+ };
42
+ export const proof = { example, invertTest, unwrapError };
@@ -1,4 +1,4 @@
1
- declare const _default: {
1
+ export declare const proof: {
2
2
  boolean: {
3
3
  ok: () => void;
4
4
  error: () => void;
@@ -113,4 +113,3 @@ declare const _default: {
113
113
  recordOfRecords: () => void;
114
114
  };
115
115
  };
116
- export default _default;
@@ -55,7 +55,7 @@ const assertDeepEqual = (a, b) => {
55
55
  }
56
56
  throw `not deep-equal: ${String(a)} vs ${String(b)}`;
57
57
  };
58
- export default {
58
+ export const proof = {
59
59
  boolean: {
60
60
  ok: () => {
61
61
  assertOk(parse(boolean)(true));
@@ -1,6 +1,5 @@
1
- declare const _default: {
1
+ export declare const proof: {
2
2
  typeof: {
3
3
  [k: string]: (() => void)[];
4
4
  };
5
5
  };
6
- export default _default;
@@ -7,7 +7,7 @@ const tests = {
7
7
  object: [null, {}, []],
8
8
  function: [() => undefined]
9
9
  };
10
- export default {
10
+ export const proof = {
11
11
  typeof: Object.fromEntries(Object.entries(tests).map(([k, a]) => [k, a.map(v => () => {
12
12
  if (typeof v !== k) {
13
13
  throw `typeof ${v} !== ${k}`;