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.
- package/fs/asn.1/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/asn.1/{test.f.js → proof.f.js} +1 -1
- package/fs/base128/proof.f.d.ts +1 -0
- package/fs/base128/{test.f.js → proof.f.js} +1 -1
- package/fs/bnf/data/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/bnf/data/{test.f.js → proof.f.js} +1 -1
- package/fs/bnf/proof.f.d.ts +3 -0
- package/fs/bnf/{test.f.js → proof.f.js} +1 -1
- package/fs/cas/module.f.js +2 -12
- package/fs/cas/proof.f.d.ts +1 -0
- package/fs/cas/proof.f.js +1 -0
- package/fs/cbase32/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/cbase32/{test.f.js → proof.f.js} +1 -1
- package/fs/ci/node/module.f.js +12 -7
- package/fs/ci/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/ci/{test.f.js → proof.f.js} +1 -1
- package/fs/crypto/hmac/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/crypto/hmac/{test.f.js → proof.f.js} +1 -1
- package/fs/crypto/secp/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/crypto/secp/{test.f.js → proof.f.js} +1 -1
- package/fs/crypto/sha2/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/crypto/sha2/{test.f.js → proof.f.js} +1 -1
- package/fs/crypto/sign/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/crypto/sign/{test.f.js → proof.f.js} +1 -1
- package/fs/dev/module.f.d.ts +28 -2
- package/fs/dev/module.f.js +38 -22
- package/fs/dev/{test.f.d.ts → proof.f.d.ts} +5 -2
- package/fs/dev/{test.f.js → proof.f.js} +25 -2
- package/fs/dev/tf/module.f.d.ts +63 -5
- package/fs/dev/tf/module.f.js +77 -20
- package/fs/dev/tf/{test.f.d.ts → proof.f.d.ts} +26 -0
- package/fs/dev/tf/{test.f.js → proof.f.js} +76 -34
- package/fs/dev/tf/scenarios/async-subtests.fail.d.ts +4 -0
- package/fs/dev/tf/scenarios/async-subtests.fail.js +7 -0
- package/fs/dev/tf/scenarios/async-subtests.pass.d.ts +4 -0
- package/fs/dev/tf/scenarios/async-subtests.pass.js +7 -0
- package/fs/dev/tf/scenarios/async.fail.d.ts +1 -0
- package/fs/dev/tf/scenarios/async.fail.js +4 -0
- package/fs/dev/tf/scenarios/async.pass.d.ts +1 -0
- package/fs/dev/tf/scenarios/async.pass.js +3 -0
- package/fs/dev/tf/scenarios/thenable.pass.d.ts +3 -0
- package/fs/dev/tf/scenarios/thenable.pass.js +9 -0
- package/fs/dev/tf/scenarios/thenable2.pass.f.d.ts +3 -0
- package/fs/dev/tf/scenarios/thenable2.pass.f.js +3 -0
- package/fs/dev/version/proof.f.d.ts +3 -0
- package/fs/dev/version/{test.f.js → proof.f.js} +1 -1
- package/fs/djs/ast/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/djs/ast/{test.f.js → proof.f.js} +1 -1
- package/fs/djs/parser/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/djs/parser/{test.f.js → proof.f.js} +1 -1
- package/fs/djs/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/djs/{test.f.js → proof.f.js} +1 -1
- package/fs/djs/serializer/module.f.d.ts +2 -2
- package/fs/djs/serializer/module.f.js +47 -79
- package/fs/djs/serializer/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/djs/serializer/{test.f.js → proof.f.js} +8 -8
- package/fs/djs/tokenizer/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/djs/tokenizer/{test.f.js → proof.f.js} +1 -1
- package/fs/djs/tokenizer-new/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/djs/tokenizer-new/{test.f.js → proof.f.js} +1 -1
- package/fs/djs/transpiler/module.f.d.ts +15 -0
- package/fs/djs/transpiler/module.f.js +10 -2
- package/fs/djs/transpiler/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/djs/transpiler/{test.f.js → proof.f.js} +1 -1
- package/fs/fsc/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/fsc/{test.f.js → proof.f.js} +1 -1
- package/fs/fsm/proof.f.d.ts +4 -0
- package/fs/fsm/{test.f.js → proof.f.js} +1 -1
- package/fs/html/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/html/{test.f.js → proof.f.js} +1 -1
- package/fs/io/module.d.ts +1 -1
- package/fs/io/module.f.d.ts +3 -2
- package/fs/io/module.f.js +4 -3
- package/fs/io/module.js +19 -11
- package/fs/js/tokenizer/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/js/tokenizer/{test.f.js → proof.f.js} +1 -1
- package/fs/json/parser/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/json/parser/{test.f.js → proof.f.js} +1 -1
- package/fs/json/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/json/{test.f.js → proof.f.js} +1 -1
- package/fs/json/serializer/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/json/serializer/{test.f.js → proof.f.js} +1 -1
- package/fs/json/tokenizer/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/json/tokenizer/{test.f.js → proof.f.js} +1 -1
- package/fs/path/proof.f.d.ts +5 -0
- package/fs/path/{test.f.js → proof.f.js} +4 -3
- package/fs/sul/id/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/sul/id/{test.f.js → proof.f.js} +1 -1
- package/fs/sul/level/hash/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/sul/level/hash/{test.f.js → proof.f.js} +1 -1
- package/fs/sul/level/literal/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/sul/level/literal/{test.f.js → proof.f.js} +1 -1
- package/fs/sul/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/sul/{test.f.js → proof.f.js} +1 -1
- package/fs/text/ascii/proof.f.d.ts +3 -0
- package/fs/text/ascii/{test.f.js → proof.f.js} +1 -1
- package/fs/text/code_point/module.f.d.ts +28 -0
- package/fs/text/code_point/module.f.js +31 -0
- package/fs/text/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/text/{test.f.js → proof.f.js} +1 -1
- package/fs/text/sgr/proof.f.d.ts +1 -0
- package/fs/text/sgr/{test.f.js → proof.f.js} +1 -1
- package/fs/text/utf16/module.f.js +3 -53
- package/fs/text/utf16/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/text/utf16/{test.f.js → proof.f.js} +1 -1
- package/fs/text/utf8/module.f.js +3 -25
- package/fs/text/utf8/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/text/utf8/{test.f.js → proof.f.js} +1 -1
- package/fs/types/array/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/types/array/{test.f.js → proof.f.js} +1 -1
- package/fs/types/bigfloat/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/types/bigfloat/{test.f.js → proof.f.js} +1 -1
- package/fs/types/bigint/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/types/bigint/{test.f.js → proof.f.js} +1 -1
- package/fs/types/bit_vec/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/types/bit_vec/{test.f.js → proof.f.js} +1 -1
- package/fs/types/btree/find/proof.f.d.ts +1 -0
- package/fs/types/btree/find/{test.f.js → proof.f.js} +1 -1
- package/fs/types/btree/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/types/btree/{test.f.js → proof.f.js} +1 -1
- package/fs/types/btree/remove/proof.f.d.ts +4 -0
- package/fs/types/btree/remove/{test.f.js → proof.f.js} +1 -1
- package/fs/types/btree/set/proof.f.d.ts +1 -0
- package/fs/types/btree/set/{test.f.js → proof.f.js} +1 -1
- package/fs/types/btree/types/module.f.d.ts +8 -0
- package/fs/types/btree/types/module.f.js +8 -0
- package/fs/types/byte_set/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/types/byte_set/{test.f.js → proof.f.js} +1 -1
- package/fs/types/effects/module.f.d.ts +17 -0
- package/fs/types/effects/module.f.js +17 -0
- package/fs/types/effects/node/module.f.d.ts +54 -5
- package/fs/types/effects/node/module.f.js +4 -1
- package/fs/types/effects/node/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/types/effects/node/{test.f.js → proof.f.js} +1 -1
- package/fs/types/effects/node/virtual/module.f.js +1 -0
- package/fs/types/effects/proof.f.d.ts +11 -0
- package/fs/types/effects/proof.f.js +57 -0
- package/fs/types/function/compare/proof.f.d.ts +1 -0
- package/fs/types/function/compare/{test.f.js → proof.f.js} +1 -1
- package/fs/types/function/operator/proof.f.d.ts +12 -0
- package/fs/types/function/operator/{test.f.js → proof.f.js} +11 -10
- package/fs/types/function/proof.f.d.ts +1 -0
- package/fs/types/function/{test.f.js → proof.f.js} +1 -1
- package/fs/types/list/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/types/list/{test.f.js → proof.f.js} +1 -1
- package/fs/types/map/proof.f.d.ts +4 -0
- package/fs/types/map/{test.f.js → proof.f.js} +1 -1
- package/fs/types/monoid/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/types/monoid/{test.f.js → proof.f.js} +1 -1
- package/fs/types/nibble_set/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/types/nibble_set/{test.f.js → proof.f.js} +1 -1
- package/fs/types/nominal/proof.f.d.ts +4 -0
- package/fs/types/nominal/{test.f.js → proof.f.js} +1 -1
- package/fs/types/nullable/proof.f.d.ts +1 -0
- package/fs/types/nullable/{test.f.js → proof.f.js} +1 -1
- package/fs/types/number/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/types/number/{test.f.js → proof.f.js} +1 -1
- package/fs/types/object/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/types/object/{test.f.js → proof.f.js} +1 -1
- package/fs/types/ordered_map/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/types/ordered_map/{test.f.js → proof.f.js} +1 -1
- package/fs/types/patricia_trie/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/types/patricia_trie/{test.f.js → proof.f.js} +1 -1
- package/fs/types/prime_field/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/types/prime_field/{test.f.js → proof.f.js} +1 -1
- package/fs/types/range/proof.f.d.ts +1 -0
- package/fs/types/range/{test.f.js → proof.f.js} +1 -1
- package/fs/types/range_map/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/types/range_map/{test.f.js → proof.f.js} +1 -1
- package/fs/types/result/proof.f.d.ts +5 -0
- package/fs/types/result/{test.f.js → proof.f.js} +18 -2
- package/fs/types/rtti/parse/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/types/rtti/parse/{test.f.js → proof.f.js} +1 -1
- package/fs/types/rtti/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/types/rtti/{test.f.js → proof.f.js} +1 -1
- package/fs/types/rtti/ts/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/types/rtti/ts/{test.f.js → proof.f.js} +1 -1
- package/fs/types/rtti/validate/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/types/rtti/validate/{test.f.js → proof.f.js} +1 -1
- package/fs/types/sorted_list/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/types/sorted_list/{test.f.js → proof.f.js} +1 -1
- package/fs/types/sorted_set/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/types/sorted_set/{test.f.js → proof.f.js} +1 -1
- package/fs/types/string/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/types/string/{test.f.js → proof.f.js} +1 -1
- package/fs/types/string_set/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/types/string_set/{test.f.js → proof.f.js} +1 -1
- package/fs/types/ts/{test.f.d.ts → proof.f.d.ts} +20 -0
- package/fs/types/ts/{test.f.js → proof.f.js} +1 -0
- package/fs/types/uint8array/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/fs/types/uint8array/{test.f.js → proof.f.js} +1 -1
- package/issues/demo/sample/{test.f.js → proof.f.js} +1 -1
- package/issues/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/issues/{test.f.js → proof.f.js} +1 -1
- package/nanvm-lib/tests/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/nanvm-lib/tests/{test.f.js → proof.f.js} +1 -1
- package/nanvm-lib/tests/vm/{test.f.d.ts → proof.f.d.ts} +1 -2
- package/nanvm-lib/tests/vm/{test.f.js → proof.f.js} +1 -1
- package/package.json +2 -2
- package/fs/base128/test.f.d.ts +0 -2
- package/fs/bnf/test.f.d.ts +0 -4
- package/fs/cas/test.f.d.ts +0 -2
- package/fs/cas/test.f.js +0 -1
- package/fs/dev/version/test.f.d.ts +0 -4
- package/fs/fsm/test.f.d.ts +0 -5
- package/fs/path/test.f.d.ts +0 -3
- package/fs/text/ascii/test.f.d.ts +0 -4
- package/fs/text/sgr/test.f.d.ts +0 -2
- package/fs/types/btree/find/test.f.d.ts +0 -2
- package/fs/types/btree/remove/test.f.d.ts +0 -5
- package/fs/types/btree/set/test.f.d.ts +0 -2
- package/fs/types/function/compare/test.f.d.ts +0 -2
- package/fs/types/function/operator/test.f.d.ts +0 -10
- package/fs/types/function/test.f.d.ts +0 -2
- package/fs/types/map/test.f.d.ts +0 -5
- package/fs/types/nominal/test.f.d.ts +0 -5
- package/fs/types/nullable/test.f.d.ts +0 -2
- package/fs/types/range/test.f.d.ts +0 -2
- 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
|
-
*
|
|
94
|
-
*
|
|
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
|
-
|
|
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');
|
|
@@ -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
|
|
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,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;
|
|
@@ -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
|
-
|
|
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
|
-
|
|
8
|
+
const concatTest = () => {
|
|
9
9
|
const result = concat('world')('hello');
|
|
10
10
|
if (result !== 'helloworld') {
|
|
11
11
|
throw result;
|
|
12
12
|
}
|
|
13
13
|
};
|
|
14
|
-
|
|
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
|
-
|
|
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
|
-
|
|
30
|
+
const additionTest = () => {
|
|
31
31
|
const result = addition(3)(4);
|
|
32
32
|
if (result !== 7) {
|
|
33
33
|
throw result;
|
|
34
34
|
}
|
|
35
35
|
};
|
|
36
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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,4 +1,4 @@
|
|
|
1
|
-
declare const
|
|
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;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const proof: (() => void)[];
|
|
@@ -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
|
|
115
|
+
export const proof = {
|
|
116
116
|
empty,
|
|
117
117
|
singleLeaf,
|
|
118
118
|
twoLeaves,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const proof: () => void;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { error, ok, unwrap, invert } from "./module.f.js";
|
|
2
|
-
|
|
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
|
-
|
|
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 };
|
|
@@ -7,7 +7,7 @@ const tests = {
|
|
|
7
7
|
object: [null, {}, []],
|
|
8
8
|
function: [() => undefined]
|
|
9
9
|
};
|
|
10
|
-
export
|
|
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}`;
|