@as-pect/assembly 6.0.0 → 7.0.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/README.md +34 -34
- package/assembly/index.ts +24 -24
- package/assembly/internal/Actual.ts +20 -20
- package/assembly/internal/Expectation.ts +544 -481
- package/assembly/internal/Expected.ts +55 -55
- package/assembly/internal/Reflect.ts +698 -662
- package/assembly/internal/ReflectedValueType.ts +17 -17
- package/assembly/internal/Test.ts +81 -81
- package/assembly/internal/assert.ts +3 -3
- package/assembly/internal/call.ts +3 -3
- package/assembly/internal/comparison/toIncludeComparison.ts +67 -62
- package/assembly/internal/comparison/toIncludeEqualComparison.ts +91 -78
- package/assembly/internal/log.ts +19 -18
- package/assembly/internal/noOp.ts +3 -2
- package/package.json +17 -10
- package/types/as-pect.d.ts +733 -733
- package/types/as-pect.portable.d.ts +389 -389
- package/types/env.d.ts +1 -1
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
export const enum ReflectedValueType {
|
|
2
|
-
None = 0,
|
|
3
|
-
Class = 1,
|
|
4
|
-
String = 2,
|
|
5
|
-
ArrayBuffer = 3,
|
|
6
|
-
Map = 4,
|
|
7
|
-
Set = 5,
|
|
8
|
-
Function = 6,
|
|
9
|
-
Integer = 7,
|
|
10
|
-
Float = 8,
|
|
11
|
-
Boolean = 9,
|
|
12
|
-
Array = 10,
|
|
13
|
-
TypedArray = 11,
|
|
14
|
-
Finite = 12,
|
|
15
|
-
Truthy = 13,
|
|
16
|
-
Falsy = 14,
|
|
17
|
-
}
|
|
1
|
+
export const enum ReflectedValueType {
|
|
2
|
+
None = 0,
|
|
3
|
+
Class = 1,
|
|
4
|
+
String = 2,
|
|
5
|
+
ArrayBuffer = 3,
|
|
6
|
+
Map = 4,
|
|
7
|
+
Set = 5,
|
|
8
|
+
Function = 6,
|
|
9
|
+
Integer = 7,
|
|
10
|
+
Float = 8,
|
|
11
|
+
Boolean = 9,
|
|
12
|
+
Array = 10,
|
|
13
|
+
TypedArray = 11,
|
|
14
|
+
Finite = 12,
|
|
15
|
+
Truthy = 13,
|
|
16
|
+
Falsy = 14,
|
|
17
|
+
}
|
|
@@ -1,81 +1,81 @@
|
|
|
1
|
-
import { noOp } from "./noOp";
|
|
2
|
-
|
|
3
|
-
// @ts-ignore: Decorators *are* valid here!
|
|
4
|
-
@external("__aspect", "beforeEach")
|
|
5
|
-
@global
|
|
6
|
-
export declare function beforeEach(callback: () => void): void;
|
|
7
|
-
|
|
8
|
-
// @ts-ignore: Decorators *are* valid here!
|
|
9
|
-
@external("__aspect", "beforeAll")
|
|
10
|
-
@global
|
|
11
|
-
export declare function beforeAll(callback: () => void): void;
|
|
12
|
-
|
|
13
|
-
// @ts-ignore: Decorators *are* valid here!
|
|
14
|
-
@external("__aspect", "afterEach")
|
|
15
|
-
@global
|
|
16
|
-
export declare function afterEach(callback: () => void): void;
|
|
17
|
-
|
|
18
|
-
// @ts-ignore: Decorators *are* valid here!
|
|
19
|
-
@external("__aspect", "afterAll")
|
|
20
|
-
@global
|
|
21
|
-
export declare function afterAll(callback: () => void): void;
|
|
22
|
-
|
|
23
|
-
// @ts-ignore: Decorators *are* valid here!
|
|
24
|
-
@external("__aspect", "reportTodo")
|
|
25
|
-
@global
|
|
26
|
-
export declare function todo(description: string): void;
|
|
27
|
-
|
|
28
|
-
// @ts-ignore: Decorators *are* valid here!
|
|
29
|
-
@external("__aspect", "debug")
|
|
30
|
-
@global
|
|
31
|
-
export declare function debug(): void;
|
|
32
|
-
|
|
33
|
-
// @ts-ignore: Decorators *are* valid here!
|
|
34
|
-
@external("__aspect", "reportTodo")
|
|
35
|
-
@global
|
|
36
|
-
export declare function xit(description: string, callback: () => void): void;
|
|
37
|
-
|
|
38
|
-
// @ts-ignore: Decorators *are* valid here!
|
|
39
|
-
@external("__aspect", "reportTodo")
|
|
40
|
-
@global
|
|
41
|
-
export declare function xtest(description: string, callback: () => void): void;
|
|
42
|
-
|
|
43
|
-
// @ts-ignore: decorators *are* valid here
|
|
44
|
-
@external("__aspect", "reportTestTypeNode")
|
|
45
|
-
@global
|
|
46
|
-
export declare function it(description: string, runner: () => void): void;
|
|
47
|
-
|
|
48
|
-
// @ts-ignore: decorators *are* valid here
|
|
49
|
-
@external("__aspect", "reportTestTypeNode")
|
|
50
|
-
@global
|
|
51
|
-
export declare function test(description: string, runner: () => void): void;
|
|
52
|
-
|
|
53
|
-
// @ts-ignore: decorators *are* valid here
|
|
54
|
-
@external("__aspect", "reportNegatedTestNode")
|
|
55
|
-
@global
|
|
56
|
-
export declare function itThrows(
|
|
57
|
-
description: string,
|
|
58
|
-
runner: () => void,
|
|
59
|
-
// @ts-ignore: this is a valid syntax
|
|
60
|
-
message: string | null = null,
|
|
61
|
-
): void;
|
|
62
|
-
|
|
63
|
-
// @ts-ignore: decorators *are* valid here
|
|
64
|
-
@external("__aspect", "reportNegatedTestNode")
|
|
65
|
-
@global
|
|
66
|
-
export declare function throws(
|
|
67
|
-
description: string,
|
|
68
|
-
runner: () => void,
|
|
69
|
-
// @ts-ignore: this is a valid syntax
|
|
70
|
-
message: string | null = null,
|
|
71
|
-
): void;
|
|
72
|
-
|
|
73
|
-
// @ts-ignore: Decorators *are* valid here!
|
|
74
|
-
@external("__aspect", "reportGroupTypeNode")
|
|
75
|
-
@global
|
|
76
|
-
export declare function describe(
|
|
77
|
-
// @ts-ignore: this is a valid syntax
|
|
78
|
-
description: string = "",
|
|
79
|
-
// @ts-ignore: this is a valid syntax
|
|
80
|
-
runner: () => void = noOp,
|
|
81
|
-
): void;
|
|
1
|
+
import { noOp } from "./noOp";
|
|
2
|
+
|
|
3
|
+
// @ts-ignore: Decorators *are* valid here!
|
|
4
|
+
@external("__aspect", "beforeEach")
|
|
5
|
+
@global
|
|
6
|
+
export declare function beforeEach(callback: () => void): void;
|
|
7
|
+
|
|
8
|
+
// @ts-ignore: Decorators *are* valid here!
|
|
9
|
+
@external("__aspect", "beforeAll")
|
|
10
|
+
@global
|
|
11
|
+
export declare function beforeAll(callback: () => void): void;
|
|
12
|
+
|
|
13
|
+
// @ts-ignore: Decorators *are* valid here!
|
|
14
|
+
@external("__aspect", "afterEach")
|
|
15
|
+
@global
|
|
16
|
+
export declare function afterEach(callback: () => void): void;
|
|
17
|
+
|
|
18
|
+
// @ts-ignore: Decorators *are* valid here!
|
|
19
|
+
@external("__aspect", "afterAll")
|
|
20
|
+
@global
|
|
21
|
+
export declare function afterAll(callback: () => void): void;
|
|
22
|
+
|
|
23
|
+
// @ts-ignore: Decorators *are* valid here!
|
|
24
|
+
@external("__aspect", "reportTodo")
|
|
25
|
+
@global
|
|
26
|
+
export declare function todo(description: string): void;
|
|
27
|
+
|
|
28
|
+
// @ts-ignore: Decorators *are* valid here!
|
|
29
|
+
@external("__aspect", "debug")
|
|
30
|
+
@global
|
|
31
|
+
export declare function debug(): void;
|
|
32
|
+
|
|
33
|
+
// @ts-ignore: Decorators *are* valid here!
|
|
34
|
+
@external("__aspect", "reportTodo")
|
|
35
|
+
@global
|
|
36
|
+
export declare function xit(description: string, callback: () => void): void;
|
|
37
|
+
|
|
38
|
+
// @ts-ignore: Decorators *are* valid here!
|
|
39
|
+
@external("__aspect", "reportTodo")
|
|
40
|
+
@global
|
|
41
|
+
export declare function xtest(description: string, callback: () => void): void;
|
|
42
|
+
|
|
43
|
+
// @ts-ignore: decorators *are* valid here
|
|
44
|
+
@external("__aspect", "reportTestTypeNode")
|
|
45
|
+
@global
|
|
46
|
+
export declare function it(description: string, runner: () => void): void;
|
|
47
|
+
|
|
48
|
+
// @ts-ignore: decorators *are* valid here
|
|
49
|
+
@external("__aspect", "reportTestTypeNode")
|
|
50
|
+
@global
|
|
51
|
+
export declare function test(description: string, runner: () => void): void;
|
|
52
|
+
|
|
53
|
+
// @ts-ignore: decorators *are* valid here
|
|
54
|
+
@external("__aspect", "reportNegatedTestNode")
|
|
55
|
+
@global
|
|
56
|
+
export declare function itThrows(
|
|
57
|
+
description: string,
|
|
58
|
+
runner: () => void,
|
|
59
|
+
// @ts-ignore: this is a valid syntax
|
|
60
|
+
message: string | null = null,
|
|
61
|
+
): void;
|
|
62
|
+
|
|
63
|
+
// @ts-ignore: decorators *are* valid here
|
|
64
|
+
@external("__aspect", "reportNegatedTestNode")
|
|
65
|
+
@global
|
|
66
|
+
export declare function throws(
|
|
67
|
+
description: string,
|
|
68
|
+
runner: () => void,
|
|
69
|
+
// @ts-ignore: this is a valid syntax
|
|
70
|
+
message: string | null = null,
|
|
71
|
+
): void;
|
|
72
|
+
|
|
73
|
+
// @ts-ignore: Decorators *are* valid here!
|
|
74
|
+
@external("__aspect", "reportGroupTypeNode")
|
|
75
|
+
@global
|
|
76
|
+
export declare function describe(
|
|
77
|
+
// @ts-ignore: this is a valid syntax
|
|
78
|
+
description: string = "",
|
|
79
|
+
// @ts-ignore: this is a valid syntax
|
|
80
|
+
runner: () => void = noOp,
|
|
81
|
+
): void;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export function assert(condition: i32, message: string): void {
|
|
2
|
-
if (!condition) throw new Error(message);
|
|
3
|
-
}
|
|
1
|
+
export function assert(condition: i32, message: string): void {
|
|
2
|
+
if (!condition) throw new Error(message);
|
|
3
|
+
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export function __call(func: () => void): void {
|
|
2
|
-
func();
|
|
3
|
-
}
|
|
1
|
+
export function __call(func: () => void): void {
|
|
2
|
+
func();
|
|
3
|
+
}
|
|
@@ -1,62 +1,67 @@
|
|
|
1
|
-
import { Actual } from "../Actual";
|
|
2
|
-
import { Expected } from "../Expected";
|
|
3
|
-
import { assert } from "../assert";
|
|
4
|
-
|
|
5
|
-
export function toIncludeComparison<T, U>(
|
|
6
|
-
actual: T,
|
|
7
|
-
expected: U,
|
|
8
|
-
negated: i32,
|
|
9
|
-
message: string,
|
|
10
|
-
): void {
|
|
11
|
-
// @ts-ignore: checking if a property is defined is compile safe
|
|
12
|
-
if (!isDefined(actual[0]))
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
// Assert that the actual value is not null.
|
|
19
|
-
Actual.report(actual);
|
|
20
|
-
if (isNullable<T>()) {
|
|
21
|
-
Expected.report("null", 1);
|
|
22
|
-
assert(i32(actual !== null), "");
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
// We always expect the value to be included
|
|
26
|
-
Expected.report("Included", negated);
|
|
27
|
-
// assume it isn't included
|
|
28
|
-
let includes: bool = false;
|
|
29
|
-
|
|
30
|
-
if (actual instanceof Set) {
|
|
31
|
-
includes = actual.has(expected);
|
|
32
|
-
} else {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
1
|
+
import { Actual } from "../Actual";
|
|
2
|
+
import { Expected } from "../Expected";
|
|
3
|
+
import { assert } from "../assert";
|
|
4
|
+
|
|
5
|
+
export function toIncludeComparison<T, U>(
|
|
6
|
+
actual: T,
|
|
7
|
+
expected: U,
|
|
8
|
+
negated: i32,
|
|
9
|
+
message: string,
|
|
10
|
+
): void {
|
|
11
|
+
// @ts-ignore: checking if a property is defined is compile safe
|
|
12
|
+
if (!isDefined(actual[0]))
|
|
13
|
+
// @as-covers: ignore because this is a compile time error
|
|
14
|
+
ERROR(
|
|
15
|
+
"Cannot call toIncludeEquals on actual value of type T where T does not have an index signature.",
|
|
16
|
+
);
|
|
17
|
+
|
|
18
|
+
// Assert that the actual value is not null.
|
|
19
|
+
Actual.report(actual);
|
|
20
|
+
if (isNullable<T>()) {
|
|
21
|
+
Expected.report("null", 1);
|
|
22
|
+
assert(i32(actual !== null), "");
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// We always expect the value to be included
|
|
26
|
+
Expected.report("Included", negated);
|
|
27
|
+
// assume it isn't included
|
|
28
|
+
let includes: bool = false;
|
|
29
|
+
|
|
30
|
+
if (actual instanceof Set) {
|
|
31
|
+
includes = actual.has(expected);
|
|
32
|
+
} else {
|
|
33
|
+
if (isNullable(actual)) {
|
|
34
|
+
includes = includesCheck(actual!, expected);
|
|
35
|
+
} else {
|
|
36
|
+
includes = includesCheck(actual, expected);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
Actual.report(includes ? "Included" : "Not Included");
|
|
41
|
+
assert(negated ^ i32(includes), message);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function includesCheck<T, U>(actual: T, expected: U): bool {
|
|
45
|
+
// @ts-ignore: typesafe check
|
|
46
|
+
if (!isDefined(actual.length))
|
|
47
|
+
// @as-covers: ignore because this is a compile time error
|
|
48
|
+
ERROR("Can only call toInclude on array-like objects or Sets.");
|
|
49
|
+
|
|
50
|
+
if (!isDefined(unchecked(actual[0])))
|
|
51
|
+
// @as-covers: ignore because this is a compile time error
|
|
52
|
+
ERROR("Can only call toInclude on array-like objects or Sets.");
|
|
53
|
+
|
|
54
|
+
// @ts-ignore: typesafe access
|
|
55
|
+
let length = <indexof<T>>actual.length;
|
|
56
|
+
// @ts-ignore: typesafe check
|
|
57
|
+
if (isDefined(unchecked(actual[0]))) {
|
|
58
|
+
// @ts-ignore: if T does not have a length property, it will throw a compiler error.
|
|
59
|
+
for (let i = <indexof<T>>0; i < length; i++) {
|
|
60
|
+
// @ts-ignore: if this expression does not work, it will throw a compiler error.
|
|
61
|
+
if (unchecked(actual[i]) === expected) {
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
return false;
|
|
67
|
+
}
|
|
@@ -1,78 +1,91 @@
|
|
|
1
|
-
import { Actual } from "../Actual";
|
|
2
|
-
import { Expected } from "../Expected";
|
|
3
|
-
import { assert } from "../assert";
|
|
4
|
-
|
|
5
|
-
// @ts-ignore expected is valueof<T> or it will be a compiler error
|
|
6
|
-
export function toIncludeEqualComparison<T, U>(
|
|
7
|
-
actual: T,
|
|
8
|
-
expected: U,
|
|
9
|
-
negated: i32,
|
|
10
|
-
message: string,
|
|
11
|
-
): void {
|
|
12
|
-
// @ts-ignore: typesafe check
|
|
13
|
-
if (!isDefined(actual[0]))
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
// Assert that the actual value is not null.
|
|
20
|
-
Actual.report(actual);
|
|
21
|
-
Expected.report("null", 1);
|
|
22
|
-
assert(i32(changetype<usize>(actual) != 0), "");
|
|
23
|
-
|
|
24
|
-
// We always expect the value to be included
|
|
25
|
-
Expected.report("Included", negated);
|
|
26
|
-
// assume it isn't included
|
|
27
|
-
let includes = false;
|
|
28
|
-
|
|
29
|
-
if (actual instanceof Set) {
|
|
30
|
-
if (actual.has(expected)) {
|
|
31
|
-
includes = true;
|
|
32
|
-
} else {
|
|
33
|
-
// if it isn't already in the set, we need to look over each value and inspect it for strict equality
|
|
34
|
-
// @ts-ignore: type safe .values() method call
|
|
35
|
-
let values = actual.values();
|
|
36
|
-
let length = values.length;
|
|
37
|
-
for (let i = 0; i < length; i++) {
|
|
38
|
-
let key = unchecked(values[i]);
|
|
39
|
-
if (Reflect.equals(key, expected) === Reflect.SUCCESSFUL_MATCH) {
|
|
40
|
-
includes = true;
|
|
41
|
-
break;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
} else {
|
|
46
|
-
// @ts-ignore: typesafe check
|
|
47
|
-
if (!isDefined(actual.length))
|
|
48
|
-
ERROR("Can only call toIncludeEquals on array-like objects or Sets.");
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
1
|
+
import { Actual } from "../Actual";
|
|
2
|
+
import { Expected } from "../Expected";
|
|
3
|
+
import { assert } from "../assert";
|
|
4
|
+
|
|
5
|
+
// @ts-ignore expected is valueof<T> or it will be a compiler error
|
|
6
|
+
export function toIncludeEqualComparison<T, U>(
|
|
7
|
+
actual: T,
|
|
8
|
+
expected: U,
|
|
9
|
+
negated: i32,
|
|
10
|
+
message: string,
|
|
11
|
+
): void {
|
|
12
|
+
// @ts-ignore: typesafe check
|
|
13
|
+
if (!isDefined(actual[0]))
|
|
14
|
+
// @as-covers: ignore beause this is a compile time error
|
|
15
|
+
ERROR(
|
|
16
|
+
"Cannot call toIncludeEquals on actual value of type T where T does not have an index signature.",
|
|
17
|
+
);
|
|
18
|
+
|
|
19
|
+
// Assert that the actual value is not null.
|
|
20
|
+
Actual.report(actual);
|
|
21
|
+
Expected.report("null", 1);
|
|
22
|
+
assert(i32(changetype<usize>(actual) != 0), "");
|
|
23
|
+
|
|
24
|
+
// We always expect the value to be included
|
|
25
|
+
Expected.report("Included", negated);
|
|
26
|
+
// assume it isn't included
|
|
27
|
+
let includes = false;
|
|
28
|
+
|
|
29
|
+
if (actual instanceof Set) {
|
|
30
|
+
if (actual.has(expected)) {
|
|
31
|
+
includes = true;
|
|
32
|
+
} else {
|
|
33
|
+
// if it isn't already in the set, we need to look over each value and inspect it for strict equality
|
|
34
|
+
// @ts-ignore: type safe .values() method call
|
|
35
|
+
let values = actual.values();
|
|
36
|
+
let length = values.length;
|
|
37
|
+
for (let i = 0; i < length; i++) {
|
|
38
|
+
let key = unchecked(values[i]);
|
|
39
|
+
if (Reflect.equals(key, expected) === Reflect.SUCCESSFUL_MATCH) {
|
|
40
|
+
includes = true;
|
|
41
|
+
break;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
} else {
|
|
46
|
+
// @ts-ignore: typesafe check
|
|
47
|
+
if (!isDefined(actual.length))
|
|
48
|
+
ERROR("Can only call toIncludeEquals on array-like objects or Sets.");
|
|
49
|
+
|
|
50
|
+
if (isNullable<T>()) {
|
|
51
|
+
let actualNotNull = actual!;
|
|
52
|
+
// @ts-ignore: typesafe check
|
|
53
|
+
if (isDefined(unchecked(actualNotNull[0]))) {
|
|
54
|
+
// @ts-ignore: typesafe access
|
|
55
|
+
let length = <indexof<T>>actualNotNull.length;
|
|
56
|
+
// @ts-ignore: if T does not have a length property, it will throw a compiler error.
|
|
57
|
+
for (let i = <indexof<T>>0; i < length; i++) {
|
|
58
|
+
if (
|
|
59
|
+
// @ts-ignore: actual[i] type must match expected, or a compiler error will happen
|
|
60
|
+
Reflect.equals(unchecked(actualNotNull[i]), expected) ==
|
|
61
|
+
Reflect.SUCCESSFUL_MATCH
|
|
62
|
+
) {
|
|
63
|
+
includes = true;
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
} else {
|
|
69
|
+
// @ts-ignore: typesafe check
|
|
70
|
+
if (isDefined(unchecked(actual[0]))) {
|
|
71
|
+
// @ts-ignore: typesafe access
|
|
72
|
+
let length = <indexof<T>>actual.length;
|
|
73
|
+
// @ts-ignore: if T does not have a length property, it will throw a compiler error.
|
|
74
|
+
for (let i = <indexof<T>>0; i < length; i++) {
|
|
75
|
+
if (
|
|
76
|
+
// @ts-ignore: actual[i] type must match expected, or a compiler error will happen
|
|
77
|
+
Reflect.equals(unchecked(actual[i]), expected) ==
|
|
78
|
+
Reflect.SUCCESSFUL_MATCH
|
|
79
|
+
) {
|
|
80
|
+
includes = true;
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
// unchecked is always defined...
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
Actual.report(includes ? "Included" : "Not Included");
|
|
90
|
+
assert(negated ^ i32(includes), message);
|
|
91
|
+
}
|
package/assembly/internal/log.ts
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
|
-
// @ts-ignore: decorators *are* valid here
|
|
2
|
-
@external("__aspect", "logReflectedValue")
|
|
3
|
-
declare function logReflectedValue(value: i32): void;
|
|
4
|
-
|
|
5
|
-
let ignoreLogs: bool = false;
|
|
6
|
-
|
|
7
|
-
export function __ignoreLogs(value: bool): void {
|
|
8
|
-
ignoreLogs = value;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
// @ts-ignore: decorators *are* valid here
|
|
12
|
-
@global
|
|
13
|
-
export function log<T>(value: T): void {
|
|
14
|
-
if (ignoreLogs) return;
|
|
15
|
-
|
|
16
|
-
Reflect.
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
// @ts-ignore: decorators *are* valid here
|
|
2
|
+
@external("__aspect", "logReflectedValue")
|
|
3
|
+
declare function logReflectedValue(value: i32): void;
|
|
4
|
+
|
|
5
|
+
let ignoreLogs: bool = false;
|
|
6
|
+
|
|
7
|
+
export function __ignoreLogs(value: bool): void {
|
|
8
|
+
ignoreLogs = value;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// @ts-ignore: decorators *are* valid here
|
|
12
|
+
@global
|
|
13
|
+
export function log<T>(value: T): void {
|
|
14
|
+
if (ignoreLogs) return;
|
|
15
|
+
// The T parameter must be passed directly
|
|
16
|
+
let reflectedId = Reflect.toReflectedValue<T>(value);
|
|
17
|
+
Reflect.attachStackTrace(reflectedId);
|
|
18
|
+
logReflectedValue(reflectedId);
|
|
19
|
+
}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
/* eslint-disable */
|
|
2
|
-
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
// @as-covers: ignore because this is just an empty placeholder function
|
|
3
|
+
export const noOp = (): void => {};
|
package/package.json
CHANGED
|
@@ -1,15 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@as-pect/assembly",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0",
|
|
4
4
|
"description": "Write AssemblyScript tests at blazing fast speeds",
|
|
5
5
|
"types": "types/as-pect.d.ts",
|
|
6
|
+
"type": "module",
|
|
6
7
|
"scripts": {
|
|
7
|
-
"asp:ci": "node ../cli/lib/test --summary",
|
|
8
|
-
"asp": "node ../cli/lib/test --verbose",
|
|
9
|
-
"test:ci": "
|
|
10
|
-
"test": "
|
|
8
|
+
"asp:ci": "node --experimental-wasi-unstable-preview1 ../cli/lib/test.js --summary",
|
|
9
|
+
"asp": "node --experimental-wasi-unstable-preview1 ../cli/lib/test.js --verbose",
|
|
10
|
+
"test:ci": "asp --summary",
|
|
11
|
+
"test": "asp --verbose",
|
|
11
12
|
"tsc:all": "exit 0",
|
|
12
|
-
"test:update-snapshots": "exit 0"
|
|
13
|
+
"test:update-snapshots": "exit 0",
|
|
14
|
+
"asbuild:debug": "asc assembly/index.ts --target debug",
|
|
15
|
+
"asbuild:release": "asc assembly/index.ts --target release",
|
|
16
|
+
"asbuild": "npm run asbuild:debug && npm run asbuild:release",
|
|
17
|
+
"start": "npx serve ."
|
|
13
18
|
},
|
|
14
19
|
"repository": {
|
|
15
20
|
"type": "git",
|
|
@@ -31,8 +36,10 @@
|
|
|
31
36
|
"assembly/index.ts",
|
|
32
37
|
"types/"
|
|
33
38
|
],
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
|
|
37
|
-
|
|
39
|
+
"exports": {
|
|
40
|
+
".": {
|
|
41
|
+
"import": "./build/release.js",
|
|
42
|
+
"types": "./build/release.d.ts"
|
|
43
|
+
}
|
|
44
|
+
}
|
|
38
45
|
}
|