@rcompat/test 0.1.11 → 0.1.13

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.
@@ -1,11 +1,15 @@
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
- export default class Assert<T> {
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(actual: T, test: Test);
8
+ constructor(test: Test, actual?: Actual);
6
9
  equals(expected: unknown): this;
7
10
  nequals(expected: unknown): this;
8
- type<_Expected extends T>(): 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;
9
13
  true(): this;
10
14
  false(): this;
11
15
  null(): this;
@@ -13,6 +17,8 @@ export default class Assert<T> {
13
17
  instance(expected: UnknownFunction): this;
14
18
  throws(expected?: string): this;
15
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
@@ -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
- constructor(actual, test) {
5
+ #actual;
6
+ constructor(test, actual) {
7
7
  this.#actual = actual;
8
8
  this.#test = test;
9
9
  }
@@ -25,7 +25,9 @@ export default class Assert {
25
25
  return this;
26
26
  }
27
27
  type() {
28
- // noop
28
+ return this;
29
+ }
30
+ nottype() {
29
31
  return this;
30
32
  }
31
33
  #static(expected) {
@@ -75,7 +77,9 @@ export default class Assert {
75
77
  return this;
76
78
  }
77
79
  fail(reason) {
78
- this.#failed(reason);
80
+ if (reason !== undefined) {
81
+ this.#failed(reason);
82
+ }
79
83
  }
80
84
  }
81
85
  ;
@@ -1,4 +1,4 @@
1
- import Assert from "#Assert";
2
- type Asserter = <T>(actual: T) => Assert<T>;
1
+ import type Assert from "#Assert";
2
+ type Asserter = <const T>(actual?: T) => Assert<T>;
3
3
  export { Asserter as default };
4
4
  //# sourceMappingURL=Asserter.d.ts.map
@@ -1,4 +1,4 @@
1
- import Body from "#Body";
1
+ import type Body from "#Body";
2
2
  import Result from "#Result";
3
3
  import type FileRef from "@rcompat/fs/FileRef";
4
4
  export default class Test {
@@ -23,7 +23,7 @@ export default class Test {
23
23
  this.#results.push(new Result(actual, expected, passed));
24
24
  }
25
25
  run() {
26
- const asserter = (actual) => new Assert(actual, this);
26
+ const asserter = (actual) => new Assert(this, actual);
27
27
  this.#body(asserter);
28
28
  }
29
29
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rcompat/test",
3
- "version": "0.1.11",
3
+ "version": "0.1.13",
4
4
  "description": "Standard library testing",
5
5
  "bugs": "https://github.com/rcompat/rcompat/issues",
6
6
  "license": "MIT",