@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.
@@ -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<Expected extends T>(expected?: Expected): void;
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
@@ -7,19 +7,23 @@ export default class Assert {
7
7
  this.#actual = actual;
8
8
  this.#test = test;
9
9
  }
10
- #report(expected, passed) {
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
- if (expected !== undefined) {
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(expected, !equals(this.#actual, expected));
23
+ this.#report(!equals(this.#actual, expected), expected);
20
24
  }
21
25
  #static(expected) {
22
- this.#report(expected, equals(this.#actual, expected));
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(expected, this.#actual instanceof expected);
41
+ this.#report(this.#actual instanceof expected, expected);
38
42
  }
39
43
  throws(expected) {
40
44
  try {
41
45
  this.#actual();
42
- this.#report("[void]", false);
46
+ this.#failed("[did not throw]");
43
47
  }
44
48
  catch (error) {
45
49
  const { message } = E(error);
46
- const messaged = expected !== undefined;
47
- this.#report(message, messaged ? equals(message, expected) : true);
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.#report("[void]", true);
61
+ this.#passed();
54
62
  }
55
63
  catch (error) {
56
- const { message } = E(error);
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
@@ -1,4 +1,4 @@
1
- import Asserter from "#Asserter";
1
+ import type Asserter from "#Asserter";
2
2
  type Body = (asserter: Asserter) => void;
3
3
  export { Body as default };
4
4
  //# sourceMappingURL=Body.d.ts.map
@@ -0,0 +1,5 @@
1
+ export default class StaticAssert<T> {
2
+ constructor(_actual: T);
3
+ equals<_Expected extends T>(): void;
4
+ }
5
+ //# sourceMappingURL=StaticAssert.d.ts.map
@@ -0,0 +1,7 @@
1
+ export default class StaticAssert {
2
+ constructor(_actual) { }
3
+ // type check, no body
4
+ equals() { }
5
+ }
6
+ ;
7
+ //# sourceMappingURL=StaticAssert.js.map
@@ -0,0 +1,4 @@
1
+ import type StaticAssert from "#StaticAssert";
2
+ type StaticAsserter = <T>(actual: T) => StaticAssert<T>;
3
+ export { StaticAsserter as default };
4
+ //# sourceMappingURL=StaticAsserter.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=StaticAsserter.js.map
@@ -0,0 +1,4 @@
1
+ import type StaticAsserter from "#StaticAsserter";
2
+ type StaticBody = (asserter: StaticAsserter) => void;
3
+ export { StaticBody as default };
4
+ //# sourceMappingURL=StaticBody.d.ts.map
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=StaticBody.js.map
@@ -23,7 +23,8 @@ export default class Test {
23
23
  this.#results.push(new Result(actual, expected, passed));
24
24
  }
25
25
  run() {
26
- this.#body((actual) => new Assert(actual, this));
26
+ const asserter = (actual) => new Assert(actual, this);
27
+ this.#body(asserter);
27
28
  }
28
29
  }
29
30
  ;
@@ -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
@@ -2,6 +2,9 @@ import repository from "#repository";
2
2
  export default {
3
3
  case(name, body) {
4
4
  repository.put(name, body);
5
- }
5
+ },
6
+ static(_body) {
7
+ // noop
8
+ },
6
9
  };
7
10
  //# sourceMappingURL=index.js.map
@@ -0,0 +1,3 @@
1
+ declare const never: (value: unknown) => never;
2
+ export default never;
3
+ //# sourceMappingURL=never.d.ts.map
@@ -0,0 +1,3 @@
1
+ const never = (value) => value;
2
+ export default never;
3
+ //# sourceMappingURL=never.js.map
@@ -0,0 +1,3 @@
1
+ declare const _default: never;
2
+ export default _default;
3
+ //# sourceMappingURL=undef.d.ts.map
@@ -0,0 +1,3 @@
1
+ import never from "#never";
2
+ export default never(undefined);
3
+ //# sourceMappingURL=undef.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,2 @@
1
+ export { default } from "#undef";
2
+ //# sourceMappingURL=undef.d.ts.map
@@ -0,0 +1,2 @@
1
+ export { default } from "#undef";
2
+ //# sourceMappingURL=undef.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rcompat/test",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "test module",
5
5
  "bugs": "https://github.com/rcompat/rcompat/issues",
6
6
  "license": "MIT",
@@ -1,6 +0,0 @@
1
- declare const NEVER: {
2
- (value: unknown): never;
3
- undefined: never;
4
- };
5
- export default NEVER;
6
- //# sourceMappingURL=NEVER.d.ts.map
@@ -1,4 +0,0 @@
1
- const NEVER = (value) => value;
2
- NEVER.undefined = NEVER(undefined);
3
- export default NEVER;
4
- //# sourceMappingURL=NEVER.js.map
@@ -1,2 +0,0 @@
1
- export { default } from "#NEVER";
2
- //# sourceMappingURL=NEVER.d.ts.map
@@ -1,2 +0,0 @@
1
- export { default } from "#NEVER";
2
- //# sourceMappingURL=NEVER.js.map