@rcompat/test 0.0.1 → 0.1.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/lib/private/Assert.d.ts +16 -0
- package/lib/private/Assert.js +60 -0
- package/lib/private/Asserter.d.ts +4 -0
- package/lib/private/Asserter.js +2 -0
- package/lib/private/Body.d.ts +4 -0
- package/lib/private/Body.js +2 -0
- package/lib/private/E.d.ts +6 -0
- package/lib/private/E.js +2 -0
- package/lib/private/NEVER.d.ts +6 -0
- package/lib/private/NEVER.js +4 -0
- package/lib/private/Result.d.ts +8 -0
- package/lib/private/Result.js +21 -0
- package/lib/private/Test.d.ts +13 -0
- package/lib/private/Test.js +30 -0
- package/lib/private/equals.js +4 -1
- package/lib/private/index.d.ts +6 -0
- package/lib/private/index.js +7 -0
- package/lib/private/repository.d.ts +13 -0
- package/lib/private/repository.js +22 -0
- package/lib/private/to-object.d.ts +1 -1
- package/lib/private/types/fn.d.ts +7 -0
- package/lib/private/types/fn.js +4 -0
- package/lib/private/types/map.d.ts +1 -1
- package/lib/private/types/record.d.ts +1 -1
- package/lib/private/types/set.d.ts +1 -1
- package/lib/public/Asserter.d.ts +2 -0
- package/lib/public/Asserter.js +2 -0
- package/lib/public/E.d.ts +2 -0
- package/lib/public/E.js +2 -0
- package/lib/public/NEVER.d.ts +2 -0
- package/lib/public/NEVER.js +2 -0
- package/lib/public/Result.d.ts +3 -0
- package/lib/public/Result.js +2 -0
- package/lib/public/Test.d.ts +3 -0
- package/lib/public/Test.js +2 -0
- package/lib/public/index.d.ts +2 -0
- package/lib/public/index.js +2 -0
- package/lib/public/repository.d.ts +2 -0
- package/lib/public/repository.js +2 -0
- package/package.json +21 -8
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type Test from "#Test";
|
|
2
|
+
import type UnknownFunction from "@rcompat/type/UnknownFunction";
|
|
3
|
+
export default class Assert<T> {
|
|
4
|
+
#private;
|
|
5
|
+
constructor(actual: T, test: Test);
|
|
6
|
+
equals<Expected extends T>(expected: Expected): void;
|
|
7
|
+
nequals(expected: unknown): void;
|
|
8
|
+
true(): void;
|
|
9
|
+
false(): void;
|
|
10
|
+
null(): void;
|
|
11
|
+
undefined(): void;
|
|
12
|
+
instance(expected: UnknownFunction): void;
|
|
13
|
+
throws(expected?: string): void;
|
|
14
|
+
tries(): void;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=Assert.d.ts.map
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import E from "#E";
|
|
2
|
+
import equals from "#equals";
|
|
3
|
+
export default class Assert {
|
|
4
|
+
#actual;
|
|
5
|
+
#test;
|
|
6
|
+
constructor(actual, test) {
|
|
7
|
+
this.#actual = actual;
|
|
8
|
+
this.#test = test;
|
|
9
|
+
}
|
|
10
|
+
#report(expected, passed) {
|
|
11
|
+
this.#test.report(this.#actual, expected, passed);
|
|
12
|
+
}
|
|
13
|
+
equals(expected) {
|
|
14
|
+
this.#report(expected, equals(this.#actual, expected));
|
|
15
|
+
}
|
|
16
|
+
nequals(expected) {
|
|
17
|
+
this.#report(expected, !equals(this.#actual, expected));
|
|
18
|
+
}
|
|
19
|
+
#static(expected) {
|
|
20
|
+
this.#report(expected, equals(this.#actual, expected));
|
|
21
|
+
}
|
|
22
|
+
true() {
|
|
23
|
+
this.#static(true);
|
|
24
|
+
}
|
|
25
|
+
false() {
|
|
26
|
+
this.#static(false);
|
|
27
|
+
}
|
|
28
|
+
null() {
|
|
29
|
+
this.#static(null);
|
|
30
|
+
}
|
|
31
|
+
undefined() {
|
|
32
|
+
this.#static(undefined);
|
|
33
|
+
}
|
|
34
|
+
instance(expected) {
|
|
35
|
+
this.#report(expected, this.#actual instanceof expected);
|
|
36
|
+
}
|
|
37
|
+
throws(expected) {
|
|
38
|
+
try {
|
|
39
|
+
this.#actual();
|
|
40
|
+
this.#report("[void]", false);
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
const { message } = E(error);
|
|
44
|
+
const messaged = expected !== undefined;
|
|
45
|
+
this.#report(message, messaged ? equals(message, expected) : true);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
tries() {
|
|
49
|
+
try {
|
|
50
|
+
this.#actual();
|
|
51
|
+
this.#report("[void]", true);
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
const { message } = E(error);
|
|
55
|
+
this.#report(`[threw] ${message}`, false);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
;
|
|
60
|
+
//# sourceMappingURL=Assert.js.map
|
package/lib/private/E.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export default class Result {
|
|
2
|
+
#actual;
|
|
3
|
+
#expected;
|
|
4
|
+
#passed;
|
|
5
|
+
constructor(actual, expected, passed) {
|
|
6
|
+
this.#actual = actual;
|
|
7
|
+
this.#expected = expected;
|
|
8
|
+
this.#passed = passed;
|
|
9
|
+
}
|
|
10
|
+
get actual() {
|
|
11
|
+
return this.#actual;
|
|
12
|
+
}
|
|
13
|
+
get expected() {
|
|
14
|
+
return this.#expected;
|
|
15
|
+
}
|
|
16
|
+
get passed() {
|
|
17
|
+
return this.#passed;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
;
|
|
21
|
+
//# sourceMappingURL=Result.js.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import Body from "#Body";
|
|
2
|
+
import Result from "#Result";
|
|
3
|
+
import type FileRef from "@rcompat/fs/FileRef";
|
|
4
|
+
export default class Test {
|
|
5
|
+
#private;
|
|
6
|
+
constructor(name: string, body: Body, file: FileRef);
|
|
7
|
+
get name(): string;
|
|
8
|
+
get file(): FileRef;
|
|
9
|
+
get results(): Result<unknown>[];
|
|
10
|
+
report<T>(actual: T, expected: T, passed: boolean): void;
|
|
11
|
+
run(): void;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=Test.d.ts.map
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import Assert from "#Assert";
|
|
2
|
+
import Result from "#Result";
|
|
3
|
+
export default class Test {
|
|
4
|
+
#name;
|
|
5
|
+
#body;
|
|
6
|
+
#results = [];
|
|
7
|
+
#file;
|
|
8
|
+
constructor(name, body, file) {
|
|
9
|
+
this.#name = name;
|
|
10
|
+
this.#body = body;
|
|
11
|
+
this.#file = file;
|
|
12
|
+
}
|
|
13
|
+
get name() {
|
|
14
|
+
return this.#name;
|
|
15
|
+
}
|
|
16
|
+
get file() {
|
|
17
|
+
return this.#file;
|
|
18
|
+
}
|
|
19
|
+
get results() {
|
|
20
|
+
return this.#results;
|
|
21
|
+
}
|
|
22
|
+
report(actual, expected, passed) {
|
|
23
|
+
this.#results.push(new Result(actual, expected, passed));
|
|
24
|
+
}
|
|
25
|
+
run() {
|
|
26
|
+
this.#body((actual) => new Assert(actual, this));
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
;
|
|
30
|
+
//# sourceMappingURL=Test.js.map
|
package/lib/private/equals.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import array from "#types/array";
|
|
2
2
|
import date from "#types/date";
|
|
3
|
+
import fn from "#types/fn";
|
|
3
4
|
import map from "#types/map";
|
|
4
5
|
import nul from "#types/null";
|
|
5
6
|
import record from "#types/record";
|
|
@@ -12,7 +13,9 @@ const checks = [
|
|
|
12
13
|
[array.is, (x, y) => array.is(y) && array.equal(x, y)],
|
|
13
14
|
[set.is, (x, y) => set.is(y) && set.equal(x, y)],
|
|
14
15
|
[map.is, (x, y) => map.is(y) && map.equal(x, y)],
|
|
15
|
-
[
|
|
16
|
+
[fn.is, (x, y) => fn.is(y) && fn.equal(x, y)],
|
|
17
|
+
[record.is, (x, y) => record.is(y)
|
|
18
|
+
&& record.equal(x, y)],
|
|
16
19
|
[(_) => true, (_, _1) => false]
|
|
17
20
|
];
|
|
18
21
|
const equals = (x, y) => typeof x === typeof y
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type Body from "#Body";
|
|
2
|
+
import Test from "#Test";
|
|
3
|
+
import type FileRef from "@rcompat/fs/FileRef";
|
|
4
|
+
declare class Repository {
|
|
5
|
+
#private;
|
|
6
|
+
reset(): void;
|
|
7
|
+
put(name: string, body: Body): void;
|
|
8
|
+
current(file: FileRef): void;
|
|
9
|
+
run(): Generator<Test, void, unknown>;
|
|
10
|
+
}
|
|
11
|
+
declare const _default: Repository;
|
|
12
|
+
export default _default;
|
|
13
|
+
//# sourceMappingURL=repository.d.ts.map
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import Test from "#Test";
|
|
2
|
+
class Repository {
|
|
3
|
+
#tests = [];
|
|
4
|
+
#current;
|
|
5
|
+
reset() {
|
|
6
|
+
this.#tests = [];
|
|
7
|
+
}
|
|
8
|
+
put(name, body) {
|
|
9
|
+
this.#tests.push(new Test(name, body, this.#current));
|
|
10
|
+
}
|
|
11
|
+
current(file) {
|
|
12
|
+
this.#current = file;
|
|
13
|
+
}
|
|
14
|
+
*run() {
|
|
15
|
+
for (const test of this.#tests) {
|
|
16
|
+
test.run();
|
|
17
|
+
yield test;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export default new Repository();
|
|
22
|
+
//# sourceMappingURL=repository.js.map
|
package/lib/public/E.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rcompat/test",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "test module",
|
|
5
5
|
"bugs": "https://github.com/rcompat/rcompat/issues",
|
|
6
6
|
"license": "MIT",
|
|
@@ -14,30 +14,43 @@
|
|
|
14
14
|
"url": "https://github.com/rcompat/rcompat",
|
|
15
15
|
"directory": "packages/test"
|
|
16
16
|
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@rcompat/fs": "^0.12.1"
|
|
19
|
+
},
|
|
17
20
|
"dependencies": {
|
|
18
|
-
"@rcompat/record": "^0.
|
|
19
|
-
"@rcompat/core": "^0.6.0"
|
|
21
|
+
"@rcompat/record": "^0.7.0"
|
|
20
22
|
},
|
|
21
23
|
"type": "module",
|
|
22
24
|
"imports": {
|
|
25
|
+
"#mask/*": {
|
|
26
|
+
"apekit": "./src/private/mask/*.ts",
|
|
27
|
+
"default": "./lib/private/mask/*.js"
|
|
28
|
+
},
|
|
23
29
|
"#types/*": {
|
|
24
|
-
"
|
|
30
|
+
"apekit": "./src/private/types/*.ts",
|
|
25
31
|
"default": "./lib/private/types/*.js"
|
|
26
32
|
},
|
|
27
33
|
"#*": {
|
|
28
|
-
"
|
|
34
|
+
"apekit": "./src/private/*.ts",
|
|
29
35
|
"default": "./lib/private/*.js"
|
|
30
36
|
}
|
|
31
37
|
},
|
|
32
38
|
"exports": {
|
|
39
|
+
"./mask/*": {
|
|
40
|
+
"apekit": "./src/public/mask/*.ts",
|
|
41
|
+
"default": "./lib/public/mask/*.js"
|
|
42
|
+
},
|
|
33
43
|
"./*": {
|
|
34
|
-
"
|
|
44
|
+
"apekit": "./src/public/*.ts",
|
|
35
45
|
"default": "./lib/public/*.js"
|
|
46
|
+
},
|
|
47
|
+
".": {
|
|
48
|
+
"apekit": "./src/public/index.ts",
|
|
49
|
+
"default": "./lib/public/index.js"
|
|
36
50
|
}
|
|
37
51
|
},
|
|
38
52
|
"scripts": {
|
|
39
53
|
"build": "npm run clean && tsc",
|
|
40
|
-
"clean": "rm -rf ./lib"
|
|
41
|
-
"test": "tsx --conditions=livetypes ../../node_modules/debris/src/bin.js"
|
|
54
|
+
"clean": "rm -rf ./lib"
|
|
42
55
|
}
|
|
43
56
|
}
|