functionalscript 0.14.1 → 0.14.2
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/dev/tf/all.test.js +1 -52
- package/fs/dev/tf/module.d.ts +1 -0
- package/fs/dev/tf/module.js +52 -0
- package/package.json +1 -1
package/fs/dev/tf/all.test.js
CHANGED
|
@@ -1,54 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { loadModuleMap } from "../module.f.js";
|
|
3
|
-
import { isTest, parseTestSet } from "./module.f.js";
|
|
4
|
-
import * as nodeTest from 'node:test';
|
|
5
|
-
const isBun = typeof Bun !== 'undefined';
|
|
6
|
-
const isPlaywright = typeof process !== 'undefined' && process?.env?.PLAYWRIGHT_TEST !== undefined;
|
|
7
|
-
const createFramework = (fw) => (prefix, f) => fw.test(prefix, t => f((name, v) => t.test(name, v)));
|
|
8
|
-
// Bun doesn't support nested tests yet.
|
|
9
|
-
const createBunFramework = (fw) => (prefix, f) => f((name, v) => fw.test(`${prefix}: ${name}`, v));
|
|
10
|
-
const createPlaywrightFramework = async () => {
|
|
11
|
-
const pwTest = (await import('@playwright/test')).test;
|
|
12
|
-
return (prefix, f) => f((name, v) => pwTest(`${prefix}: ${name}`, v));
|
|
13
|
-
};
|
|
14
|
-
const framework = isPlaywright ? await createPlaywrightFramework() :
|
|
15
|
-
isBun ? createBunFramework(nodeTest) :
|
|
16
|
-
createFramework(nodeTest);
|
|
17
|
-
const parse = parseTestSet(io.tryCatch);
|
|
18
|
-
const scanModule = (x) => async (subTestRunner) => {
|
|
19
|
-
let subTests = [x];
|
|
20
|
-
while (true) {
|
|
21
|
-
const [first, ...rest] = subTests;
|
|
22
|
-
if (first === undefined) {
|
|
23
|
-
break;
|
|
24
|
-
}
|
|
25
|
-
subTests = rest;
|
|
26
|
-
//
|
|
27
|
-
const [name, value, throws] = first;
|
|
28
|
-
const set = parse(throws)(value);
|
|
29
|
-
if (typeof set === 'function') {
|
|
30
|
-
await subTestRunner(name, () => {
|
|
31
|
-
const r = set();
|
|
32
|
-
// The result of a function is walked as a fresh sub-tree;
|
|
33
|
-
// the parent's `throws` flag does not propagate into it.
|
|
34
|
-
subTests = [...subTests, [`${name}()`, r, false]];
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
for (const [j, y] of set) {
|
|
39
|
-
const pr = `${name}/${j}`;
|
|
40
|
-
subTests = [...subTests, [pr, y, throws || j === 'throw']];
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
const run = async () => {
|
|
46
|
-
const x = await loadModuleMap(io);
|
|
47
|
-
for (const [i, v] of Object.entries(x)) {
|
|
48
|
-
if (isTest(i)) {
|
|
49
|
-
framework(i, scanModule(['', v.default, false]));
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
};
|
|
1
|
+
import { run } from "./module.js";
|
|
53
2
|
// we need `await` for Playwright.
|
|
54
3
|
await run();
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const run: () => Promise<void>;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { io } from "../../io/module.js";
|
|
2
|
+
import { loadModuleMap } from "../module.f.js";
|
|
3
|
+
import { isTest, parseTestSet } from "./module.f.js";
|
|
4
|
+
import * as nodeTest from 'node:test';
|
|
5
|
+
const isBun = typeof Bun !== 'undefined';
|
|
6
|
+
const isPlaywright = typeof process !== 'undefined' && process?.env?.PLAYWRIGHT_TEST !== undefined;
|
|
7
|
+
const createFramework = (fw) => (prefix, f) => fw.test(prefix, t => f((name, v) => t.test(name, v)));
|
|
8
|
+
// Bun doesn't support nested tests yet.
|
|
9
|
+
const createBunFramework = (fw) => (prefix, f) => f((name, v) => fw.test(`${prefix}: ${name}`, v));
|
|
10
|
+
const createPlaywrightFramework = async () => {
|
|
11
|
+
const pwTest = (await import('@playwright/test')).test;
|
|
12
|
+
return (prefix, f) => f((name, v) => pwTest(`${prefix}: ${name}`, v));
|
|
13
|
+
};
|
|
14
|
+
const framework = isPlaywright ? await createPlaywrightFramework() :
|
|
15
|
+
isBun ? createBunFramework(nodeTest) :
|
|
16
|
+
createFramework(nodeTest);
|
|
17
|
+
const parse = parseTestSet(io.tryCatch);
|
|
18
|
+
const scanModule = (x) => async (subTestRunner) => {
|
|
19
|
+
let subTests = [x];
|
|
20
|
+
while (true) {
|
|
21
|
+
const [first, ...rest] = subTests;
|
|
22
|
+
if (first === undefined) {
|
|
23
|
+
break;
|
|
24
|
+
}
|
|
25
|
+
subTests = rest;
|
|
26
|
+
//
|
|
27
|
+
const [name, value, throws] = first;
|
|
28
|
+
const set = parse(throws)(value);
|
|
29
|
+
if (typeof set === 'function') {
|
|
30
|
+
await subTestRunner(name, () => {
|
|
31
|
+
const r = set();
|
|
32
|
+
// The result of a function is walked as a fresh sub-tree;
|
|
33
|
+
// the parent's `throws` flag does not propagate into it.
|
|
34
|
+
subTests = [...subTests, [`${name}()`, r, false]];
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
for (const [j, y] of set) {
|
|
39
|
+
const pr = `${name}/${j}`;
|
|
40
|
+
subTests = [...subTests, [pr, y, throws || j === 'throw']];
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
export const run = async () => {
|
|
46
|
+
const x = await loadModuleMap(io);
|
|
47
|
+
for (const [i, v] of Object.entries(x)) {
|
|
48
|
+
if (isTest(i)) {
|
|
49
|
+
framework(i, scanModule(['', v.default, false]));
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
};
|