@rcompat/test 0.1.1 → 0.1.3
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/lib/private/Assert.d.ts +3 -1
- package/lib/private/Assert.js +26 -14
- package/lib/private/Body.d.ts +1 -1
- package/lib/private/StaticAssert.d.ts +5 -0
- package/lib/private/StaticAssert.js +7 -0
- package/lib/private/StaticAsserter.d.ts +4 -0
- package/lib/private/StaticAsserter.js +2 -0
- package/lib/private/StaticBody.d.ts +4 -0
- package/lib/private/StaticBody.js +2 -0
- package/lib/private/Test.js +2 -1
- package/lib/private/index.d.ts +3 -1
- package/lib/private/index.js +4 -1
- package/lib/private/never.d.ts +3 -0
- package/lib/private/never.js +3 -0
- package/lib/private/undef.d.ts +3 -0
- package/lib/private/undef.js +3 -0
- package/lib/public/never.d.ts +2 -0
- package/lib/public/never.js +2 -0
- package/lib/public/undef.d.ts +2 -0
- package/lib/public/undef.js +2 -0
- package/package.json +1 -1
- package/lib/private/NEVER.d.ts +0 -6
- package/lib/private/NEVER.js +0 -4
- package/lib/public/NEVER.d.ts +0 -2
- package/lib/public/NEVER.js +0 -2
package/lib/private/Assert.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import type UnknownFunction from "@rcompat/type/UnknownFunction";
|
|
|
3
3
|
export default class Assert<T> {
|
|
4
4
|
#private;
|
|
5
5
|
constructor(actual: T, test: Test);
|
|
6
|
-
equals
|
|
6
|
+
equals(expected: T): void;
|
|
7
7
|
nequals(expected: unknown): void;
|
|
8
8
|
true(): void;
|
|
9
9
|
false(): void;
|
|
@@ -12,5 +12,7 @@ export default class Assert<T> {
|
|
|
12
12
|
instance(expected: UnknownFunction): void;
|
|
13
13
|
throws(expected?: string): void;
|
|
14
14
|
tries(): void;
|
|
15
|
+
fail(reason: string): void;
|
|
16
|
+
type<_Expected extends T>(): void;
|
|
15
17
|
}
|
|
16
18
|
//# sourceMappingURL=Assert.d.ts.map
|
package/lib/private/Assert.js
CHANGED
|
@@ -7,19 +7,23 @@ export default class Assert {
|
|
|
7
7
|
this.#actual = actual;
|
|
8
8
|
this.#test = test;
|
|
9
9
|
}
|
|
10
|
-
#report(expected,
|
|
11
|
-
this.#test.report(this.#actual, expected, passed);
|
|
10
|
+
#report(passed, expected, actual) {
|
|
11
|
+
this.#test.report(actual ?? this.#actual, expected, passed);
|
|
12
|
+
}
|
|
13
|
+
#passed() {
|
|
14
|
+
this.#report(true, undefined);
|
|
15
|
+
}
|
|
16
|
+
#failed(expected, actual) {
|
|
17
|
+
this.#report(false, expected, actual);
|
|
12
18
|
}
|
|
13
19
|
equals(expected) {
|
|
14
|
-
|
|
15
|
-
this.#report(expected, equals(this.#actual, expected));
|
|
16
|
-
}
|
|
20
|
+
this.#report(equals(this.#actual, expected), expected);
|
|
17
21
|
}
|
|
18
22
|
nequals(expected) {
|
|
19
|
-
this.#report(
|
|
23
|
+
this.#report(!equals(this.#actual, expected), expected);
|
|
20
24
|
}
|
|
21
25
|
#static(expected) {
|
|
22
|
-
this.#report(
|
|
26
|
+
this.#report(equals(this.#actual, expected), expected);
|
|
23
27
|
}
|
|
24
28
|
true() {
|
|
25
29
|
this.#static(true);
|
|
@@ -34,29 +38,37 @@ export default class Assert {
|
|
|
34
38
|
this.#static(undefined);
|
|
35
39
|
}
|
|
36
40
|
instance(expected) {
|
|
37
|
-
this.#report(
|
|
41
|
+
this.#report(this.#actual instanceof expected, expected);
|
|
38
42
|
}
|
|
39
43
|
throws(expected) {
|
|
40
44
|
try {
|
|
41
45
|
this.#actual();
|
|
42
|
-
this.#
|
|
46
|
+
this.#failed("[did not throw]");
|
|
43
47
|
}
|
|
44
48
|
catch (error) {
|
|
45
49
|
const { message } = E(error);
|
|
46
|
-
|
|
47
|
-
|
|
50
|
+
if (expected === undefined || expected === message) {
|
|
51
|
+
this.#passed();
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
this.#failed(expected, message);
|
|
55
|
+
}
|
|
48
56
|
}
|
|
49
57
|
}
|
|
50
58
|
tries() {
|
|
51
59
|
try {
|
|
52
60
|
this.#actual();
|
|
53
|
-
this.#
|
|
61
|
+
this.#passed();
|
|
54
62
|
}
|
|
55
63
|
catch (error) {
|
|
56
|
-
|
|
57
|
-
this.#report(`[threw] ${message}`, false);
|
|
64
|
+
this.#failed(E(error).message, "[did not throw]");
|
|
58
65
|
}
|
|
59
66
|
}
|
|
67
|
+
fail(reason) {
|
|
68
|
+
this.#failed(reason);
|
|
69
|
+
}
|
|
70
|
+
// type check, no body
|
|
71
|
+
type() { }
|
|
60
72
|
}
|
|
61
73
|
;
|
|
62
74
|
//# sourceMappingURL=Assert.js.map
|
package/lib/private/Body.d.ts
CHANGED
package/lib/private/Test.js
CHANGED
package/lib/private/index.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import Body from "#Body";
|
|
1
|
+
import type Body from "#Body";
|
|
2
|
+
import type StaticBody from "#StaticBody";
|
|
2
3
|
declare const _default: {
|
|
3
4
|
case(name: string, body: Body): void;
|
|
5
|
+
static(_body: StaticBody): void;
|
|
4
6
|
};
|
|
5
7
|
export default _default;
|
|
6
8
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/private/index.js
CHANGED
package/package.json
CHANGED
package/lib/private/NEVER.d.ts
DELETED
package/lib/private/NEVER.js
DELETED
package/lib/public/NEVER.d.ts
DELETED
package/lib/public/NEVER.js
DELETED