@rcompat/test 0.0.2 → 0.1.1

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.
Files changed (44) hide show
  1. package/lib/private/Assert.d.ts +16 -0
  2. package/lib/private/Assert.js +62 -0
  3. package/lib/private/Asserter.d.ts +4 -0
  4. package/lib/private/Asserter.js +2 -0
  5. package/lib/private/Body.d.ts +4 -0
  6. package/lib/private/Body.js +2 -0
  7. package/lib/private/E.d.ts +6 -0
  8. package/lib/private/E.js +2 -0
  9. package/lib/private/NEVER.d.ts +6 -0
  10. package/lib/private/NEVER.js +4 -0
  11. package/lib/private/Result.d.ts +8 -0
  12. package/lib/private/Result.js +21 -0
  13. package/lib/private/Test.d.ts +13 -0
  14. package/lib/private/Test.js +30 -0
  15. package/lib/private/equals.js +4 -1
  16. package/lib/private/index.d.ts +6 -0
  17. package/lib/private/index.js +7 -0
  18. package/lib/private/repository.d.ts +13 -0
  19. package/lib/private/repository.js +22 -0
  20. package/lib/private/to-object.d.ts +1 -1
  21. package/lib/private/types/fn.d.ts +7 -0
  22. package/lib/private/types/fn.js +4 -0
  23. package/lib/private/types/map.d.ts +1 -1
  24. package/lib/private/types/record.d.ts +1 -1
  25. package/lib/private/types/set.d.ts +1 -1
  26. package/lib/public/Asserter.d.ts +2 -0
  27. package/lib/public/Asserter.js +2 -0
  28. package/lib/public/E.d.ts +2 -0
  29. package/lib/public/E.js +2 -0
  30. package/lib/public/NEVER.d.ts +2 -0
  31. package/lib/public/NEVER.js +2 -0
  32. package/lib/public/Result.d.ts +3 -0
  33. package/lib/public/Result.js +2 -0
  34. package/lib/public/Test.d.ts +3 -0
  35. package/lib/public/Test.js +2 -0
  36. package/lib/public/index.d.ts +2 -0
  37. package/lib/public/index.js +2 -0
  38. package/lib/public/repository.d.ts +2 -0
  39. package/lib/public/repository.js +2 -0
  40. package/package.json +21 -8
  41. package/lib/private/detype.d.ts +0 -3
  42. package/lib/private/detype.js +0 -2
  43. package/lib/public/detype.d.ts +0 -2
  44. package/lib/public/detype.js +0 -2
@@ -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,62 @@
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
+ if (expected !== undefined) {
15
+ this.#report(expected, equals(this.#actual, expected));
16
+ }
17
+ }
18
+ nequals(expected) {
19
+ this.#report(expected, !equals(this.#actual, expected));
20
+ }
21
+ #static(expected) {
22
+ this.#report(expected, equals(this.#actual, expected));
23
+ }
24
+ true() {
25
+ this.#static(true);
26
+ }
27
+ false() {
28
+ this.#static(false);
29
+ }
30
+ null() {
31
+ this.#static(null);
32
+ }
33
+ undefined() {
34
+ this.#static(undefined);
35
+ }
36
+ instance(expected) {
37
+ this.#report(expected, this.#actual instanceof expected);
38
+ }
39
+ throws(expected) {
40
+ try {
41
+ this.#actual();
42
+ this.#report("[void]", false);
43
+ }
44
+ catch (error) {
45
+ const { message } = E(error);
46
+ const messaged = expected !== undefined;
47
+ this.#report(message, messaged ? equals(message, expected) : true);
48
+ }
49
+ }
50
+ tries() {
51
+ try {
52
+ this.#actual();
53
+ this.#report("[void]", true);
54
+ }
55
+ catch (error) {
56
+ const { message } = E(error);
57
+ this.#report(`[threw] ${message}`, false);
58
+ }
59
+ }
60
+ }
61
+ ;
62
+ //# sourceMappingURL=Assert.js.map
@@ -0,0 +1,4 @@
1
+ import Assert from "#Assert";
2
+ type Asserter = <T>(actual: T) => Assert<T>;
3
+ export { Asserter as default };
4
+ //# sourceMappingURL=Asserter.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=Asserter.js.map
@@ -0,0 +1,4 @@
1
+ import Asserter from "#Asserter";
2
+ type Body = (asserter: Asserter) => void;
3
+ export { Body as default };
4
+ //# sourceMappingURL=Body.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=Body.js.map
@@ -0,0 +1,6 @@
1
+ type ErrorMessage = {
2
+ message: string;
3
+ };
4
+ declare const _default: (error: unknown) => ErrorMessage;
5
+ export default _default;
6
+ //# sourceMappingURL=E.d.ts.map
@@ -0,0 +1,2 @@
1
+ export default (error) => error;
2
+ //# sourceMappingURL=E.js.map
@@ -0,0 +1,6 @@
1
+ declare const NEVER: {
2
+ (value: unknown): never;
3
+ undefined: never;
4
+ };
5
+ export default NEVER;
6
+ //# sourceMappingURL=NEVER.d.ts.map
@@ -0,0 +1,4 @@
1
+ const NEVER = (value) => value;
2
+ NEVER.undefined = NEVER(undefined);
3
+ export default NEVER;
4
+ //# sourceMappingURL=NEVER.js.map
@@ -0,0 +1,8 @@
1
+ export default class Result<T> {
2
+ #private;
3
+ constructor(actual: T, expected: T, passed: boolean);
4
+ get actual(): T;
5
+ get expected(): T;
6
+ get passed(): boolean;
7
+ }
8
+ //# sourceMappingURL=Result.d.ts.map
@@ -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
@@ -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
- [record.is, (x, y) => record.is(y) && record.equal(x, y)],
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,6 @@
1
+ import Body from "#Body";
2
+ declare const _default: {
3
+ case(name: string, body: Body): void;
4
+ };
5
+ export default _default;
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,7 @@
1
+ import repository from "#repository";
2
+ export default {
3
+ case(name, body) {
4
+ repository.put(name, body);
5
+ }
6
+ };
7
+ //# sourceMappingURL=index.js.map
@@ -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
@@ -1,4 +1,4 @@
1
- import type { UnknownMap } from "#types/map";
1
+ import type UnknownMap from "@rcompat/type/UnknownMap";
2
2
  declare const _default: (map: UnknownMap) => {
3
3
  [k: string]: unknown;
4
4
  };
@@ -0,0 +1,7 @@
1
+ import type UnknownFunction from "@rcompat/type/UnknownFunction";
2
+ declare const _default: {
3
+ is: (x: unknown) => x is UnknownFunction;
4
+ equal: <T extends UnknownFunction>(x: T, y: T) => boolean;
5
+ };
6
+ export default _default;
7
+ //# sourceMappingURL=fn.d.ts.map
@@ -0,0 +1,4 @@
1
+ const is = (x) => typeof x === "function";
2
+ const equal = (x, y) => x.length === y.length;
3
+ export default { is, equal };
4
+ //# sourceMappingURL=fn.js.map
@@ -1,4 +1,4 @@
1
- export type UnknownMap = Map<PropertyKey, unknown>;
1
+ import type UnknownMap from "@rcompat/type/UnknownMap";
2
2
  declare const _default: {
3
3
  equal: <T extends UnknownMap>(x: T, y: T) => boolean;
4
4
  include: <T extends UnknownMap>(x: T, y: T) => boolean;
@@ -1,4 +1,4 @@
1
- import Dictionary from "@rcompat/record/Dictionary";
1
+ import type Dictionary from "@rcompat/type/Dictionary";
2
2
  declare const _default: {
3
3
  equal: <T extends Dictionary>(x: T, y: T) => boolean;
4
4
  include: <T extends Dictionary>(x: T, y: T) => boolean;
@@ -1,4 +1,4 @@
1
- export type UnknownSet = Set<unknown>;
1
+ import type UnknownSet from "@rcompat/type/UnknownSet";
2
2
  declare const _default: {
3
3
  equal: <T extends UnknownSet>(x: T, y: T) => boolean;
4
4
  include: <T extends UnknownSet>(x: T, y: T) => boolean;
@@ -0,0 +1,2 @@
1
+ export { default } from "#Asserter";
2
+ //# sourceMappingURL=Asserter.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=Asserter.js.map
@@ -0,0 +1,2 @@
1
+ export { default } from "#E";
2
+ //# sourceMappingURL=E.d.ts.map
@@ -0,0 +1,2 @@
1
+ export { default } from "#E";
2
+ //# sourceMappingURL=E.js.map
@@ -0,0 +1,2 @@
1
+ export { default } from "#NEVER";
2
+ //# sourceMappingURL=NEVER.d.ts.map
@@ -0,0 +1,2 @@
1
+ export { default } from "#NEVER";
2
+ //# sourceMappingURL=NEVER.js.map
@@ -0,0 +1,3 @@
1
+ import type Result from "#Result";
2
+ export type { Result as default };
3
+ //# sourceMappingURL=Result.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=Result.js.map
@@ -0,0 +1,3 @@
1
+ import type Test from "#Test";
2
+ export type { Test as default };
3
+ //# sourceMappingURL=Test.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=Test.js.map
@@ -0,0 +1,2 @@
1
+ export { default } from "#index";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,2 @@
1
+ export { default } from "#index";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,2 @@
1
+ export { default } from "#repository";
2
+ //# sourceMappingURL=repository.d.ts.map
@@ -0,0 +1,2 @@
1
+ export { default } from "#repository";
2
+ //# sourceMappingURL=repository.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rcompat/test",
3
- "version": "0.0.2",
3
+ "version": "0.1.1",
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.2"
19
+ },
17
20
  "dependencies": {
18
- "@rcompat/core": "^0.6.0",
19
- "@rcompat/record": "^0.6.2"
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
- "livetypes": "./src/private/types/*.ts",
30
+ "apekit": "./src/private/types/*.ts",
25
31
  "default": "./lib/private/types/*.js"
26
32
  },
27
33
  "#*": {
28
- "livetypes": "./src/private/*.ts",
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
- "livetypes": "./src/public/*.ts",
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
  }
@@ -1,3 +0,0 @@
1
- declare const _default: <T>(t: (...params: any[]) => T) => (...params: any[]) => T;
2
- export default _default;
3
- //# sourceMappingURL=detype.d.ts.map
@@ -1,2 +0,0 @@
1
- export default (t) => t;
2
- //# sourceMappingURL=detype.js.map
@@ -1,2 +0,0 @@
1
- export { default } from "#detype";
2
- //# sourceMappingURL=detype.d.ts.map
@@ -1,2 +0,0 @@
1
- export { default } from "#detype";
2
- //# sourceMappingURL=detype.js.map