@kaeawc/auto-mobile 0.0.91 → 0.0.93
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/dist/build-info.json +12 -12
- package/dist/schemas/README.md +16 -0
- package/dist/schemas/prototype-icon-names.json +302 -0
- package/dist/schemas/test-plan.schema.json +370 -52
- package/dist/src/chunk-00167wan.js +55 -0
- package/dist/src/chunk-0jrrsnc9.js +6 -0
- package/dist/src/chunk-0n6swkwg.js +5 -0
- package/dist/src/chunk-0qsy1qsx.js +57 -0
- package/dist/src/chunk-11m8wj8j.js +237 -0
- package/dist/src/chunk-1p7xf5kb.js +5 -0
- package/dist/src/chunk-23p5f095.js +4 -0
- package/dist/src/chunk-26k317v5.js +5 -0
- package/dist/src/chunk-284ptqa4.js +7 -0
- package/dist/src/chunk-28re4xrg.js +4 -0
- package/dist/src/chunk-2f9rkmhx.js +5 -0
- package/dist/src/chunk-2fxdh48t.js +4 -0
- package/dist/src/chunk-2tbdrbt6.js +4 -0
- package/dist/src/chunk-2tqzq5qh.js +971 -0
- package/dist/src/chunk-32gvv9b4.js +21 -0
- package/dist/src/chunk-3f3t1x97.js +8 -0
- package/dist/src/chunk-3fspkbc7.js +4 -0
- package/dist/src/chunk-3qwrzxh0.js +11 -0
- package/dist/src/chunk-3sy6ahhz.js +26 -0
- package/dist/src/chunk-3vg455e6.js +4 -0
- package/dist/src/chunk-3xkpk44w.js +5 -0
- package/dist/src/chunk-3y6eykz9.js +4 -0
- package/dist/src/chunk-49bsqdx3.js +4 -0
- package/dist/src/chunk-4hw3665t.js +42 -0
- package/dist/src/chunk-58wzr3mt.js +5 -0
- package/dist/src/chunk-5d2hft6c.js +5 -0
- package/dist/src/chunk-5s645vr4.js +4 -0
- package/dist/src/chunk-5snsn9cf.js +4 -0
- package/dist/src/chunk-5tm9mn47.js +54 -0
- package/dist/src/chunk-5zc77a5t.js +4 -0
- package/dist/src/chunk-64j0majr.js +19 -0
- package/dist/src/chunk-65y8v4td.js +17 -0
- package/dist/src/chunk-6awz7vhq.js +5 -0
- package/dist/src/chunk-6bznss4t.js +8 -0
- package/dist/src/chunk-6ep7f5ge.js +4 -0
- package/dist/src/chunk-6pg7bqck.js +4 -0
- package/dist/src/chunk-6wt9rgjf.js +5 -0
- package/dist/src/chunk-6xmss8er.js +8 -0
- package/dist/src/chunk-710rxz9y.js +5 -0
- package/dist/src/chunk-7cs2da62.js +5 -0
- package/dist/src/chunk-7g103b54.js +4 -0
- package/dist/src/chunk-7j5vj4pa.js +4 -0
- package/dist/src/chunk-7rz9898k.js +5 -0
- package/dist/src/chunk-7tw8x05v.js +4 -0
- package/dist/src/chunk-7zy586cb.js +4 -0
- package/dist/src/chunk-8037tzzj.js +5 -0
- package/dist/src/chunk-84nanf8s.js +5 -0
- package/dist/src/chunk-8g1922rp.js +10 -0
- package/dist/src/chunk-8gvwcv2p.js +4 -0
- package/dist/src/chunk-8ph29g99.js +4 -0
- package/dist/src/chunk-8thrmfat.js +4 -0
- package/dist/src/chunk-8zgzzs7k.js +78 -0
- package/dist/src/chunk-97b1zmaq.js +4 -0
- package/dist/src/chunk-9fth9ayh.js +4 -0
- package/dist/src/chunk-9j6anhjr.js +4 -0
- package/dist/src/chunk-aabchzxk.js +9 -0
- package/dist/src/chunk-ayp07wbb.js +4 -0
- package/dist/src/chunk-bfjwqk8q.js +4 -0
- package/dist/src/chunk-bfw6125s.js +5 -0
- package/dist/src/chunk-bnhscm2n.js +4 -0
- package/dist/src/chunk-bxmsax22.js +5 -0
- package/dist/src/chunk-c1vs4g1n.js +4 -0
- package/dist/src/chunk-ct3e7yng.js +4 -0
- package/dist/src/chunk-cyy71ggq.js +5 -0
- package/dist/src/chunk-ddzkz92z.js +4 -0
- package/dist/src/chunk-dgrbdpb7.js +9 -0
- package/dist/src/chunk-drdz8hee.js +5 -0
- package/dist/src/chunk-e98dqnc9.js +145 -0
- package/dist/src/chunk-eersndy7.js +5 -0
- package/dist/src/chunk-eggq53ks.js +4 -0
- package/dist/src/chunk-f2dya7cs.js +4 -0
- package/dist/src/chunk-fbakd6cw.js +4 -0
- package/dist/src/chunk-fgb98zjj.js +5 -0
- package/dist/src/chunk-fmpad823.js +5 -0
- package/dist/src/chunk-g04bwyj3.js +4 -0
- package/dist/src/chunk-g0xr8zw0.js +4 -0
- package/dist/src/chunk-g3rjs80x.js +4 -0
- package/dist/src/chunk-g78rtrfv.js +4 -0
- package/dist/src/chunk-g7tmjbkt.js +5 -0
- package/dist/src/chunk-gabgv3y5.js +4 -0
- package/dist/src/chunk-gmr45m8f.js +4 -0
- package/dist/src/chunk-gsyfebqj.js +4 -0
- package/dist/src/chunk-h5rpn9wr.js +247 -0
- package/dist/src/chunk-hb1x7v55.js +4 -0
- package/dist/src/chunk-hrfytkxh.js +168 -0
- package/dist/src/chunk-j4yjzbak.js +4 -0
- package/dist/src/chunk-jd6a5v6p.js +5 -0
- package/dist/src/chunk-jh6vhqzx.js +5 -0
- package/dist/src/chunk-kn5spq15.js +4 -0
- package/dist/src/chunk-m94qs0f0.js +4 -0
- package/dist/src/chunk-mjrps0ac.js +7 -0
- package/dist/src/chunk-n03dmn5q.js +5 -0
- package/dist/src/chunk-n72qhwd9.js +4 -0
- package/dist/src/chunk-ndt1ccxm.js +71 -0
- package/dist/src/chunk-nr6y0n4y.js +5 -0
- package/dist/src/chunk-pcsen2vs.js +4 -0
- package/dist/src/chunk-ppfr0b8h.js +4 -0
- package/dist/src/chunk-q10bdnat.js +4 -0
- package/dist/src/chunk-q9xmq595.js +4 -0
- package/dist/src/chunk-qcxzr2my.js +5 -0
- package/dist/src/chunk-qf6nynk6.js +7 -0
- package/dist/src/chunk-qyqypn28.js +5 -0
- package/dist/src/chunk-r2epb56s.js +4 -0
- package/dist/src/chunk-r5bxavdx.js +311 -0
- package/dist/src/chunk-r6z1eztj.js +18 -0
- package/dist/src/chunk-r7bpkgff.js +4 -0
- package/dist/src/chunk-r8jf3d92.js +4 -0
- package/dist/src/chunk-rbpdk7m0.js +5 -0
- package/dist/src/chunk-rc0dbypm.js +4 -0
- package/dist/src/chunk-rhcty4ms.js +4 -0
- package/dist/src/chunk-rpvckv3p.js +4 -0
- package/dist/src/chunk-rqc9ap3x.js +4 -0
- package/dist/src/chunk-rvvy1bte.js +7 -0
- package/dist/src/chunk-ry0mz41y.js +4 -0
- package/dist/src/chunk-s3jc6cwp.js +5 -0
- package/dist/src/chunk-sfv61xjb.js +6 -0
- package/dist/src/chunk-t6bfvfkg.js +4 -0
- package/dist/src/chunk-t6c8akcm.js +5 -0
- package/dist/src/chunk-t7w8rctc.js +4 -0
- package/dist/src/chunk-thbh3jew.js +5 -0
- package/dist/src/chunk-v2wd4n3e.js +5 -0
- package/dist/src/chunk-v6pya0dm.js +5 -0
- package/dist/src/chunk-vy3bwm1d.js +17 -0
- package/dist/src/chunk-w3vs79ex.js +27 -0
- package/dist/src/chunk-w4zga19f.js +4 -0
- package/dist/src/chunk-w5b2jwk3.js +14 -0
- package/dist/src/chunk-w7hkv422.js +5 -0
- package/dist/src/chunk-waqwcjyn.js +4 -0
- package/dist/src/chunk-wbh8spm5.js +20 -0
- package/dist/src/chunk-wyrkw6hw.js +5 -0
- package/dist/src/chunk-xa73x2cx.js +5 -0
- package/dist/src/chunk-xgan0qqp.js +4 -0
- package/dist/src/chunk-y2vs6jwg.js +4 -0
- package/dist/src/chunk-yattm52s.js +4 -0
- package/dist/src/chunk-yb97j25b.js +6 -0
- package/dist/src/chunk-ybbtagbt.js +5 -0
- package/dist/src/chunk-ycaj2sgf.js +9 -0
- package/dist/src/chunk-yf7ympyz.js +325 -0
- package/dist/src/chunk-yjawdzk8.js +4 -0
- package/dist/src/chunk-z637nqg8.js +11 -0
- package/dist/src/chunk-zgja5f3p.js +6 -0
- package/dist/src/chunk-zs1sghs9.js +4 -0
- package/dist/src/daemon/processEntry.js +4 -0
- package/dist/src/index.js +4 -2843
- package/dist/src/runtime/bunRuntimeGuard.js +4 -0
- package/dist/src/utils/workers/iosBundleExtractWorker.js +2 -3
- package/ios/CameraPosterInjection/Injection/CameraPosterInjection.m +466 -0
- package/package.json +7 -6
- package/schemas/README.md +16 -0
- package/schemas/prototype-icon-names.json +302 -0
- package/schemas/test-plan.schema.json +370 -52
- package/node_modules/@borewit/text-codec/README.md +0 -87
- package/node_modules/@jimp/diff/node_modules/pixelmatch/README.md +0 -110
- package/node_modules/@jimp/diff/node_modules/pixelmatch/node_modules/pngjs/README.md +0 -433
- package/node_modules/@jimp/file-ops/dist/browser/index.js +0 -8
- package/node_modules/@jimp/js-png/README.md +0 -35
- package/node_modules/@jimp/js-png/src/__image_snapshots__/index-node-test-ts-png-should-use-png-options-1-snap.png +0 -0
- package/node_modules/@jimp/js-png/src/output.png +0 -0
- package/node_modules/@jimp/js-png/vitest.config.browser.mjs +0 -3
- package/node_modules/@jimp/plugin-resize/README.md +0 -12
- package/node_modules/@jimp/plugin-resize/vitest.config.browser.mjs +0 -3
- package/node_modules/@tokenizer/inflate/README.md +0 -114
- package/node_modules/@tokenizer/token/README.md +0 -19
- package/node_modules/await-to-js/README.md +0 -82
- package/node_modules/debug/README.md +0 -481
- package/node_modules/exif-parser/README.md +0 -83
- package/node_modules/file-type/readme.md +0 -667
- package/node_modules/ieee754/README.md +0 -51
- package/node_modules/mime/README.md +0 -178
- package/node_modules/ms/readme.md +0 -59
- package/node_modules/parse-bmfont-xml/README.md +0 -74
- package/node_modules/parse-bmfont-xml/lib/browser.js +0 -85
- package/node_modules/parse-bmfont-xml/node_modules/xml2js/README.md +0 -507
- package/node_modules/pngjs/README.md +0 -287
- package/node_modules/sax/README.md +0 -228
- package/node_modules/strtok3/README.md +0 -795
- package/node_modules/tinycolor2/README.md +0 -492
- package/node_modules/tinycolor2/cjs/test.js +0 -2191
- package/node_modules/tinycolor2/cjs/test_template.js +0 -26
- package/node_modules/tinycolor2/deno_asserts@0.168.0.mjs +0 -807
- package/node_modules/tinycolor2/esm/test.js +0 -2189
- package/node_modules/tinycolor2/esm/test_template.js +0 -24
- package/node_modules/tinycolor2/tinycolor.js +0 -1191
- package/node_modules/token-types/README.md +0 -160
- package/node_modules/uint8array-extras/readme.md +0 -318
- package/node_modules/xml-parse-from-string/README.md +0 -35
- package/node_modules/xmlbuilder/README.md +0 -86
- package/node_modules/zod/README.md +0 -208
- package/node_modules/zod/v4/locales/ar.d.cts +0 -4
- package/node_modules/zod/v4/locales/ar.d.ts +0 -4
- package/node_modules/zod/v4/locales/az.d.cts +0 -4
- package/node_modules/zod/v4/locales/az.d.ts +0 -4
- package/node_modules/zod/v4/locales/be.d.cts +0 -4
- package/node_modules/zod/v4/locales/be.d.ts +0 -4
- package/node_modules/zod/v4/locales/ca.d.cts +0 -4
- package/node_modules/zod/v4/locales/ca.d.ts +0 -4
- package/node_modules/zod/v4/locales/cs.d.cts +0 -4
- package/node_modules/zod/v4/locales/cs.d.ts +0 -4
- package/node_modules/zod/v4/locales/de.d.cts +0 -4
- package/node_modules/zod/v4/locales/de.d.ts +0 -4
- package/node_modules/zod/v4/locales/en.d.cts +0 -5
- package/node_modules/zod/v4/locales/en.d.ts +0 -5
- package/node_modules/zod/v4/locales/eo.d.cts +0 -5
- package/node_modules/zod/v4/locales/eo.d.ts +0 -5
- package/node_modules/zod/v4/locales/es.d.cts +0 -4
- package/node_modules/zod/v4/locales/es.d.ts +0 -4
- package/node_modules/zod/v4/locales/fa.d.cts +0 -4
- package/node_modules/zod/v4/locales/fa.d.ts +0 -4
- package/node_modules/zod/v4/locales/fi.d.cts +0 -4
- package/node_modules/zod/v4/locales/fi.d.ts +0 -4
- package/node_modules/zod/v4/locales/fr-CA.d.cts +0 -4
- package/node_modules/zod/v4/locales/fr-CA.d.ts +0 -4
- package/node_modules/zod/v4/locales/fr.d.cts +0 -4
- package/node_modules/zod/v4/locales/fr.d.ts +0 -4
- package/node_modules/zod/v4/locales/he.d.cts +0 -4
- package/node_modules/zod/v4/locales/he.d.ts +0 -4
- package/node_modules/zod/v4/locales/hu.d.cts +0 -4
- package/node_modules/zod/v4/locales/hu.d.ts +0 -4
- package/node_modules/zod/v4/locales/id.d.cts +0 -4
- package/node_modules/zod/v4/locales/id.d.ts +0 -4
- package/node_modules/zod/v4/locales/index.d.cts +0 -39
- package/node_modules/zod/v4/locales/index.d.ts +0 -39
- package/node_modules/zod/v4/locales/it.d.cts +0 -4
- package/node_modules/zod/v4/locales/it.d.ts +0 -4
- package/node_modules/zod/v4/locales/ja.d.cts +0 -4
- package/node_modules/zod/v4/locales/ja.d.ts +0 -4
- package/node_modules/zod/v4/locales/kh.d.cts +0 -4
- package/node_modules/zod/v4/locales/kh.d.ts +0 -4
- package/node_modules/zod/v4/locales/ko.d.cts +0 -4
- package/node_modules/zod/v4/locales/ko.d.ts +0 -4
- package/node_modules/zod/v4/locales/mk.d.cts +0 -4
- package/node_modules/zod/v4/locales/mk.d.ts +0 -4
- package/node_modules/zod/v4/locales/ms.d.cts +0 -4
- package/node_modules/zod/v4/locales/ms.d.ts +0 -4
- package/node_modules/zod/v4/locales/nl.d.cts +0 -4
- package/node_modules/zod/v4/locales/nl.d.ts +0 -4
- package/node_modules/zod/v4/locales/no.d.cts +0 -4
- package/node_modules/zod/v4/locales/no.d.ts +0 -4
- package/node_modules/zod/v4/locales/ota.d.cts +0 -4
- package/node_modules/zod/v4/locales/ota.d.ts +0 -4
- package/node_modules/zod/v4/locales/pl.d.cts +0 -4
- package/node_modules/zod/v4/locales/pl.d.ts +0 -4
- package/node_modules/zod/v4/locales/ps.d.cts +0 -4
- package/node_modules/zod/v4/locales/ps.d.ts +0 -4
- package/node_modules/zod/v4/locales/pt.d.cts +0 -4
- package/node_modules/zod/v4/locales/pt.d.ts +0 -4
- package/node_modules/zod/v4/locales/ru.d.cts +0 -4
- package/node_modules/zod/v4/locales/ru.d.ts +0 -4
- package/node_modules/zod/v4/locales/sl.d.cts +0 -4
- package/node_modules/zod/v4/locales/sl.d.ts +0 -4
- package/node_modules/zod/v4/locales/sv.d.cts +0 -4
- package/node_modules/zod/v4/locales/sv.d.ts +0 -4
- package/node_modules/zod/v4/locales/ta.d.cts +0 -4
- package/node_modules/zod/v4/locales/ta.d.ts +0 -4
- package/node_modules/zod/v4/locales/th.d.cts +0 -4
- package/node_modules/zod/v4/locales/th.d.ts +0 -4
- package/node_modules/zod/v4/locales/tr.d.cts +0 -5
- package/node_modules/zod/v4/locales/tr.d.ts +0 -5
- package/node_modules/zod/v4/locales/ua.d.cts +0 -4
- package/node_modules/zod/v4/locales/ua.d.ts +0 -4
- package/node_modules/zod/v4/locales/ur.d.cts +0 -4
- package/node_modules/zod/v4/locales/ur.d.ts +0 -4
- package/node_modules/zod/v4/locales/vi.d.cts +0 -4
- package/node_modules/zod/v4/locales/vi.d.ts +0 -4
- package/node_modules/zod/v4/locales/zh-CN.d.cts +0 -4
- package/node_modules/zod/v4/locales/zh-CN.d.ts +0 -4
- package/node_modules/zod/v4/locales/zh-TW.d.cts +0 -4
- package/node_modules/zod/v4/locales/zh-TW.d.ts +0 -4
|
@@ -1,807 +0,0 @@
|
|
|
1
|
-
// deno-fmt-ignore-file
|
|
2
|
-
// deno-lint-ignore-file
|
|
3
|
-
// This code was bundled using `deno bundle` and it's not recommended to edit it manually
|
|
4
|
-
// Using `deno bundle https://deno.land/std@0.168.0/testing/asserts.ts > npm/deno_asserts@0.168.0.mjs`
|
|
5
|
-
|
|
6
|
-
const { Deno } = globalThis;
|
|
7
|
-
const noColor = typeof Deno?.noColor === "boolean" ? Deno.noColor : true;
|
|
8
|
-
let enabled = !noColor;
|
|
9
|
-
function code(open, close) {
|
|
10
|
-
return {
|
|
11
|
-
open: `\x1b[${open.join(";")}m`,
|
|
12
|
-
close: `\x1b[${close}m`,
|
|
13
|
-
regexp: new RegExp(`\\x1b\\[${close}m`, "g")
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
function run(str, code) {
|
|
17
|
-
return enabled ? `${code.open}${str.replace(code.regexp, code.open)}${code.close}` : str;
|
|
18
|
-
}
|
|
19
|
-
function bold(str) {
|
|
20
|
-
return run(str, code([
|
|
21
|
-
1
|
|
22
|
-
], 22));
|
|
23
|
-
}
|
|
24
|
-
function red(str) {
|
|
25
|
-
return run(str, code([
|
|
26
|
-
31
|
|
27
|
-
], 39));
|
|
28
|
-
}
|
|
29
|
-
function green(str) {
|
|
30
|
-
return run(str, code([
|
|
31
|
-
32
|
|
32
|
-
], 39));
|
|
33
|
-
}
|
|
34
|
-
function white(str) {
|
|
35
|
-
return run(str, code([
|
|
36
|
-
37
|
|
37
|
-
], 39));
|
|
38
|
-
}
|
|
39
|
-
function gray(str) {
|
|
40
|
-
return brightBlack(str);
|
|
41
|
-
}
|
|
42
|
-
function brightBlack(str) {
|
|
43
|
-
return run(str, code([
|
|
44
|
-
90
|
|
45
|
-
], 39));
|
|
46
|
-
}
|
|
47
|
-
function bgRed(str) {
|
|
48
|
-
return run(str, code([
|
|
49
|
-
41
|
|
50
|
-
], 49));
|
|
51
|
-
}
|
|
52
|
-
function bgGreen(str) {
|
|
53
|
-
return run(str, code([
|
|
54
|
-
42
|
|
55
|
-
], 49));
|
|
56
|
-
}
|
|
57
|
-
const ANSI_PATTERN = new RegExp([
|
|
58
|
-
"[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)",
|
|
59
|
-
"(?:(?:\\d{1,4}(?:;\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]))"
|
|
60
|
-
].join("|"), "g");
|
|
61
|
-
function stripColor(string) {
|
|
62
|
-
return string.replace(ANSI_PATTERN, "");
|
|
63
|
-
}
|
|
64
|
-
var DiffType;
|
|
65
|
-
(function(DiffType) {
|
|
66
|
-
DiffType["removed"] = "removed";
|
|
67
|
-
DiffType["common"] = "common";
|
|
68
|
-
DiffType["added"] = "added";
|
|
69
|
-
})(DiffType || (DiffType = {}));
|
|
70
|
-
const REMOVED = 1;
|
|
71
|
-
const COMMON = 2;
|
|
72
|
-
const ADDED = 3;
|
|
73
|
-
function createCommon(A, B, reverse) {
|
|
74
|
-
const common = [];
|
|
75
|
-
if (A.length === 0 || B.length === 0) return [];
|
|
76
|
-
for(let i = 0; i < Math.min(A.length, B.length); i += 1){
|
|
77
|
-
if (A[reverse ? A.length - i - 1 : i] === B[reverse ? B.length - i - 1 : i]) {
|
|
78
|
-
common.push(A[reverse ? A.length - i - 1 : i]);
|
|
79
|
-
} else {
|
|
80
|
-
return common;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
return common;
|
|
84
|
-
}
|
|
85
|
-
function diff(A, B) {
|
|
86
|
-
const prefixCommon = createCommon(A, B);
|
|
87
|
-
const suffixCommon = createCommon(A.slice(prefixCommon.length), B.slice(prefixCommon.length), true).reverse();
|
|
88
|
-
A = suffixCommon.length ? A.slice(prefixCommon.length, -suffixCommon.length) : A.slice(prefixCommon.length);
|
|
89
|
-
B = suffixCommon.length ? B.slice(prefixCommon.length, -suffixCommon.length) : B.slice(prefixCommon.length);
|
|
90
|
-
const swapped = B.length > A.length;
|
|
91
|
-
[A, B] = swapped ? [
|
|
92
|
-
B,
|
|
93
|
-
A
|
|
94
|
-
] : [
|
|
95
|
-
A,
|
|
96
|
-
B
|
|
97
|
-
];
|
|
98
|
-
const M = A.length;
|
|
99
|
-
const N = B.length;
|
|
100
|
-
if (!M && !N && !suffixCommon.length && !prefixCommon.length) return [];
|
|
101
|
-
if (!N) {
|
|
102
|
-
return [
|
|
103
|
-
...prefixCommon.map((c)=>({
|
|
104
|
-
type: DiffType.common,
|
|
105
|
-
value: c
|
|
106
|
-
})),
|
|
107
|
-
...A.map((a)=>({
|
|
108
|
-
type: swapped ? DiffType.added : DiffType.removed,
|
|
109
|
-
value: a
|
|
110
|
-
})),
|
|
111
|
-
...suffixCommon.map((c)=>({
|
|
112
|
-
type: DiffType.common,
|
|
113
|
-
value: c
|
|
114
|
-
}))
|
|
115
|
-
];
|
|
116
|
-
}
|
|
117
|
-
const offset = N;
|
|
118
|
-
const delta = M - N;
|
|
119
|
-
const size = M + N + 1;
|
|
120
|
-
const fp = Array.from({
|
|
121
|
-
length: size
|
|
122
|
-
}, ()=>({
|
|
123
|
-
y: -1,
|
|
124
|
-
id: -1
|
|
125
|
-
}));
|
|
126
|
-
const routes = new Uint32Array((M * N + size + 1) * 2);
|
|
127
|
-
const diffTypesPtrOffset = routes.length / 2;
|
|
128
|
-
let ptr = 0;
|
|
129
|
-
let p = -1;
|
|
130
|
-
function backTrace(A, B, current, swapped) {
|
|
131
|
-
const M = A.length;
|
|
132
|
-
const N = B.length;
|
|
133
|
-
const result = [];
|
|
134
|
-
let a = M - 1;
|
|
135
|
-
let b = N - 1;
|
|
136
|
-
let j = routes[current.id];
|
|
137
|
-
let type = routes[current.id + diffTypesPtrOffset];
|
|
138
|
-
while(true){
|
|
139
|
-
if (!j && !type) break;
|
|
140
|
-
const prev = j;
|
|
141
|
-
if (type === 1) {
|
|
142
|
-
result.unshift({
|
|
143
|
-
type: swapped ? DiffType.removed : DiffType.added,
|
|
144
|
-
value: B[b]
|
|
145
|
-
});
|
|
146
|
-
b -= 1;
|
|
147
|
-
} else if (type === 3) {
|
|
148
|
-
result.unshift({
|
|
149
|
-
type: swapped ? DiffType.added : DiffType.removed,
|
|
150
|
-
value: A[a]
|
|
151
|
-
});
|
|
152
|
-
a -= 1;
|
|
153
|
-
} else {
|
|
154
|
-
result.unshift({
|
|
155
|
-
type: DiffType.common,
|
|
156
|
-
value: A[a]
|
|
157
|
-
});
|
|
158
|
-
a -= 1;
|
|
159
|
-
b -= 1;
|
|
160
|
-
}
|
|
161
|
-
j = routes[prev];
|
|
162
|
-
type = routes[prev + diffTypesPtrOffset];
|
|
163
|
-
}
|
|
164
|
-
return result;
|
|
165
|
-
}
|
|
166
|
-
function createFP(slide, down, k, M) {
|
|
167
|
-
if (slide && slide.y === -1 && down && down.y === -1) {
|
|
168
|
-
return {
|
|
169
|
-
y: 0,
|
|
170
|
-
id: 0
|
|
171
|
-
};
|
|
172
|
-
}
|
|
173
|
-
if (down && down.y === -1 || k === M || (slide && slide.y) > (down && down.y) + 1) {
|
|
174
|
-
const prev = slide.id;
|
|
175
|
-
ptr++;
|
|
176
|
-
routes[ptr] = prev;
|
|
177
|
-
routes[ptr + diffTypesPtrOffset] = ADDED;
|
|
178
|
-
return {
|
|
179
|
-
y: slide.y,
|
|
180
|
-
id: ptr
|
|
181
|
-
};
|
|
182
|
-
} else {
|
|
183
|
-
const prev1 = down.id;
|
|
184
|
-
ptr++;
|
|
185
|
-
routes[ptr] = prev1;
|
|
186
|
-
routes[ptr + diffTypesPtrOffset] = REMOVED;
|
|
187
|
-
return {
|
|
188
|
-
y: down.y + 1,
|
|
189
|
-
id: ptr
|
|
190
|
-
};
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
function snake(k, slide, down, _offset, A, B) {
|
|
194
|
-
const M = A.length;
|
|
195
|
-
const N = B.length;
|
|
196
|
-
if (k < -N || M < k) return {
|
|
197
|
-
y: -1,
|
|
198
|
-
id: -1
|
|
199
|
-
};
|
|
200
|
-
const fp = createFP(slide, down, k, M);
|
|
201
|
-
while(fp.y + k < M && fp.y < N && A[fp.y + k] === B[fp.y]){
|
|
202
|
-
const prev = fp.id;
|
|
203
|
-
ptr++;
|
|
204
|
-
fp.id = ptr;
|
|
205
|
-
fp.y += 1;
|
|
206
|
-
routes[ptr] = prev;
|
|
207
|
-
routes[ptr + diffTypesPtrOffset] = COMMON;
|
|
208
|
-
}
|
|
209
|
-
return fp;
|
|
210
|
-
}
|
|
211
|
-
while(fp[delta + offset].y < N){
|
|
212
|
-
p = p + 1;
|
|
213
|
-
for(let k = -p; k < delta; ++k){
|
|
214
|
-
fp[k + offset] = snake(k, fp[k - 1 + offset], fp[k + 1 + offset], offset, A, B);
|
|
215
|
-
}
|
|
216
|
-
for(let k1 = delta + p; k1 > delta; --k1){
|
|
217
|
-
fp[k1 + offset] = snake(k1, fp[k1 - 1 + offset], fp[k1 + 1 + offset], offset, A, B);
|
|
218
|
-
}
|
|
219
|
-
fp[delta + offset] = snake(delta, fp[delta - 1 + offset], fp[delta + 1 + offset], offset, A, B);
|
|
220
|
-
}
|
|
221
|
-
return [
|
|
222
|
-
...prefixCommon.map((c)=>({
|
|
223
|
-
type: DiffType.common,
|
|
224
|
-
value: c
|
|
225
|
-
})),
|
|
226
|
-
...backTrace(A, B, fp[delta + offset], swapped),
|
|
227
|
-
...suffixCommon.map((c)=>({
|
|
228
|
-
type: DiffType.common,
|
|
229
|
-
value: c
|
|
230
|
-
}))
|
|
231
|
-
];
|
|
232
|
-
}
|
|
233
|
-
function diffstr(A, B) {
|
|
234
|
-
function unescape(string) {
|
|
235
|
-
return string.replaceAll("\b", "\\b").replaceAll("\f", "\\f").replaceAll("\t", "\\t").replaceAll("\v", "\\v").replaceAll(/\r\n|\r|\n/g, (str)=>str === "\r" ? "\\r" : str === "\n" ? "\\n\n" : "\\r\\n\r\n");
|
|
236
|
-
}
|
|
237
|
-
function tokenize(string, { wordDiff =false } = {}) {
|
|
238
|
-
if (wordDiff) {
|
|
239
|
-
const tokens = string.split(/([^\S\r\n]+|[()[\]{}'"\r\n]|\b)/);
|
|
240
|
-
const words = /^[a-zA-Z\u{C0}-\u{FF}\u{D8}-\u{F6}\u{F8}-\u{2C6}\u{2C8}-\u{2D7}\u{2DE}-\u{2FF}\u{1E00}-\u{1EFF}]+$/u;
|
|
241
|
-
for(let i = 0; i < tokens.length - 1; i++){
|
|
242
|
-
if (!tokens[i + 1] && tokens[i + 2] && words.test(tokens[i]) && words.test(tokens[i + 2])) {
|
|
243
|
-
tokens[i] += tokens[i + 2];
|
|
244
|
-
tokens.splice(i + 1, 2);
|
|
245
|
-
i--;
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
return tokens.filter((token)=>token);
|
|
249
|
-
} else {
|
|
250
|
-
const tokens1 = [], lines = string.split(/(\n|\r\n)/);
|
|
251
|
-
if (!lines[lines.length - 1]) {
|
|
252
|
-
lines.pop();
|
|
253
|
-
}
|
|
254
|
-
for(let i1 = 0; i1 < lines.length; i1++){
|
|
255
|
-
if (i1 % 2) {
|
|
256
|
-
tokens1[tokens1.length - 1] += lines[i1];
|
|
257
|
-
} else {
|
|
258
|
-
tokens1.push(lines[i1]);
|
|
259
|
-
}
|
|
260
|
-
}
|
|
261
|
-
return tokens1;
|
|
262
|
-
}
|
|
263
|
-
}
|
|
264
|
-
function createDetails(line, tokens) {
|
|
265
|
-
return tokens.filter(({ type })=>type === line.type || type === DiffType.common).map((result, i, t)=>{
|
|
266
|
-
if (result.type === DiffType.common && t[i - 1] && t[i - 1]?.type === t[i + 1]?.type && /\s+/.test(result.value)) {
|
|
267
|
-
result.type = t[i - 1].type;
|
|
268
|
-
}
|
|
269
|
-
return result;
|
|
270
|
-
});
|
|
271
|
-
}
|
|
272
|
-
const diffResult = diff(tokenize(`${unescape(A)}\n`), tokenize(`${unescape(B)}\n`));
|
|
273
|
-
const added = [], removed = [];
|
|
274
|
-
for (const result of diffResult){
|
|
275
|
-
if (result.type === DiffType.added) {
|
|
276
|
-
added.push(result);
|
|
277
|
-
}
|
|
278
|
-
if (result.type === DiffType.removed) {
|
|
279
|
-
removed.push(result);
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
const aLines = added.length < removed.length ? added : removed;
|
|
283
|
-
const bLines = aLines === removed ? added : removed;
|
|
284
|
-
for (const a of aLines){
|
|
285
|
-
let tokens = [], b;
|
|
286
|
-
while(bLines.length){
|
|
287
|
-
b = bLines.shift();
|
|
288
|
-
tokens = diff(tokenize(a.value, {
|
|
289
|
-
wordDiff: true
|
|
290
|
-
}), tokenize(b?.value ?? "", {
|
|
291
|
-
wordDiff: true
|
|
292
|
-
}));
|
|
293
|
-
if (tokens.some(({ type , value })=>type === DiffType.common && value.trim().length)) {
|
|
294
|
-
break;
|
|
295
|
-
}
|
|
296
|
-
}
|
|
297
|
-
a.details = createDetails(a, tokens);
|
|
298
|
-
if (b) {
|
|
299
|
-
b.details = createDetails(b, tokens);
|
|
300
|
-
}
|
|
301
|
-
}
|
|
302
|
-
return diffResult;
|
|
303
|
-
}
|
|
304
|
-
function createColor(diffType, { background =false } = {}) {
|
|
305
|
-
background = false;
|
|
306
|
-
switch(diffType){
|
|
307
|
-
case DiffType.added:
|
|
308
|
-
return (s)=>background ? bgGreen(white(s)) : green(bold(s));
|
|
309
|
-
case DiffType.removed:
|
|
310
|
-
return (s)=>background ? bgRed(white(s)) : red(bold(s));
|
|
311
|
-
default:
|
|
312
|
-
return white;
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
function createSign(diffType) {
|
|
316
|
-
switch(diffType){
|
|
317
|
-
case DiffType.added:
|
|
318
|
-
return "+ ";
|
|
319
|
-
case DiffType.removed:
|
|
320
|
-
return "- ";
|
|
321
|
-
default:
|
|
322
|
-
return " ";
|
|
323
|
-
}
|
|
324
|
-
}
|
|
325
|
-
function buildMessage(diffResult, { stringDiff =false } = {}) {
|
|
326
|
-
const messages = [], diffMessages = [];
|
|
327
|
-
messages.push("");
|
|
328
|
-
messages.push("");
|
|
329
|
-
messages.push(` ${gray(bold("[Diff]"))} ${red(bold("Actual"))} / ${green(bold("Expected"))}`);
|
|
330
|
-
messages.push("");
|
|
331
|
-
messages.push("");
|
|
332
|
-
diffResult.forEach((result)=>{
|
|
333
|
-
const c = createColor(result.type);
|
|
334
|
-
const line = result.details?.map((detail)=>detail.type !== DiffType.common ? createColor(detail.type, {
|
|
335
|
-
background: true
|
|
336
|
-
})(detail.value) : detail.value).join("") ?? result.value;
|
|
337
|
-
diffMessages.push(c(`${createSign(result.type)}${line}`));
|
|
338
|
-
});
|
|
339
|
-
messages.push(...stringDiff ? [
|
|
340
|
-
diffMessages.join("")
|
|
341
|
-
] : diffMessages);
|
|
342
|
-
messages.push("");
|
|
343
|
-
return messages;
|
|
344
|
-
}
|
|
345
|
-
function format(v) {
|
|
346
|
-
const { Deno } = globalThis;
|
|
347
|
-
return typeof Deno?.inspect === "function" ? Deno.inspect(v, {
|
|
348
|
-
depth: Infinity,
|
|
349
|
-
sorted: true,
|
|
350
|
-
trailingComma: true,
|
|
351
|
-
compact: false,
|
|
352
|
-
iterableLimit: Infinity,
|
|
353
|
-
getters: true
|
|
354
|
-
}) : `"${String(v).replace(/(?=["\\])/g, "\\")}"`;
|
|
355
|
-
}
|
|
356
|
-
const CAN_NOT_DISPLAY = "[Cannot display]";
|
|
357
|
-
class AssertionError extends Error {
|
|
358
|
-
name = "AssertionError";
|
|
359
|
-
constructor(message){
|
|
360
|
-
super(message);
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
function isKeyedCollection(x) {
|
|
364
|
-
return [
|
|
365
|
-
Symbol.iterator,
|
|
366
|
-
"size"
|
|
367
|
-
].every((k)=>k in x);
|
|
368
|
-
}
|
|
369
|
-
function equal(c, d) {
|
|
370
|
-
const seen = new Map();
|
|
371
|
-
return function compare(a, b) {
|
|
372
|
-
if (a && b && (a instanceof RegExp && b instanceof RegExp || a instanceof URL && b instanceof URL)) {
|
|
373
|
-
return String(a) === String(b);
|
|
374
|
-
}
|
|
375
|
-
if (a instanceof Date && b instanceof Date) {
|
|
376
|
-
const aTime = a.getTime();
|
|
377
|
-
const bTime = b.getTime();
|
|
378
|
-
if (Number.isNaN(aTime) && Number.isNaN(bTime)) {
|
|
379
|
-
return true;
|
|
380
|
-
}
|
|
381
|
-
return aTime === bTime;
|
|
382
|
-
}
|
|
383
|
-
if (typeof a === "number" && typeof b === "number") {
|
|
384
|
-
return Number.isNaN(a) && Number.isNaN(b) || a === b;
|
|
385
|
-
}
|
|
386
|
-
if (Object.is(a, b)) {
|
|
387
|
-
return true;
|
|
388
|
-
}
|
|
389
|
-
if (a && typeof a === "object" && b && typeof b === "object") {
|
|
390
|
-
if (a && b && !constructorsEqual(a, b)) {
|
|
391
|
-
return false;
|
|
392
|
-
}
|
|
393
|
-
if (a instanceof WeakMap || b instanceof WeakMap) {
|
|
394
|
-
if (!(a instanceof WeakMap && b instanceof WeakMap)) return false;
|
|
395
|
-
throw new TypeError("cannot compare WeakMap instances");
|
|
396
|
-
}
|
|
397
|
-
if (a instanceof WeakSet || b instanceof WeakSet) {
|
|
398
|
-
if (!(a instanceof WeakSet && b instanceof WeakSet)) return false;
|
|
399
|
-
throw new TypeError("cannot compare WeakSet instances");
|
|
400
|
-
}
|
|
401
|
-
if (seen.get(a) === b) {
|
|
402
|
-
return true;
|
|
403
|
-
}
|
|
404
|
-
if (Object.keys(a || {}).length !== Object.keys(b || {}).length) {
|
|
405
|
-
return false;
|
|
406
|
-
}
|
|
407
|
-
seen.set(a, b);
|
|
408
|
-
if (isKeyedCollection(a) && isKeyedCollection(b)) {
|
|
409
|
-
if (a.size !== b.size) {
|
|
410
|
-
return false;
|
|
411
|
-
}
|
|
412
|
-
let unmatchedEntries = a.size;
|
|
413
|
-
for (const [aKey, aValue] of a.entries()){
|
|
414
|
-
for (const [bKey, bValue] of b.entries()){
|
|
415
|
-
if (aKey === aValue && bKey === bValue && compare(aKey, bKey) || compare(aKey, bKey) && compare(aValue, bValue)) {
|
|
416
|
-
unmatchedEntries--;
|
|
417
|
-
break;
|
|
418
|
-
}
|
|
419
|
-
}
|
|
420
|
-
}
|
|
421
|
-
return unmatchedEntries === 0;
|
|
422
|
-
}
|
|
423
|
-
const merged = {
|
|
424
|
-
...a,
|
|
425
|
-
...b
|
|
426
|
-
};
|
|
427
|
-
for (const key of [
|
|
428
|
-
...Object.getOwnPropertyNames(merged),
|
|
429
|
-
...Object.getOwnPropertySymbols(merged)
|
|
430
|
-
]){
|
|
431
|
-
if (!compare(a && a[key], b && b[key])) {
|
|
432
|
-
return false;
|
|
433
|
-
}
|
|
434
|
-
if (key in a && !(key in b) || key in b && !(key in a)) {
|
|
435
|
-
return false;
|
|
436
|
-
}
|
|
437
|
-
}
|
|
438
|
-
if (a instanceof WeakRef || b instanceof WeakRef) {
|
|
439
|
-
if (!(a instanceof WeakRef && b instanceof WeakRef)) return false;
|
|
440
|
-
return compare(a.deref(), b.deref());
|
|
441
|
-
}
|
|
442
|
-
return true;
|
|
443
|
-
}
|
|
444
|
-
return false;
|
|
445
|
-
}(c, d);
|
|
446
|
-
}
|
|
447
|
-
function constructorsEqual(a, b) {
|
|
448
|
-
return a.constructor === b.constructor || a.constructor === Object && !b.constructor || !a.constructor && b.constructor === Object;
|
|
449
|
-
}
|
|
450
|
-
function assert(expr, msg = "") {
|
|
451
|
-
if (!expr) {
|
|
452
|
-
throw new AssertionError(msg);
|
|
453
|
-
}
|
|
454
|
-
}
|
|
455
|
-
function assertFalse(expr, msg = "") {
|
|
456
|
-
if (expr) {
|
|
457
|
-
throw new AssertionError(msg);
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
|
-
function assertEquals(actual, expected, msg) {
|
|
461
|
-
if (equal(actual, expected)) {
|
|
462
|
-
return;
|
|
463
|
-
}
|
|
464
|
-
let message = "";
|
|
465
|
-
const actualString = format(actual);
|
|
466
|
-
const expectedString = format(expected);
|
|
467
|
-
try {
|
|
468
|
-
const stringDiff = typeof actual === "string" && typeof expected === "string";
|
|
469
|
-
const diffResult = stringDiff ? diffstr(actual, expected) : diff(actualString.split("\n"), expectedString.split("\n"));
|
|
470
|
-
const diffMsg = buildMessage(diffResult, {
|
|
471
|
-
stringDiff
|
|
472
|
-
}).join("\n");
|
|
473
|
-
message = `Values are not equal:\n${diffMsg}`;
|
|
474
|
-
} catch {
|
|
475
|
-
message = `\n${red(CAN_NOT_DISPLAY)} + \n\n`;
|
|
476
|
-
}
|
|
477
|
-
if (msg) {
|
|
478
|
-
message = msg;
|
|
479
|
-
}
|
|
480
|
-
throw new AssertionError(message);
|
|
481
|
-
}
|
|
482
|
-
function assertNotEquals(actual, expected, msg) {
|
|
483
|
-
if (!equal(actual, expected)) {
|
|
484
|
-
return;
|
|
485
|
-
}
|
|
486
|
-
let actualString;
|
|
487
|
-
let expectedString;
|
|
488
|
-
try {
|
|
489
|
-
actualString = String(actual);
|
|
490
|
-
} catch {
|
|
491
|
-
actualString = "[Cannot display]";
|
|
492
|
-
}
|
|
493
|
-
try {
|
|
494
|
-
expectedString = String(expected);
|
|
495
|
-
} catch {
|
|
496
|
-
expectedString = "[Cannot display]";
|
|
497
|
-
}
|
|
498
|
-
if (!msg) {
|
|
499
|
-
msg = `actual: ${actualString} expected not to be: ${expectedString}`;
|
|
500
|
-
}
|
|
501
|
-
throw new AssertionError(msg);
|
|
502
|
-
}
|
|
503
|
-
function assertStrictEquals(actual, expected, msg) {
|
|
504
|
-
if (Object.is(actual, expected)) {
|
|
505
|
-
return;
|
|
506
|
-
}
|
|
507
|
-
let message;
|
|
508
|
-
if (msg) {
|
|
509
|
-
message = msg;
|
|
510
|
-
} else {
|
|
511
|
-
const actualString = format(actual);
|
|
512
|
-
const expectedString = format(expected);
|
|
513
|
-
if (actualString === expectedString) {
|
|
514
|
-
const withOffset = actualString.split("\n").map((l)=>` ${l}`).join("\n");
|
|
515
|
-
message = `Values have the same structure but are not reference-equal:\n\n${red(withOffset)}\n`;
|
|
516
|
-
} else {
|
|
517
|
-
try {
|
|
518
|
-
const stringDiff = typeof actual === "string" && typeof expected === "string";
|
|
519
|
-
const diffResult = stringDiff ? diffstr(actual, expected) : diff(actualString.split("\n"), expectedString.split("\n"));
|
|
520
|
-
const diffMsg = buildMessage(diffResult, {
|
|
521
|
-
stringDiff
|
|
522
|
-
}).join("\n");
|
|
523
|
-
message = `Values are not strictly equal:\n${diffMsg}`;
|
|
524
|
-
} catch {
|
|
525
|
-
message = `\n${red(CAN_NOT_DISPLAY)} + \n\n`;
|
|
526
|
-
}
|
|
527
|
-
}
|
|
528
|
-
}
|
|
529
|
-
throw new AssertionError(message);
|
|
530
|
-
}
|
|
531
|
-
function assertNotStrictEquals(actual, expected, msg) {
|
|
532
|
-
if (!Object.is(actual, expected)) {
|
|
533
|
-
return;
|
|
534
|
-
}
|
|
535
|
-
throw new AssertionError(msg ?? `Expected "actual" to be strictly unequal to: ${format(actual)}\n`);
|
|
536
|
-
}
|
|
537
|
-
function assertAlmostEquals(actual, expected, tolerance = 1e-7, msg) {
|
|
538
|
-
if (Object.is(actual, expected)) {
|
|
539
|
-
return;
|
|
540
|
-
}
|
|
541
|
-
const delta = Math.abs(expected - actual);
|
|
542
|
-
if (delta <= tolerance) {
|
|
543
|
-
return;
|
|
544
|
-
}
|
|
545
|
-
const f = (n)=>Number.isInteger(n) ? n : n.toExponential();
|
|
546
|
-
throw new AssertionError(msg ?? `actual: "${f(actual)}" expected to be close to "${f(expected)}": \
|
|
547
|
-
delta "${f(delta)}" is greater than "${f(tolerance)}"`);
|
|
548
|
-
}
|
|
549
|
-
function assertInstanceOf(actual, expectedType, msg = "") {
|
|
550
|
-
if (!msg) {
|
|
551
|
-
const expectedTypeStr = expectedType.name;
|
|
552
|
-
let actualTypeStr = "";
|
|
553
|
-
if (actual === null) {
|
|
554
|
-
actualTypeStr = "null";
|
|
555
|
-
} else if (actual === undefined) {
|
|
556
|
-
actualTypeStr = "undefined";
|
|
557
|
-
} else if (typeof actual === "object") {
|
|
558
|
-
actualTypeStr = actual.constructor?.name ?? "Object";
|
|
559
|
-
} else {
|
|
560
|
-
actualTypeStr = typeof actual;
|
|
561
|
-
}
|
|
562
|
-
if (expectedTypeStr == actualTypeStr) {
|
|
563
|
-
msg = `Expected object to be an instance of "${expectedTypeStr}".`;
|
|
564
|
-
} else if (actualTypeStr == "function") {
|
|
565
|
-
msg = `Expected object to be an instance of "${expectedTypeStr}" but was not an instanced object.`;
|
|
566
|
-
} else {
|
|
567
|
-
msg = `Expected object to be an instance of "${expectedTypeStr}" but was "${actualTypeStr}".`;
|
|
568
|
-
}
|
|
569
|
-
}
|
|
570
|
-
assert(actual instanceof expectedType, msg);
|
|
571
|
-
}
|
|
572
|
-
function assertNotInstanceOf(actual, unexpectedType, msg = `Expected object to not be an instance of "${typeof unexpectedType}"`) {
|
|
573
|
-
assertFalse(actual instanceof unexpectedType, msg);
|
|
574
|
-
}
|
|
575
|
-
function assertExists(actual, msg) {
|
|
576
|
-
if (actual === undefined || actual === null) {
|
|
577
|
-
if (!msg) {
|
|
578
|
-
msg = `actual: "${actual}" expected to not be null or undefined`;
|
|
579
|
-
}
|
|
580
|
-
throw new AssertionError(msg);
|
|
581
|
-
}
|
|
582
|
-
}
|
|
583
|
-
function assertStringIncludes(actual, expected, msg) {
|
|
584
|
-
if (!actual.includes(expected)) {
|
|
585
|
-
if (!msg) {
|
|
586
|
-
msg = `actual: "${actual}" expected to contain: "${expected}"`;
|
|
587
|
-
}
|
|
588
|
-
throw new AssertionError(msg);
|
|
589
|
-
}
|
|
590
|
-
}
|
|
591
|
-
function assertArrayIncludes(actual, expected, msg) {
|
|
592
|
-
const missing = [];
|
|
593
|
-
for(let i = 0; i < expected.length; i++){
|
|
594
|
-
let found = false;
|
|
595
|
-
for(let j = 0; j < actual.length; j++){
|
|
596
|
-
if (equal(expected[i], actual[j])) {
|
|
597
|
-
found = true;
|
|
598
|
-
break;
|
|
599
|
-
}
|
|
600
|
-
}
|
|
601
|
-
if (!found) {
|
|
602
|
-
missing.push(expected[i]);
|
|
603
|
-
}
|
|
604
|
-
}
|
|
605
|
-
if (missing.length === 0) {
|
|
606
|
-
return;
|
|
607
|
-
}
|
|
608
|
-
if (!msg) {
|
|
609
|
-
msg = `actual: "${format(actual)}" expected to include: "${format(expected)}"\nmissing: ${format(missing)}`;
|
|
610
|
-
}
|
|
611
|
-
throw new AssertionError(msg);
|
|
612
|
-
}
|
|
613
|
-
function assertMatch(actual, expected, msg) {
|
|
614
|
-
if (!expected.test(actual)) {
|
|
615
|
-
if (!msg) {
|
|
616
|
-
msg = `actual: "${actual}" expected to match: "${expected}"`;
|
|
617
|
-
}
|
|
618
|
-
throw new AssertionError(msg);
|
|
619
|
-
}
|
|
620
|
-
}
|
|
621
|
-
function assertNotMatch(actual, expected, msg) {
|
|
622
|
-
if (expected.test(actual)) {
|
|
623
|
-
if (!msg) {
|
|
624
|
-
msg = `actual: "${actual}" expected to not match: "${expected}"`;
|
|
625
|
-
}
|
|
626
|
-
throw new AssertionError(msg);
|
|
627
|
-
}
|
|
628
|
-
}
|
|
629
|
-
function assertObjectMatch(actual, expected) {
|
|
630
|
-
function filter(a, b) {
|
|
631
|
-
const seen = new WeakMap();
|
|
632
|
-
return fn(a, b);
|
|
633
|
-
function fn(a, b) {
|
|
634
|
-
if (seen.has(a) && seen.get(a) === b) {
|
|
635
|
-
return a;
|
|
636
|
-
}
|
|
637
|
-
seen.set(a, b);
|
|
638
|
-
const filtered = {};
|
|
639
|
-
const entries = [
|
|
640
|
-
...Object.getOwnPropertyNames(a),
|
|
641
|
-
...Object.getOwnPropertySymbols(a)
|
|
642
|
-
].filter((key)=>key in b).map((key)=>[
|
|
643
|
-
key,
|
|
644
|
-
a[key]
|
|
645
|
-
]);
|
|
646
|
-
for (const [key, value] of entries){
|
|
647
|
-
if (Array.isArray(value)) {
|
|
648
|
-
const subset = b[key];
|
|
649
|
-
if (Array.isArray(subset)) {
|
|
650
|
-
filtered[key] = fn({
|
|
651
|
-
...value
|
|
652
|
-
}, {
|
|
653
|
-
...subset
|
|
654
|
-
});
|
|
655
|
-
continue;
|
|
656
|
-
}
|
|
657
|
-
} else if (value instanceof RegExp) {
|
|
658
|
-
filtered[key] = value;
|
|
659
|
-
continue;
|
|
660
|
-
} else if (typeof value === "object") {
|
|
661
|
-
const subset1 = b[key];
|
|
662
|
-
if (typeof subset1 === "object" && subset1) {
|
|
663
|
-
if (value instanceof Map && subset1 instanceof Map) {
|
|
664
|
-
filtered[key] = new Map([
|
|
665
|
-
...value
|
|
666
|
-
].filter(([k])=>subset1.has(k)).map(([k, v])=>[
|
|
667
|
-
k,
|
|
668
|
-
typeof v === "object" ? fn(v, subset1.get(k)) : v
|
|
669
|
-
]));
|
|
670
|
-
continue;
|
|
671
|
-
}
|
|
672
|
-
if (value instanceof Set && subset1 instanceof Set) {
|
|
673
|
-
filtered[key] = new Set([
|
|
674
|
-
...value
|
|
675
|
-
].filter((v)=>subset1.has(v)));
|
|
676
|
-
continue;
|
|
677
|
-
}
|
|
678
|
-
filtered[key] = fn(value, subset1);
|
|
679
|
-
continue;
|
|
680
|
-
}
|
|
681
|
-
}
|
|
682
|
-
filtered[key] = value;
|
|
683
|
-
}
|
|
684
|
-
return filtered;
|
|
685
|
-
}
|
|
686
|
-
}
|
|
687
|
-
return assertEquals(filter(actual, expected), filter(expected, expected));
|
|
688
|
-
}
|
|
689
|
-
function fail(msg) {
|
|
690
|
-
assert(false, `Failed assertion${msg ? `: ${msg}` : "."}`);
|
|
691
|
-
}
|
|
692
|
-
function assertIsError(error, ErrorClass, msgIncludes, msg) {
|
|
693
|
-
if (error instanceof Error === false) {
|
|
694
|
-
throw new AssertionError(`Expected "error" to be an Error object.`);
|
|
695
|
-
}
|
|
696
|
-
if (ErrorClass && !(error instanceof ErrorClass)) {
|
|
697
|
-
msg = `Expected error to be instance of "${ErrorClass.name}", but was "${typeof error === "object" ? error?.constructor?.name : "[not an object]"}"${msg ? `: ${msg}` : "."}`;
|
|
698
|
-
throw new AssertionError(msg);
|
|
699
|
-
}
|
|
700
|
-
if (msgIncludes && (!(error instanceof Error) || !stripColor(error.message).includes(stripColor(msgIncludes)))) {
|
|
701
|
-
msg = `Expected error message to include "${msgIncludes}", but got "${error instanceof Error ? error.message : "[not an Error]"}"${msg ? `: ${msg}` : "."}`;
|
|
702
|
-
throw new AssertionError(msg);
|
|
703
|
-
}
|
|
704
|
-
}
|
|
705
|
-
function assertThrows(fn, errorClassOrMsg, msgIncludesOrMsg, msg) {
|
|
706
|
-
let ErrorClass = undefined;
|
|
707
|
-
let msgIncludes = undefined;
|
|
708
|
-
let err;
|
|
709
|
-
if (typeof errorClassOrMsg !== "string") {
|
|
710
|
-
if (errorClassOrMsg === undefined || errorClassOrMsg.prototype instanceof Error || errorClassOrMsg.prototype === Error.prototype) {
|
|
711
|
-
ErrorClass = errorClassOrMsg;
|
|
712
|
-
msgIncludes = msgIncludesOrMsg;
|
|
713
|
-
} else {
|
|
714
|
-
msg = msgIncludesOrMsg;
|
|
715
|
-
}
|
|
716
|
-
} else {
|
|
717
|
-
msg = errorClassOrMsg;
|
|
718
|
-
}
|
|
719
|
-
let doesThrow = false;
|
|
720
|
-
const msgToAppendToError = msg ? `: ${msg}` : ".";
|
|
721
|
-
try {
|
|
722
|
-
fn();
|
|
723
|
-
} catch (error) {
|
|
724
|
-
if (ErrorClass) {
|
|
725
|
-
if (error instanceof Error === false) {
|
|
726
|
-
throw new AssertionError("A non-Error object was thrown.");
|
|
727
|
-
}
|
|
728
|
-
assertIsError(error, ErrorClass, msgIncludes, msg);
|
|
729
|
-
}
|
|
730
|
-
err = error;
|
|
731
|
-
doesThrow = true;
|
|
732
|
-
}
|
|
733
|
-
if (!doesThrow) {
|
|
734
|
-
msg = `Expected function to throw${msgToAppendToError}`;
|
|
735
|
-
throw new AssertionError(msg);
|
|
736
|
-
}
|
|
737
|
-
return err;
|
|
738
|
-
}
|
|
739
|
-
async function assertRejects(fn, errorClassOrMsg, msgIncludesOrMsg, msg) {
|
|
740
|
-
let ErrorClass = undefined;
|
|
741
|
-
let msgIncludes = undefined;
|
|
742
|
-
let err;
|
|
743
|
-
if (typeof errorClassOrMsg !== "string") {
|
|
744
|
-
if (errorClassOrMsg === undefined || errorClassOrMsg.prototype instanceof Error || errorClassOrMsg.prototype === Error.prototype) {
|
|
745
|
-
ErrorClass = errorClassOrMsg;
|
|
746
|
-
msgIncludes = msgIncludesOrMsg;
|
|
747
|
-
}
|
|
748
|
-
} else {
|
|
749
|
-
msg = errorClassOrMsg;
|
|
750
|
-
}
|
|
751
|
-
let doesThrow = false;
|
|
752
|
-
let isPromiseReturned = false;
|
|
753
|
-
const msgToAppendToError = msg ? `: ${msg}` : ".";
|
|
754
|
-
try {
|
|
755
|
-
const possiblePromise = fn();
|
|
756
|
-
if (possiblePromise && typeof possiblePromise === "object" && typeof possiblePromise.then === "function") {
|
|
757
|
-
isPromiseReturned = true;
|
|
758
|
-
await possiblePromise;
|
|
759
|
-
}
|
|
760
|
-
} catch (error) {
|
|
761
|
-
if (!isPromiseReturned) {
|
|
762
|
-
throw new AssertionError(`Function throws when expected to reject${msgToAppendToError}`);
|
|
763
|
-
}
|
|
764
|
-
if (ErrorClass) {
|
|
765
|
-
if (error instanceof Error === false) {
|
|
766
|
-
throw new AssertionError("A non-Error object was rejected.");
|
|
767
|
-
}
|
|
768
|
-
assertIsError(error, ErrorClass, msgIncludes, msg);
|
|
769
|
-
}
|
|
770
|
-
err = error;
|
|
771
|
-
doesThrow = true;
|
|
772
|
-
}
|
|
773
|
-
if (!doesThrow) {
|
|
774
|
-
throw new AssertionError(`Expected function to reject${msgToAppendToError}`);
|
|
775
|
-
}
|
|
776
|
-
return err;
|
|
777
|
-
}
|
|
778
|
-
function unimplemented(msg) {
|
|
779
|
-
throw new AssertionError(msg || "unimplemented");
|
|
780
|
-
}
|
|
781
|
-
function unreachable() {
|
|
782
|
-
throw new AssertionError("unreachable");
|
|
783
|
-
}
|
|
784
|
-
export { AssertionError as AssertionError };
|
|
785
|
-
export { equal as equal };
|
|
786
|
-
export { assert as assert };
|
|
787
|
-
export { assertFalse as assertFalse };
|
|
788
|
-
export { assertEquals as assertEquals };
|
|
789
|
-
export { assertNotEquals as assertNotEquals };
|
|
790
|
-
export { assertStrictEquals as assertStrictEquals };
|
|
791
|
-
export { assertNotStrictEquals as assertNotStrictEquals };
|
|
792
|
-
export { assertAlmostEquals as assertAlmostEquals };
|
|
793
|
-
export { assertInstanceOf as assertInstanceOf };
|
|
794
|
-
export { assertNotInstanceOf as assertNotInstanceOf };
|
|
795
|
-
export { assertExists as assertExists };
|
|
796
|
-
export { assertStringIncludes as assertStringIncludes };
|
|
797
|
-
export { assertArrayIncludes as assertArrayIncludes };
|
|
798
|
-
export { assertMatch as assertMatch };
|
|
799
|
-
export { assertNotMatch as assertNotMatch };
|
|
800
|
-
export { assertObjectMatch as assertObjectMatch };
|
|
801
|
-
export { fail as fail };
|
|
802
|
-
export { assertIsError as assertIsError };
|
|
803
|
-
export { assertThrows as assertThrows };
|
|
804
|
-
export { assertRejects as assertRejects };
|
|
805
|
-
export { unimplemented as unimplemented };
|
|
806
|
-
export { unreachable as unreachable };
|
|
807
|
-
|