@rcompat/test 0.1.10 → 0.1.12
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 +18 -12
- package/lib/private/Assert.js +19 -8
- package/lib/private/Asserter.d.ts +2 -2
- package/lib/private/Test.d.ts +1 -1
- package/lib/private/Test.js +1 -1
- package/package.json +1 -1
package/lib/private/Assert.d.ts
CHANGED
|
@@ -1,18 +1,24 @@
|
|
|
1
1
|
import type Test from "#Test";
|
|
2
|
+
import type Not from "@rcompat/type/Not";
|
|
3
|
+
import type Print from "@rcompat/type/Print";
|
|
2
4
|
import type UnknownFunction from "@rcompat/type/UnknownFunction";
|
|
3
|
-
|
|
5
|
+
type Equals<X, Y> = (<T>() => T extends X ? true : false) extends <T>() => T extends Y ? true : false ? true : false;
|
|
6
|
+
export default class Assert<const Actual> {
|
|
4
7
|
#private;
|
|
5
|
-
constructor(
|
|
6
|
-
equals(expected: unknown):
|
|
7
|
-
nequals(expected: unknown):
|
|
8
|
-
type<
|
|
9
|
-
true():
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
8
|
+
constructor(test: Test, actual?: Actual);
|
|
9
|
+
equals(expected: unknown): this;
|
|
10
|
+
nequals(expected: unknown): this;
|
|
11
|
+
type<const Expected extends Equals<Actual, Expected> extends true ? unknown : Print<Actual>>(): this;
|
|
12
|
+
nottype<const Expected extends Not<Equals<Actual, Expected>> extends true ? unknown : "actual and expected types are same">(): this;
|
|
13
|
+
true(): this;
|
|
14
|
+
false(): this;
|
|
15
|
+
null(): this;
|
|
16
|
+
undefined(): this;
|
|
17
|
+
instance(expected: UnknownFunction): this;
|
|
18
|
+
throws(expected?: string): this;
|
|
19
|
+
tries(): this;
|
|
20
|
+
fail<const Expected extends Not<Equals<Actual, Expected>> extends true ? unknown : "was supposed to fail but didn't">(): void;
|
|
16
21
|
fail(reason: string): void;
|
|
17
22
|
}
|
|
23
|
+
export {};
|
|
18
24
|
//# sourceMappingURL=Assert.d.ts.map
|
package/lib/private/Assert.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import E from "#E";
|
|
2
2
|
import equals from "#equals";
|
|
3
3
|
export default class Assert {
|
|
4
|
-
#actual;
|
|
5
4
|
#test;
|
|
6
|
-
|
|
5
|
+
#actual;
|
|
6
|
+
constructor(test, actual) {
|
|
7
7
|
this.#actual = actual;
|
|
8
8
|
this.#test = test;
|
|
9
9
|
}
|
|
@@ -18,30 +18,37 @@ export default class Assert {
|
|
|
18
18
|
}
|
|
19
19
|
equals(expected) {
|
|
20
20
|
this.#report(equals(this.#actual, expected), expected);
|
|
21
|
+
return this;
|
|
21
22
|
}
|
|
22
23
|
nequals(expected) {
|
|
23
24
|
this.#report(!equals(this.#actual, expected), expected);
|
|
25
|
+
return this;
|
|
24
26
|
}
|
|
25
27
|
type() {
|
|
26
|
-
|
|
28
|
+
return this;
|
|
29
|
+
}
|
|
30
|
+
nottype() {
|
|
31
|
+
return this;
|
|
27
32
|
}
|
|
28
33
|
#static(expected) {
|
|
29
34
|
this.#report(equals(this.#actual, expected), expected);
|
|
35
|
+
return this;
|
|
30
36
|
}
|
|
31
37
|
true() {
|
|
32
|
-
this.#static(true);
|
|
38
|
+
return this.#static(true);
|
|
33
39
|
}
|
|
34
40
|
false() {
|
|
35
|
-
this.#static(false);
|
|
41
|
+
return this.#static(false);
|
|
36
42
|
}
|
|
37
43
|
null() {
|
|
38
|
-
this.#static(null);
|
|
44
|
+
return this.#static(null);
|
|
39
45
|
}
|
|
40
46
|
undefined() {
|
|
41
|
-
this.#static(undefined);
|
|
47
|
+
return this.#static(undefined);
|
|
42
48
|
}
|
|
43
49
|
instance(expected) {
|
|
44
50
|
this.#report(this.#actual instanceof expected, expected);
|
|
51
|
+
return this;
|
|
45
52
|
}
|
|
46
53
|
throws(expected) {
|
|
47
54
|
try {
|
|
@@ -57,6 +64,7 @@ export default class Assert {
|
|
|
57
64
|
this.#failed(expected, message);
|
|
58
65
|
}
|
|
59
66
|
}
|
|
67
|
+
return this;
|
|
60
68
|
}
|
|
61
69
|
tries() {
|
|
62
70
|
try {
|
|
@@ -66,9 +74,12 @@ export default class Assert {
|
|
|
66
74
|
catch (error) {
|
|
67
75
|
this.#failed(E(error).message, "[did not throw]");
|
|
68
76
|
}
|
|
77
|
+
return this;
|
|
69
78
|
}
|
|
70
79
|
fail(reason) {
|
|
71
|
-
|
|
80
|
+
if (reason !== undefined) {
|
|
81
|
+
this.#failed(reason);
|
|
82
|
+
}
|
|
72
83
|
}
|
|
73
84
|
}
|
|
74
85
|
;
|
package/lib/private/Test.d.ts
CHANGED
package/lib/private/Test.js
CHANGED