as-test 1.1.5 → 1.1.7
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/CHANGELOG.md +16 -1
- package/README.md +4 -9
- package/assembly/index.ts +10 -15
- package/assembly/src/expectation.ts +11 -11
- package/assembly/src/fuzz.ts +11 -7
- package/assembly/src/log.ts +2 -2
- package/assembly/src/suite.ts +5 -5
- package/assembly/src/tests.ts +8 -8
- package/assembly/util/wipc.ts +5 -1
- package/bin/build-worker-pool.js +146 -142
- package/bin/build-worker.js +37 -34
- package/bin/commands/build-core.js +577 -465
- package/bin/commands/build.js +49 -29
- package/bin/commands/clean-core.js +120 -113
- package/bin/commands/clean.js +14 -8
- package/bin/commands/doctor-core.js +288 -289
- package/bin/commands/doctor.js +1 -1
- package/bin/commands/fuzz-core.js +467 -414
- package/bin/commands/fuzz.js +27 -10
- package/bin/commands/init-core.js +905 -794
- package/bin/commands/init.js +2 -2
- package/bin/commands/run-core.js +2675 -2344
- package/bin/commands/run.js +43 -25
- package/bin/commands/test.js +56 -32
- package/bin/commands/web-runner-source.js +1 -1
- package/bin/commands/web-session.js +516 -525
- package/bin/coverage-points.js +363 -341
- package/bin/crash-store.js +56 -66
- package/bin/index.js +4092 -3150
- package/bin/reporters/default.js +1090 -890
- package/bin/reporters/tap.js +319 -325
- package/bin/types.js +67 -67
- package/bin/util.js +1290 -1239
- package/bin/wipc.js +70 -73
- package/lib/build/index.d.ts +3 -1
- package/lib/build/index.js +1039 -1034
- package/lib/build/web-runner/client.js +1 -1
- package/lib/build/web-runner/html.js +1 -1
- package/lib/build/web-runner/worker.js +1 -1
- package/package.json +6 -3
- package/transform/lib/coverage.js +4 -4
- package/transform/lib/log.js +9 -5
- package/assembly/util/json.ts +0 -112
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export function buildWebRunnerClientSource() {
|
|
2
|
-
|
|
2
|
+
return String.raw`const runnerOrigin = location.origin;
|
|
3
3
|
const workerUrl = new URL("/worker.js", runnerOrigin);
|
|
4
4
|
const wsUrl = new URL("/ws", runnerOrigin);
|
|
5
5
|
wsUrl.protocol = location.protocol == "https:" ? "wss:" : "ws:";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "as-test",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.7",
|
|
4
4
|
"author": "Jairus Tanaka",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -12,6 +12,9 @@
|
|
|
12
12
|
"typer-diff": "^1.1.1",
|
|
13
13
|
"wipc-js": "^0.1.1"
|
|
14
14
|
},
|
|
15
|
+
"peerDependencies": {
|
|
16
|
+
"json-as": ">=1.0.0"
|
|
17
|
+
},
|
|
15
18
|
"devDependencies": {
|
|
16
19
|
"@assemblyscript/wasi-shim": "^0.1.0",
|
|
17
20
|
"@eslint/js": "^10.0.1",
|
|
@@ -20,7 +23,7 @@
|
|
|
20
23
|
"as-test": "./",
|
|
21
24
|
"assemblyscript": "^0.28.17",
|
|
22
25
|
"assemblyscript-prettier": "^3.0.4",
|
|
23
|
-
"json-as": "^1.3.
|
|
26
|
+
"json-as": "^1.3.6",
|
|
24
27
|
"prettier": "3.8.3",
|
|
25
28
|
"try-as": "^1.0.1",
|
|
26
29
|
"typescript": "^6.0.3",
|
|
@@ -94,7 +97,7 @@
|
|
|
94
97
|
"docs:preview": "vitepress preview docs",
|
|
95
98
|
"format": "prettier -w .",
|
|
96
99
|
"release:check": "npm run build:cli && npm run build:lib && npm run build:transform && npm run test && npm run test:integration && npm run test:examples && npm pack --dry-run --cache /tmp/as-test-npm-cache",
|
|
97
|
-
"prepublishOnly": "npm run build:cli && npm run build:lib && npm run build:transform && npm run
|
|
100
|
+
"prepublishOnly": "npm run build:cli && npm run build:lib && npm run build:transform && npm run test && npm run test:integration && npm run format"
|
|
98
101
|
},
|
|
99
102
|
"type": "module"
|
|
100
103
|
}
|
|
@@ -298,10 +298,8 @@ export class CoverageTransform extends Visitor {
|
|
|
298
298
|
node.body.statements.unshift(coverStmt);
|
|
299
299
|
}
|
|
300
300
|
else if (node.body instanceof ExpressionStatement) {
|
|
301
|
-
const
|
|
302
|
-
|
|
303
|
-
const bodyBlock = node.body;
|
|
304
|
-
bodyBlock.statements.unshift(coverStmt);
|
|
301
|
+
const exprBody = node.body;
|
|
302
|
+
exprBody.expression = createCoverExpression(point.hash, exprBody.expression, node);
|
|
305
303
|
}
|
|
306
304
|
this.withScope(point, () => {
|
|
307
305
|
this.visit(node.name, node);
|
|
@@ -445,6 +443,8 @@ export class CoverageTransform extends Visitor {
|
|
|
445
443
|
super.visitReturnStatement(node);
|
|
446
444
|
if (!node.value || isBuiltinCallExpression(node.value))
|
|
447
445
|
return;
|
|
446
|
+
if (node.value.kind === NodeKind.This)
|
|
447
|
+
return;
|
|
448
448
|
const path = node.range.source.normalizedPath;
|
|
449
449
|
const point = this.createPoint(path, node.value, "Return");
|
|
450
450
|
const replacer = new RangeTransform(node);
|
package/transform/lib/log.js
CHANGED
|
@@ -4,7 +4,7 @@ import { toString } from "./util.js";
|
|
|
4
4
|
const LOG_CALL_FN = "__as_test_log_call";
|
|
5
5
|
const LOG_ENABLED_IMPORT = "__as_test_log_is_enabled_internal";
|
|
6
6
|
const LOG_SERIALIZED_IMPORT = "__as_test_log_serialized_internal";
|
|
7
|
-
const
|
|
7
|
+
const LOG_JSON_IMPORT = "__as_test_log_json_internal";
|
|
8
8
|
export class LogTransform extends Visitor {
|
|
9
9
|
parser;
|
|
10
10
|
activeSource = null;
|
|
@@ -27,11 +27,15 @@ export class LogTransform extends Visitor {
|
|
|
27
27
|
return;
|
|
28
28
|
}
|
|
29
29
|
const asTestPath = detectAsTestImportPath(node.text) ?? "as-test";
|
|
30
|
-
const
|
|
31
|
-
this.parser.currentSource =
|
|
32
|
-
node.statements.unshift(this.parser.parseTopLevelStatement(
|
|
30
|
+
const asTestTokenizer = new Tokenizer(new Source(0, node.normalizedPath, `import { __as_test_log_is_enabled as ${LOG_ENABLED_IMPORT}, __as_test_log_serialized as ${LOG_SERIALIZED_IMPORT} } from "${asTestPath}";`));
|
|
31
|
+
this.parser.currentSource = asTestTokenizer.source;
|
|
32
|
+
node.statements.unshift(this.parser.parseTopLevelStatement(asTestTokenizer));
|
|
33
33
|
this.parser.currentSource = node;
|
|
34
|
-
const
|
|
34
|
+
const jsonTokenizer = new Tokenizer(new Source(0, node.normalizedPath, `import { JSON as ${LOG_JSON_IMPORT} } from "json-as/assembly";`));
|
|
35
|
+
this.parser.currentSource = jsonTokenizer.source;
|
|
36
|
+
node.statements.unshift(this.parser.parseTopLevelStatement(jsonTokenizer));
|
|
37
|
+
this.parser.currentSource = node;
|
|
38
|
+
const callTokenizer = new Tokenizer(new Source(0, node.normalizedPath, `function ${LOG_CALL_FN}<T>(value: T): void { if (!${LOG_ENABLED_IMPORT}()) return; ${LOG_SERIALIZED_IMPORT}(${LOG_JSON_IMPORT}.stringify<T>(value)); }`));
|
|
35
39
|
this.parser.currentSource = callTokenizer.source;
|
|
36
40
|
node.statements.push(this.parser.parseTopLevelStatement(callTokenizer));
|
|
37
41
|
this.parser.currentSource = node;
|
package/assembly/util/json.ts
DELETED
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import { formatValue } from "./format";
|
|
2
|
-
|
|
3
|
-
export function quote(value: string): string {
|
|
4
|
-
return '"' + escape(value) + '"';
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export function rawOrNull(value: string): string {
|
|
8
|
-
return value.length ? value : "null";
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
export function stringifyValue<T>(value: T): string {
|
|
12
|
-
if (isNullable<T>() && changetype<usize>(value) == <usize>0) {
|
|
13
|
-
return "null";
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
if (isBoolean<T>()) {
|
|
17
|
-
return (value as bool) ? "true" : "false";
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
if (isInteger<T>() || isFloat<T>()) {
|
|
21
|
-
// @ts-expect-error: type
|
|
22
|
-
return value.toString();
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
if (isString<T>()) {
|
|
26
|
-
return quote(value as string);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
if (isArray<T>()) {
|
|
30
|
-
// @ts-expect-error: type
|
|
31
|
-
return stringifyArray<valueof<T>>(value as valueof<T>[]);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if (isManaged<T>()) {
|
|
35
|
-
// @ts-expect-error: method exists
|
|
36
|
-
return value.__as_test_json();
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
const formatted = formatValue<T>(value);
|
|
40
|
-
if (formatted != "none") {
|
|
41
|
-
return quote(formatted);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
return quote(nameof<T>());
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export function __as_test_json_value<T>(value: T): string {
|
|
48
|
-
return stringifyValue<T>(value);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
function stringifyArray<T>(values: T[]): string {
|
|
52
|
-
if (!values.length) return "[]";
|
|
53
|
-
|
|
54
|
-
let out = "[";
|
|
55
|
-
for (let i = 0; i < values.length; i++) {
|
|
56
|
-
if (i) out += ",";
|
|
57
|
-
out += stringifyValue<T>(unchecked(values[i]));
|
|
58
|
-
}
|
|
59
|
-
out += "]";
|
|
60
|
-
return out;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
function escape(value: string): string {
|
|
64
|
-
let out = "";
|
|
65
|
-
for (let i = 0; i < value.length; i++) {
|
|
66
|
-
const ch = value.charCodeAt(i);
|
|
67
|
-
if (ch == 34) {
|
|
68
|
-
out += '\\"';
|
|
69
|
-
} else if (ch == 92) {
|
|
70
|
-
out += "\\\\";
|
|
71
|
-
} else if (ch == 8) {
|
|
72
|
-
out += "\\b";
|
|
73
|
-
} else if (ch == 12) {
|
|
74
|
-
out += "\\f";
|
|
75
|
-
} else if (ch == 10) {
|
|
76
|
-
out += "\\n";
|
|
77
|
-
} else if (ch == 13) {
|
|
78
|
-
out += "\\r";
|
|
79
|
-
} else if (ch == 9) {
|
|
80
|
-
out += "\\t";
|
|
81
|
-
} else if (ch < 32) {
|
|
82
|
-
out += unicodeEscape(ch);
|
|
83
|
-
} else if (ch >= 0xd800 && ch <= 0xdfff) {
|
|
84
|
-
if (ch <= 0xdbff && i + 1 < value.length) {
|
|
85
|
-
const next = value.charCodeAt(i + 1);
|
|
86
|
-
if (next >= 0xdc00 && next <= 0xdfff) {
|
|
87
|
-
out += value.charAt(i);
|
|
88
|
-
out += value.charAt(i + 1);
|
|
89
|
-
i++;
|
|
90
|
-
continue;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
out += unicodeEscape(ch);
|
|
94
|
-
} else {
|
|
95
|
-
out += value.charAt(i);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
return out;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
function unicodeEscape(code: i32): string {
|
|
102
|
-
let out = "\\u";
|
|
103
|
-
out += hexNibble((code >> 12) & 0xf);
|
|
104
|
-
out += hexNibble((code >> 8) & 0xf);
|
|
105
|
-
out += hexNibble((code >> 4) & 0xf);
|
|
106
|
-
out += hexNibble(code & 0xf);
|
|
107
|
-
return out;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
function hexNibble(value: i32): string {
|
|
111
|
-
return String.fromCharCode(value < 10 ? 48 + value : 87 + value);
|
|
112
|
-
}
|