functionalscript 0.16.1 → 0.18.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/module.f.js +6 -0
- package/fs/ci/bun/module.f.js +6 -0
- package/fs/ci/common/module.f.d.ts +11 -5
- package/fs/ci/common/module.f.js +11 -4
- package/fs/ci/config/module.f.d.ts +11 -4
- package/fs/ci/config/module.f.js +11 -4
- package/fs/ci/deno/module.f.js +6 -0
- package/fs/ci/node/module.f.js +6 -0
- package/fs/ci/playwright/module.f.js +6 -0
- package/fs/ci/rust/module.f.js +7 -0
- package/fs/ci/test.f.js +2 -4
- package/fs/crypto/secp/module.f.d.ts +7 -0
- package/fs/dev/index/module.f.d.ts +6 -0
- package/fs/dev/index/module.f.js +6 -0
- package/fs/dev/module.f.d.ts +4 -3
- package/fs/dev/module.f.js +13 -11
- package/fs/dev/tf/module.d.ts +1 -0
- package/fs/dev/tf/module.f.d.ts +70 -22
- package/fs/dev/tf/module.f.js +134 -97
- package/fs/dev/tf/module.js +66 -16
- package/fs/dev/tf/test.f.d.ts +21 -20
- package/fs/dev/tf/test.f.js +249 -31
- package/fs/djs/module.f.d.ts +5 -2
- package/fs/djs/module.f.js +16 -21
- package/fs/djs/test.f.d.ts +11 -0
- package/fs/djs/test.f.js +74 -0
- package/fs/djs/tokenizer-new/test.f.js +126 -78
- package/fs/djs/transpiler/module.f.d.ts +3 -3
- package/fs/djs/transpiler/module.f.js +34 -29
- package/fs/djs/transpiler/test.f.js +19 -26
- package/fs/fjs/module.f.d.ts +2 -7
- package/fs/fjs/module.f.js +17 -17
- package/fs/fjs/module.js +2 -2
- package/fs/html/module.f.d.ts +6 -0
- package/fs/html/module.f.js +6 -0
- package/fs/io/module.d.ts +3 -3
- package/fs/io/module.f.d.ts +8 -2
- package/fs/io/module.f.js +25 -4
- package/fs/io/module.js +54 -15
- package/fs/js/tokenizer/module.f.js +7 -0
- package/fs/json/module.f.d.ts +7 -0
- package/fs/json/module.f.js +7 -0
- package/fs/path/module.f.d.ts +6 -0
- package/fs/path/module.f.js +6 -0
- package/fs/path/test.f.d.ts +3 -5
- package/fs/path/test.f.js +67 -49
- package/fs/text/module.f.d.ts +7 -0
- package/fs/text/module.f.js +7 -0
- package/fs/text/sgr/module.f.d.ts +9 -1
- package/fs/text/sgr/module.f.js +16 -5
- package/fs/text/utf16/module.f.d.ts +7 -0
- package/fs/text/utf16/module.f.js +7 -0
- package/fs/types/effects/node/module.f.d.ts +51 -9
- package/fs/types/effects/node/module.f.js +39 -2
- package/fs/types/effects/node/test.f.d.ts +4 -0
- package/fs/types/effects/node/test.f.js +33 -6
- package/fs/types/effects/node/virtual/module.f.d.ts +12 -3
- package/fs/types/effects/node/virtual/module.f.js +32 -9
- package/fs/types/function/compare/module.f.d.ts +12 -0
- package/fs/types/function/compare/module.f.js +33 -0
- package/fs/types/function/operator/test.f.d.ts +10 -0
- package/fs/types/function/operator/test.f.js +81 -0
- package/fs/types/monoid/module.f.d.ts +7 -0
- package/fs/types/number/module.f.d.ts +6 -0
- package/fs/types/number/module.f.js +6 -0
- package/fs/types/object/module.f.js +7 -0
- package/fs/types/prime_field/module.f.d.ts +8 -0
- package/fs/types/range_map/module.f.js +3 -18
- package/fs/types/result/module.f.d.ts +4 -0
- package/fs/types/result/module.f.js +4 -0
- package/fs/types/result/test.f.d.ts +2 -4
- package/fs/types/result/test.f.js +24 -16
- package/fs/types/rtti/common/module.f.d.ts +10 -1
- package/fs/types/rtti/common/module.f.js +7 -2
- package/fs/types/rtti/parse/module.f.js +35 -46
- package/fs/types/rtti/validate/module.f.js +9 -12
- package/fs/types/sorted_list/module.f.d.ts +1 -2
- package/fs/types/sorted_list/module.f.js +8 -21
- package/fs/types/sorted_set/module.f.d.ts +1 -3
- package/fs/types/ts/module.f.d.ts +7 -0
- package/fs/types/ts/test.f.d.ts +18 -0
- package/fs/types/ts/test.f.js +111 -0
- package/fs/types/uint8array/module.f.js +7 -1
- package/fs/types/uint8array/test.f.d.ts +1 -0
- package/fs/types/uint8array/test.f.js +5 -1
- package/package.json +3 -2
- package/fs/io/virtual/module.f.d.ts +0 -8
- package/fs/io/virtual/module.f.js +0 -43
package/fs/dev/tf/module.f.js
CHANGED
|
@@ -3,9 +3,11 @@
|
|
|
3
3
|
*
|
|
4
4
|
* @module
|
|
5
5
|
*/
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
6
|
+
import { reset, fgGreen, fgRed, bold, csiWrite } from "../../text/sgr/module.f.js";
|
|
7
|
+
import { all, sandbox } from "../../types/effects/node/module.f.js";
|
|
8
|
+
import { pure } from "../../types/effects/module.f.js";
|
|
9
|
+
import { loadModuleMap } from "../module.f.js";
|
|
10
|
+
import { invert } from "../../types/result/module.f.js";
|
|
9
11
|
export const isTest = (s) => s.endsWith('test.f.js') || s.endsWith('test.f.ts');
|
|
10
12
|
const addPass = (delta) => (ts) => ({ ...ts, time: ts.time + delta, pass: ts.pass + 1 });
|
|
11
13
|
const addFail = (delta) => (ts) => ({ ...ts, time: ts.time + delta, fail: ts.fail + 1 });
|
|
@@ -18,24 +20,12 @@ const timeFormat = (a) => {
|
|
|
18
20
|
const e = x.substring(s);
|
|
19
21
|
return `${b}.${e} ms`;
|
|
20
22
|
};
|
|
21
|
-
export const parseTestSet = (
|
|
23
|
+
export const parseTestSet = (throws, x) => {
|
|
22
24
|
switch (typeof x) {
|
|
23
25
|
case 'function': {
|
|
24
26
|
if (x.length === 0) {
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
return xt;
|
|
28
|
-
}
|
|
29
|
-
// Pass-on-throw: the test passes if it throws. Triggered when the
|
|
30
|
-
// enclosing tree node is named 'throw' (so any function reference
|
|
31
|
-
// works, not only inline ones whose inferred name is 'throw').
|
|
32
|
-
return () => {
|
|
33
|
-
const [tag, value] = t(xt);
|
|
34
|
-
if (tag === 'ok') {
|
|
35
|
-
throw value;
|
|
36
|
-
}
|
|
37
|
-
return value;
|
|
38
|
-
};
|
|
27
|
+
const fn = x;
|
|
28
|
+
return { fn, throws: throws || fn.name === 'throw' };
|
|
39
29
|
}
|
|
40
30
|
break;
|
|
41
31
|
}
|
|
@@ -48,88 +38,135 @@ export const parseTestSet = (t) => (throws) => (x) => {
|
|
|
48
38
|
}
|
|
49
39
|
return [];
|
|
50
40
|
};
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
41
|
+
/**
|
|
42
|
+
* Recursively collects all leaf tests reachable from `v` as `[path, entry]`
|
|
43
|
+
* pairs, without running anything. Return-value sub-trees are not walked
|
|
44
|
+
* (that requires execution); only the static object/array/function structure
|
|
45
|
+
* is traversed.
|
|
46
|
+
*/
|
|
47
|
+
export const collectTests = (path, throws, v) => {
|
|
48
|
+
const set = parseTestSet(throws, v);
|
|
49
|
+
if (set instanceof Array) {
|
|
50
|
+
return set.flatMap(([ck, cv]) => collectTests([...path, ck], throws || ck === 'throw', cv));
|
|
51
|
+
}
|
|
52
|
+
return [[path, set]];
|
|
53
|
+
};
|
|
54
|
+
const mergeState = (a, b) => ({ time: a.time + b.time, pass: a.pass + b.pass, fail: a.fail + b.fail });
|
|
55
|
+
const zero = { time: 0, pass: 0, fail: 0 };
|
|
56
|
+
const runModule = ({ result, test }) => (k, v) => (ts) => {
|
|
57
|
+
const walk = (path, throws, v) => {
|
|
58
|
+
const effects = collectTests(path, throws, v)
|
|
59
|
+
.map(([testPath, set]) => test(k, testPath, set)
|
|
60
|
+
.step(sr => {
|
|
61
|
+
const { result: [s, r], duration } = sr;
|
|
62
|
+
return result(k, testPath, sr)
|
|
63
|
+
.step(() => {
|
|
64
|
+
if (s === 'ok') {
|
|
65
|
+
if (set.throws) {
|
|
66
|
+
return pure(addPass(duration)(zero));
|
|
72
67
|
}
|
|
68
|
+
// Walk return-value sub-tree; null marks the call boundary so
|
|
69
|
+
// paths render as e.g. `outer().inner`. throws resets to false.
|
|
70
|
+
return walk([...testPath, null], false, r)
|
|
71
|
+
.step(sub => pure(mergeState(addPass(duration)(zero), sub)));
|
|
73
72
|
}
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
[ts, state] = next(false)(r)([ts, state]);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
else {
|
|
83
|
-
const f = ([k, v]) => ([time, state]) => {
|
|
84
|
-
log(`${i}${k}:`);
|
|
85
|
-
[time, state] = next(throws || k === 'throw')(v)([time, state]);
|
|
86
|
-
return [time, state];
|
|
87
|
-
};
|
|
88
|
-
[ts, state] = fold(f)([ts, state])(set);
|
|
89
|
-
}
|
|
90
|
-
return [ts, state];
|
|
91
|
-
};
|
|
92
|
-
return ([ts, state]) => {
|
|
93
|
-
if (isTest(k)) {
|
|
94
|
-
log(`testing ${k}`);
|
|
95
|
-
[ts, state] = test('| ')(false)(v.default)([ts, state]);
|
|
96
|
-
// Non-default exports are walked as a sibling test group so
|
|
97
|
-
// a test file can spread its tests across multiple named
|
|
98
|
-
// exports (see issue 27 in `issues/README.md`). Skip exports
|
|
99
|
-
// that parseTestSet would treat as empty (constants, types,
|
|
100
|
-
// non-test helpers) to avoid noisy empty entries in output.
|
|
101
|
-
const others = Object.fromEntries(Object.entries(v).filter(([key, val]) => key !== 'default' && ((typeof val === 'function' && val.length === 0) ||
|
|
102
|
-
(typeof val === 'object' && val !== null))));
|
|
103
|
-
if (Object.keys(others).length !== 0) {
|
|
104
|
-
[ts, state] = test('| ')(false)(others)([ts, state]);
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
return [ts, state];
|
|
108
|
-
};
|
|
73
|
+
return pure(addFail(duration)(zero));
|
|
74
|
+
});
|
|
75
|
+
}));
|
|
76
|
+
return all(...effects)
|
|
77
|
+
.step(states => pure(states.reduce(mergeState, zero)));
|
|
109
78
|
};
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
79
|
+
return walk([], false, v)
|
|
80
|
+
.step(delta => pure(mergeState(ts, delta)));
|
|
81
|
+
};
|
|
82
|
+
const { entries } = Object;
|
|
83
|
+
export const runModuleMap = (reporter) => (moduleMap) => {
|
|
84
|
+
const { summary } = reporter;
|
|
85
|
+
const modules = entries(moduleMap).filter(([k]) => isTest(k));
|
|
86
|
+
return modules.reduce((acc, [k, v]) => acc.step(runModule(reporter)(k, v)), pure({ time: 0, pass: 0, fail: 0 }))
|
|
87
|
+
.step(ts => summary(ts.pass, ts.fail, ts.time)
|
|
88
|
+
.step(() => pure(ts.fail !== 0 ? 1 : 0)));
|
|
116
89
|
};
|
|
117
|
-
export const
|
|
118
|
-
|
|
119
|
-
|
|
90
|
+
export const test = (reporter) => options => loadModuleMap(options.env).step(runModuleMap(reporter));
|
|
91
|
+
const isAlpha = (c) => (c >= 'A' && c <= 'Z') || (c >= 'a' && c <= 'z') || c === '_' || c === '$';
|
|
92
|
+
const isDigit = (c) => c >= '0' && c <= '9';
|
|
93
|
+
export const isInteger = (s) => s.length > 0 && [...s].every(isDigit) && (s === '0' || s[0] !== '0');
|
|
94
|
+
export const isIdentifier = (s) => s.length > 0 && isAlpha(s[0]) && [...s.slice(1)].every(c => isAlpha(c) || isDigit(c));
|
|
95
|
+
const fmtKey = (k) => k === null ? '()'
|
|
96
|
+
: isInteger(k) ? `[${k}]`
|
|
97
|
+
: isIdentifier(k) ? `.${k}`
|
|
98
|
+
: `[${JSON.stringify(k)}]`;
|
|
99
|
+
/**
|
|
100
|
+
* Renders a key chain as a JS property-access expression: identifier keys use
|
|
101
|
+
* dot notation, integer keys use `[N]`, other strings use `["key"]`, and `null`
|
|
102
|
+
* emits `()` to mark a function-call boundary.
|
|
103
|
+
* E.g. `['math', 'add']` → `.math.add`, `['outer', null, 'inner']` → `.outer().inner`.
|
|
104
|
+
*/
|
|
105
|
+
export const fmtPath = (path) => path.reduce((acc, k) => acc + fmtKey(k), '');
|
|
106
|
+
/**
|
|
107
|
+
* Formats a fully-qualified test identifier as a JS-like expression, e.g.
|
|
108
|
+
* `import("./math.test.f.ts").add()` or `import("./a.test.f.ts").users[3].name()`.
|
|
109
|
+
* Self-contained per line — suitable for parallel output and as a CLI filter argument.
|
|
110
|
+
*/
|
|
111
|
+
export const fmtImport = (file, path) => `import(${JSON.stringify(file)})${fmtPath(path)}()`;
|
|
112
|
+
/**
|
|
113
|
+
* Renders a key chain for terminal output: `| ` per level of depth, followed
|
|
114
|
+
* by the last segment formatted as a bare integer, a bare identifier, or a
|
|
115
|
+
* JSON-quoted string. E.g. `['math', 'add']` → `| | add`,
|
|
116
|
+
* `['a', '0']` → `| | 0`, `['x', 'hello world']` → `| | "hello world"`.
|
|
117
|
+
*/
|
|
118
|
+
export const fmtTerm = (path) => {
|
|
119
|
+
const keys = path.flatMap(k => k !== null ? [k] : []);
|
|
120
|
+
const indent = '| '.repeat(keys.length);
|
|
121
|
+
if (keys.length === 0) {
|
|
122
|
+
return `${indent}()`;
|
|
123
|
+
}
|
|
124
|
+
const last = keys[keys.length - 1];
|
|
125
|
+
return `${indent}${isInteger(last) || isIdentifier(last) ? last : JSON.stringify(last)}`;
|
|
120
126
|
};
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
127
|
+
/**
|
|
128
|
+
* Percent-encodes characters that GitHub workflow-command property values
|
|
129
|
+
* treat as separators (`%`, `:`, `,`) plus newlines.
|
|
130
|
+
* https://docs.github.com/en/actions/learn-github-actions/workflow-commands-for-github-actions
|
|
131
|
+
*/
|
|
132
|
+
export const ghEscape = (s) => s.replaceAll('%', '%25')
|
|
133
|
+
.replaceAll(':', '%3A')
|
|
134
|
+
.replaceAll(',', '%2C')
|
|
135
|
+
.replaceAll('\r', '%0D')
|
|
136
|
+
.replaceAll('\n', '%0A');
|
|
137
|
+
export const defaultTest = (file, path, { fn, throws }) => sandbox(fn)
|
|
138
|
+
.step(r => pure(throws ? { ...r, result: invert(r.result) } : r));
|
|
139
|
+
const fmtResultLine = (file, path, color, label, duration) => `${fmtImport(file, path)}: ${color}${label}${reset}, ${timeFormat(duration)}`;
|
|
140
|
+
/**
|
|
141
|
+
* The terminal/GitHub reporter used by `fjs t`. Output goes through
|
|
142
|
+
* `csiWrite`, so ANSI styles are stripped on non-TTY streams. When
|
|
143
|
+
* `GITHUB_ACTION` is set, failures are emitted as `::error` workflow
|
|
144
|
+
* annotations instead of colored lines. Exported as a factory so the
|
|
145
|
+
* GitHub format path can be exercised directly from tests.
|
|
146
|
+
*/
|
|
147
|
+
export const defaultReporter = (options) => {
|
|
148
|
+
const write = csiWrite(options);
|
|
149
|
+
const line = (w) => {
|
|
150
|
+
const x = write(w);
|
|
151
|
+
return (s) => x(s + '\n');
|
|
152
|
+
};
|
|
153
|
+
const csiLog = line('stdout');
|
|
154
|
+
const csiError = line('stderr');
|
|
155
|
+
const isGitHub = options.env['GITHUB_ACTION'] !== undefined;
|
|
156
|
+
return {
|
|
157
|
+
// https://github.com/OndraM/ci-detector/blob/main/src/Ci/GitHubActions.php
|
|
158
|
+
result: (file, path, { result: [s, v], duration }) => s === 'ok'
|
|
159
|
+
? csiLog(fmtResultLine(file, path, fgGreen, 'ok', duration))
|
|
160
|
+
: isGitHub
|
|
161
|
+
? csiError(`::error file=${file},line=1,title=${ghEscape(fmtImport(file, path))}::${ghEscape(String(v))}`)
|
|
162
|
+
: csiError(fmtResultLine(file, path, fgRed, 'error', duration))
|
|
163
|
+
.step(() => csiError(`${fgRed}${v}${reset}`)),
|
|
164
|
+
summary: (pass, fail, time) => {
|
|
165
|
+
const fgFail = fail === 0 ? fgGreen : fgRed;
|
|
166
|
+
return csiLog(`${bold}Number of tests: pass: ${fgGreen}${pass}${reset}${bold}, fail: ${fgFail}${fail}${reset}${bold}, total: ${pass + fail}${reset}`)
|
|
167
|
+
.step(() => csiLog(`${bold}Time: ${timeFormat(time)}${reset}`));
|
|
168
|
+
},
|
|
169
|
+
test: defaultTest,
|
|
170
|
+
};
|
|
126
171
|
};
|
|
127
|
-
export const main =
|
|
128
|
-
moduleMap: await loadModuleMap(io),
|
|
129
|
-
log: stdio(io), // anyLog(io.console.log),
|
|
130
|
-
error: stderr(io), // anyLog(io.console.error),
|
|
131
|
-
measure: measure(io.performance),
|
|
132
|
-
tryCatch: io.tryCatch,
|
|
133
|
-
env: env(io),
|
|
134
|
-
state: undefined,
|
|
135
|
-
})[0];
|
|
172
|
+
export const main = options => test(defaultReporter(options))(options);
|
package/fs/dev/tf/module.js
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
|
-
import { io } from "../../io/module.js";
|
|
1
|
+
import { io, tryCatch } from "../../io/module.js";
|
|
2
2
|
import { loadModuleMap } from "../module.f.js";
|
|
3
|
-
import { isTest, parseTestSet } from "./module.f.js";
|
|
3
|
+
import { fmtImport, isTest, parseTestSet, runModuleMap } from "./module.f.js";
|
|
4
4
|
import * as nodeTest from 'node:test';
|
|
5
5
|
import { asyncImport } from "../../io/module.js";
|
|
6
|
+
import { fromIo } from "../../io/module.f.js";
|
|
7
|
+
import { pure } from "../../types/effects/module.f.js";
|
|
8
|
+
import { asyncRun } from "../../types/effects/module.js";
|
|
9
|
+
import {} from "../../types/effects/node/module.f.js";
|
|
6
10
|
const isBun = typeof Bun !== 'undefined';
|
|
7
11
|
const isPlaywright = typeof process !== 'undefined' && process?.env?.PLAYWRIGHT_TEST !== undefined;
|
|
8
12
|
const createFramework = (fw) => (prefix, f) => fw.test(prefix, t => f((name, v) => t.test(name, v)));
|
|
@@ -15,7 +19,6 @@ const createPlaywrightFramework = async () => {
|
|
|
15
19
|
const framework = isPlaywright ? await createPlaywrightFramework() :
|
|
16
20
|
isBun ? createBunFramework(nodeTest) :
|
|
17
21
|
createFramework(nodeTest);
|
|
18
|
-
const parse = parseTestSet(io.tryCatch);
|
|
19
22
|
const scanModule = (x) => async (subTestRunner) => {
|
|
20
23
|
let subTests = [x];
|
|
21
24
|
while (true) {
|
|
@@ -26,28 +29,75 @@ const scanModule = (x) => async (subTestRunner) => {
|
|
|
26
29
|
subTests = rest;
|
|
27
30
|
//
|
|
28
31
|
const [name, value, throws] = first;
|
|
29
|
-
const set =
|
|
30
|
-
if (
|
|
31
|
-
await subTestRunner(name, () => {
|
|
32
|
-
const r = set();
|
|
33
|
-
// The result of a function is walked as a fresh sub-tree;
|
|
34
|
-
// the parent's `throws` flag does not propagate into it.
|
|
35
|
-
subTests = [...subTests, [`${name}()`, r, false]];
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
else {
|
|
32
|
+
const set = parseTestSet(throws, value);
|
|
33
|
+
if (set instanceof Array) {
|
|
39
34
|
for (const [j, y] of set) {
|
|
40
35
|
const pr = `${name}/${j}`;
|
|
41
36
|
subTests = [...subTests, [pr, y, throws || j === 'throw']];
|
|
42
37
|
}
|
|
43
38
|
}
|
|
39
|
+
else {
|
|
40
|
+
await subTestRunner(name, () => {
|
|
41
|
+
if (set.throws) {
|
|
42
|
+
let threw = false;
|
|
43
|
+
try {
|
|
44
|
+
set.fn();
|
|
45
|
+
}
|
|
46
|
+
catch (_) {
|
|
47
|
+
threw = true;
|
|
48
|
+
}
|
|
49
|
+
if (!threw) {
|
|
50
|
+
throw new Error(`${name}() expected to throw`);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
const r = set.fn();
|
|
55
|
+
// The result of a function is walked as a fresh sub-tree;
|
|
56
|
+
// the parent's `throws` flag does not propagate into it.
|
|
57
|
+
subTests = [...subTests, [`${name}()`, r, false]];
|
|
58
|
+
}
|
|
59
|
+
});
|
|
60
|
+
}
|
|
44
61
|
}
|
|
45
62
|
};
|
|
63
|
+
const noOp = () => pure(undefined);
|
|
64
|
+
const reporter = {
|
|
65
|
+
result: noOp,
|
|
66
|
+
summary: noOp,
|
|
67
|
+
test: (file, path, { throws, fn }) => {
|
|
68
|
+
nodeTest.test(fmtImport(file, path), async (_t) => {
|
|
69
|
+
const [s, r] = tryCatch(fn);
|
|
70
|
+
if (throws === (s === 'ok')) {
|
|
71
|
+
throw r;
|
|
72
|
+
}
|
|
73
|
+
if (!throws) {
|
|
74
|
+
// TODO: add subtests
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
return pure({
|
|
78
|
+
result: ['ok', undefined],
|
|
79
|
+
duration: 0,
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
const map = {
|
|
84
|
+
// TODO: we use the same algorithm twice. Refactor by creating a `createAll(map)`
|
|
85
|
+
// helper that takes a `map` and returns an `all` function that runs effects
|
|
86
|
+
// according to the map. There could be a problem with circular dependencies,
|
|
87
|
+
// but we can use a lazy function `() => ToAsyncOperationMap<All>` instead od `map`.
|
|
88
|
+
all: async (...effects) => Promise.all(effects.map(asyncRun(map))),
|
|
89
|
+
};
|
|
90
|
+
export const run3 = async () => {
|
|
91
|
+
const fio = fromIo(io);
|
|
92
|
+
const moduleMap = await fio(loadModuleMap(io.process.env));
|
|
93
|
+
const runner = runModuleMap(reporter)(moduleMap);
|
|
94
|
+
await asyncRun(map)(runner);
|
|
95
|
+
};
|
|
46
96
|
export const run = async () => {
|
|
47
|
-
const
|
|
48
|
-
for (const [i, v] of Object.entries(
|
|
97
|
+
const moduleMap = await fromIo(io)(loadModuleMap(io.process.env));
|
|
98
|
+
for (const [i, v] of Object.entries(moduleMap)) {
|
|
49
99
|
if (isTest(i)) {
|
|
50
|
-
framework(i, scanModule(['', v
|
|
100
|
+
framework(i, scanModule(['', v, false]));
|
|
51
101
|
}
|
|
52
102
|
}
|
|
53
103
|
};
|
package/fs/dev/tf/test.f.d.ts
CHANGED
|
@@ -1,21 +1,22 @@
|
|
|
1
|
-
declare const
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
export declare const flat: () => void;
|
|
2
|
+
export declare const nested: () => void;
|
|
3
|
+
export declare const throwKey: () => void;
|
|
4
|
+
export declare const throwKeyFail: () => void;
|
|
5
|
+
export declare const mixedPassFail: () => void;
|
|
6
|
+
export declare const returnValueSubTree: () => void;
|
|
7
|
+
export declare const arrayKeys: () => void;
|
|
8
|
+
export declare const nonTestFilesSkipped: () => void;
|
|
9
|
+
export declare const multipleFiles: () => void;
|
|
10
|
+
export declare const throwByFunctionName: () => void;
|
|
11
|
+
export declare const namedExports: () => void;
|
|
12
|
+
export declare const defaultReporterOutput: () => void;
|
|
13
|
+
export declare const defaultReporterFailOutput: () => void;
|
|
14
|
+
export declare const githubReporterOutput: () => void;
|
|
15
|
+
export declare const helpers: {
|
|
16
|
+
isInteger: () => void;
|
|
17
|
+
isIdentifier: () => void;
|
|
18
|
+
fmtImport: () => void;
|
|
19
|
+
fmtPath: () => void;
|
|
20
|
+
fmtTerm: () => void;
|
|
21
|
+
ghEscape: () => void;
|
|
21
22
|
};
|