@plugjs/expect5 0.4.1 → 0.4.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.
Files changed (59) hide show
  1. package/dist/cli.mjs +1 -1
  2. package/dist/expectation/async.cjs +73 -0
  3. package/dist/expectation/async.cjs.map +6 -0
  4. package/dist/expectation/async.d.ts +54 -0
  5. package/dist/expectation/async.mjs +46 -0
  6. package/dist/expectation/async.mjs.map +6 -0
  7. package/dist/expectation/basic.cjs +155 -183
  8. package/dist/expectation/basic.cjs.map +1 -1
  9. package/dist/expectation/basic.d.ts +90 -47
  10. package/dist/expectation/basic.mjs +142 -163
  11. package/dist/expectation/basic.mjs.map +1 -1
  12. package/dist/expectation/diff.cjs +7 -7
  13. package/dist/expectation/diff.cjs.map +1 -1
  14. package/dist/expectation/diff.mjs +7 -7
  15. package/dist/expectation/diff.mjs.map +1 -1
  16. package/dist/expectation/expect.cjs +94 -108
  17. package/dist/expectation/expect.cjs.map +2 -2
  18. package/dist/expectation/expect.d.ts +103 -130
  19. package/dist/expectation/expect.mjs +131 -137
  20. package/dist/expectation/expect.mjs.map +2 -2
  21. package/dist/expectation/include.cjs +50 -61
  22. package/dist/expectation/include.cjs.map +1 -1
  23. package/dist/expectation/include.d.ts +19 -10
  24. package/dist/expectation/include.mjs +53 -57
  25. package/dist/expectation/include.mjs.map +1 -1
  26. package/dist/expectation/throwing.cjs +27 -27
  27. package/dist/expectation/throwing.cjs.map +1 -1
  28. package/dist/expectation/throwing.d.ts +36 -8
  29. package/dist/expectation/throwing.mjs +26 -26
  30. package/dist/expectation/throwing.mjs.map +1 -1
  31. package/dist/expectation/trivial.cjs +96 -0
  32. package/dist/expectation/trivial.cjs.map +6 -0
  33. package/dist/expectation/trivial.d.ts +13 -0
  34. package/dist/expectation/trivial.mjs +61 -0
  35. package/dist/expectation/trivial.mjs.map +6 -0
  36. package/dist/expectation/types.cjs +9 -12
  37. package/dist/expectation/types.cjs.map +1 -1
  38. package/dist/expectation/types.d.ts +52 -10
  39. package/dist/expectation/types.mjs +8 -10
  40. package/dist/expectation/types.mjs.map +1 -1
  41. package/dist/index.cjs.map +1 -1
  42. package/dist/index.d.ts +1 -0
  43. package/dist/index.mjs.map +1 -1
  44. package/package.json +2 -2
  45. package/src/expectation/async.ts +151 -0
  46. package/src/expectation/basic.ts +356 -156
  47. package/src/expectation/diff.ts +8 -9
  48. package/src/expectation/expect.ts +239 -268
  49. package/src/expectation/include.ts +93 -59
  50. package/src/expectation/throwing.ts +102 -41
  51. package/src/expectation/trivial.ts +107 -0
  52. package/src/expectation/types.ts +82 -25
  53. package/src/index.ts +2 -0
  54. package/dist/expectation/void.cjs +0 -111
  55. package/dist/expectation/void.cjs.map +0 -6
  56. package/dist/expectation/void.d.ts +0 -39
  57. package/dist/expectation/void.mjs +0 -77
  58. package/dist/expectation/void.mjs.map +0 -6
  59. package/src/expectation/void.ts +0 -80
@@ -1,50 +1,49 @@
1
1
  // expectation/include.ts
2
2
  import { diff } from "./diff.mjs";
3
- import { ExpectationError, stringifyObjectType, stringifyValue } from "./types.mjs";
4
- var ToInclude = class {
5
- expect(context, negative, expected) {
6
- if (expected instanceof Map)
7
- return includesMappings(context, negative, expected);
8
- if (expected instanceof Set)
9
- return includesValues(context, negative, expected);
10
- if (Array.isArray(expected))
11
- return includesValues(context, negative, new Set(expected));
12
- if (expected instanceof Object)
13
- return includesProps(context, negative, expected);
14
- throw new TypeError(`Invalid type for "toInclude(...)": ${stringifyValue(expected)}`);
15
- }
16
- };
17
- var ToMatchContents = class {
18
- expect(context, negative, contents) {
19
- let actual;
20
- let expected;
21
- try {
22
- actual = new Set(context.value);
23
- expected = new Set(contents);
24
- } catch (error) {
25
- throw new ExpectationError(context, false, "to be an iterable object");
26
- }
27
- const result = diff(actual, expected);
28
- delete result.error;
29
- if (result.diff === negative)
30
- return;
31
- throw new ExpectationError(
32
- context,
33
- negative,
34
- `to match contents of ${stringifyObjectType(contents)}`,
35
- { ...result, value: context.value }
36
- );
3
+ import {
4
+ ExpectationError,
5
+ stringifyObjectType,
6
+ stringifyValue
7
+ } from "./types.mjs";
8
+ function toInclude(expected) {
9
+ if (expected instanceof Map)
10
+ return includesMappings(this, expected);
11
+ if (expected instanceof Set)
12
+ return includesValues(this, expected);
13
+ if (Array.isArray(expected))
14
+ return includesValues(this, new Set(expected));
15
+ if (expected instanceof Object)
16
+ return includesProps(this, expected);
17
+ throw new TypeError(`Invalid type for "toInclude(...)": ${stringifyValue(expected)}`);
18
+ }
19
+ function toMatchContents(contents) {
20
+ let actual;
21
+ let expected;
22
+ try {
23
+ actual = new Set(this.value);
24
+ expected = new Set(contents);
25
+ } catch (error) {
26
+ throw new ExpectationError(this, "to be an iterable object", false);
37
27
  }
38
- };
39
- function includesProps(context, negative, expected) {
28
+ const result = diff(actual, expected);
29
+ delete result.error;
30
+ if (result.diff === this.negative)
31
+ return this.expects;
32
+ throw new ExpectationError(
33
+ this,
34
+ `to match contents of ${stringifyObjectType(contents)}`,
35
+ { ...result, value: this.value }
36
+ );
37
+ }
38
+ function includesProps(context, expected) {
40
39
  if (context.value instanceof Map) {
41
- return includesMappings(context, negative, new Map(Object.entries(expected)));
40
+ return includesMappings(context, new Map(Object.entries(expected)));
42
41
  }
43
- context.toBeInstanceOf(Object);
42
+ context.expects.toBeInstanceOf(Object);
44
43
  const actual = context.value;
45
44
  const keys = new Set(Object.keys(expected));
46
45
  const props = {};
47
- if (negative) {
46
+ if (context.negative) {
48
47
  for (const key of keys) {
49
48
  if (actual[key] !== void 0 || key in actual) {
50
49
  props[key] = { diff: true, extra: actual[key] };
@@ -66,22 +65,22 @@ function includesProps(context, negative, expected) {
66
65
  }
67
66
  const count = Object.keys(props).length;
68
67
  if (count === 0)
69
- return;
68
+ return context.expects;
70
69
  const type = count === 1 ? "property" : "properties";
71
- throw new ExpectationError(context, negative, `to include ${count} ${type}`, {
70
+ throw new ExpectationError(context, `to include ${count} ${type}`, {
72
71
  diff: true,
73
72
  value: actual,
74
73
  props
75
74
  });
76
75
  }
77
- function includesValues(context, negative, expected) {
78
- context.toBeInstanceOf(Object);
76
+ function includesValues(context, expected) {
77
+ context.expects.toBeInstanceOf(Object);
79
78
  if (typeof context.value[Symbol.iterator] !== "function") {
80
- throw new ExpectationError(context, false, "to be an iterable object");
79
+ throw new ExpectationError(context, "to be an iterable object", false);
81
80
  }
82
81
  const actual = new Set(context.value);
83
82
  const values = [];
84
- if (negative) {
83
+ if (context.negative) {
85
84
  for (const exp of expected) {
86
85
  for (const act of actual) {
87
86
  const result = diff(act, exp);
@@ -108,20 +107,20 @@ function includesValues(context, negative, expected) {
108
107
  }
109
108
  const count = values.length;
110
109
  if (count === 0)
111
- return;
110
+ return context.expects;
112
111
  const type = count === 1 ? "value" : "values";
113
- throw new ExpectationError(context, negative, `to include ${count} ${type}`, {
112
+ throw new ExpectationError(context, `to include ${count} ${type}`, {
114
113
  diff: true,
115
114
  value: context.value,
116
115
  values
117
116
  });
118
117
  }
119
- function includesMappings(context, negative, expected) {
120
- context.toBeInstanceOf(Map);
118
+ function includesMappings(context, expected) {
119
+ context.expects.toBeInstanceOf(Map);
121
120
  const actual = context.value;
122
121
  const keys = new Set(expected.keys());
123
122
  const mappings = [];
124
- if (negative) {
123
+ if (context.negative) {
125
124
  for (const key of keys) {
126
125
  if (actual.has(key)) {
127
126
  mappings.push([key, { diff: true, extra: actual.get(key) }]);
@@ -140,19 +139,16 @@ function includesMappings(context, negative, expected) {
140
139
  }
141
140
  const count = mappings.length;
142
141
  if (count === 0)
143
- return;
142
+ return context.expects;
144
143
  const type = count === 1 ? "mapping" : "mappings";
145
- throw new ExpectationError(context, negative, `to include ${count} ${type}`, {
144
+ throw new ExpectationError(context, `to include ${count} ${type}`, {
146
145
  diff: true,
147
146
  value: context.value,
148
147
  mappings
149
148
  });
150
149
  }
151
150
  export {
152
- ToInclude,
153
- ToMatchContents,
154
- includesMappings,
155
- includesProps,
156
- includesValues
151
+ toInclude,
152
+ toMatchContents
157
153
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ACrB,iBAAS,KAAK,CAAE,KAAK,EAAE,MAAM,MAAM,SAAS,SAAS,IAAI,GAAG,EAAE,CAAE,CAAC;AAAA,MACnE,OAAO;AACL,cAAM,SAAS,KAAK,OAAO,IAAI,GAAG,GAAG,SAAS,IAAI,GAAG,CAAC;AACtD,YAAI,OAAO;AAAM,mBAAS,KAAK,CAAE,KAAK,MAAO,CAAC;AAAA,MAChD;AAAA,IACF;AAAA,EACF;AAEA,QAAM,QAAQ,SAAS;AACvB,MAAI,UAAU;AAAG,WAAO,QAAQ;AAEhC,QAAM,OAAO,UAAU,IAAI,YAAY;AACvC,QAAM,IAAI,iBAAiB,SAAS,cAAc,SAAS,QAAQ;AAAA,IACjE,MAAM;AAAA,IACN,OAAO,QAAQ;AAAA,IACf;AAAA,EACF,CAAC;AACH;",
5
5
  "names": []
6
6
  }
@@ -20,39 +20,39 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
20
20
  // expectation/throwing.ts
21
21
  var throwing_exports = {};
22
22
  __export(throwing_exports, {
23
- ToThrow: () => ToThrow,
24
- ToThrowError: () => ToThrowError
23
+ toThrow: () => toThrow,
24
+ toThrowError: () => toThrowError
25
25
  });
26
26
  module.exports = __toCommonJS(throwing_exports);
27
27
  var import_types = require("./types.cjs");
28
- var ToThrow = class {
29
- expect(context, negative, assert) {
30
- (0, import_types.assertType)(context, "function");
31
- let thrown;
32
- let error;
33
- try {
34
- context.value();
35
- thrown = false;
36
- error = void 0;
37
- } catch (caught) {
38
- thrown = true;
39
- error = caught;
40
- }
41
- if (thrown === negative) {
42
- throw new import_types.ExpectationError(context, negative, "to throw");
43
- } else if (thrown && assert) {
44
- assert(context.forValue(error));
45
- }
28
+ function toThrow(assert) {
29
+ (0, import_types.assertContextType)(this, "function");
30
+ let thrown;
31
+ let error;
32
+ try {
33
+ this.value();
34
+ thrown = false;
35
+ error = void 0;
36
+ } catch (caught) {
37
+ thrown = true;
38
+ error = caught;
46
39
  }
47
- };
48
- var ToThrowError = class {
49
- expect(context, negative, ...args) {
50
- context.negated(negative).toThrow((assert) => assert.toBeError(...args));
40
+ if (thrown === this.negative) {
41
+ throw new import_types.ExpectationError(this, "to throw");
42
+ } else if (thrown && assert) {
43
+ assert(this.forValue(error));
51
44
  }
52
- };
45
+ return this.expects;
46
+ }
47
+ function toThrowError(...args) {
48
+ return this.negated.toThrow((assert) => (
49
+ // @ts-ignore // can't reconcile the types with overloads...
50
+ assert.toBeError(...args)
51
+ ));
52
+ }
53
53
  // Annotate the CommonJS export names for ESM import in node:
54
54
  0 && (module.exports = {
55
- ToThrow,
56
- ToThrowError
55
+ toThrow,
56
+ toThrowError
57
57
  });
58
58
  //# sourceMappingURL=throwing.cjs.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/expectation/throwing.ts"],
4
- "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAA6C;AAKtC,IAAM,UAAN,MAAqC;AAAA,EAC1C,OACI,SACA,UACA,QACI;AACN,iCAAW,SAAS,UAAU;AAE9B,QAAI;AACJ,QAAI;AACJ,QAAI;AACF,cAAQ,MAAM;AACd,eAAS;AACT,cAAQ;AAAA,IACV,SAAS,QAAP;AACA,eAAS;AACT,cAAQ;AAAA,IACV;AAEA,QAAI,WAAW,UAAU;AACvB,YAAM,IAAI,8BAAiB,SAAS,UAAU,UAAU;AAAA,IAC1D,WAAW,UAAU,QAAQ;AAC3B,aAAO,QAAQ,SAAS,KAAK,CAAC;AAAA,IAChC;AAAA,EACF;AACF;AAEO,IAAM,eAAN,MAA0C;AAAA,EAC/C,OACI,SACA,aACG,MAKC;AACN,YAAQ,QAAQ,QAAQ,EAAE,QAAQ,CAAC,WAAW,OAAO,UAAU,GAAG,IAAI,CAAC;AAAA,EACzE;AACF;",
4
+ "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,mBAAoD;AAsBpD,SAAS,QAEL,QACY;AACd,sCAAkB,MAAM,UAAU;AAElC,MAAI;AACJ,MAAI;AACJ,MAAI;AACF,SAAK,MAAM;AACX,aAAS;AACT,YAAQ;AAAA,EACV,SAAS,QAAP;AACA,aAAS;AACT,YAAQ;AAAA,EACV;AAEA,MAAI,WAAW,KAAK,UAAU;AAC5B,UAAM,IAAI,8BAAiB,MAAM,UAAU;AAAA,EAC7C,WAAW,UAAU,QAAQ;AAC3B,WAAO,KAAK,SAAS,KAAK,CAAC;AAAA,EAC7B;AAEA,SAAO,KAAK;AACd;AAsCA,SAAS,gBAEF,MAOS;AACd,SAAO,KAAK,QAAQ,QAAQ,CAAC;AAAA;AAAA,IAE3B,OAAO,UAAU,GAAG,IAAI;AAAA,GAAC;AAC7B;",
5
5
  "names": []
6
6
  }
@@ -1,8 +1,36 @@
1
- import type { Expectation, Expectations } from './expect';
2
- import type { Constructor, StringMatcher } from './types';
3
- export declare class ToThrow implements Expectation {
4
- expect(context: Expectations, negative: boolean, assert?: (errorExpectations: Expectations) => void): void;
5
- }
6
- export declare class ToThrowError implements Expectation {
7
- expect(context: Expectations, negative: boolean, ...args: [] | [message: StringMatcher] | [constructor: Constructor<Error>] | [constructor: Constructor<Error>, message: StringMatcher]): void;
8
- }
1
+ import type { AssertionFunction, Constructor, JoinExpectations } from './types';
2
+ /** Expects the value to be a `function` throwing _anything_. */
3
+ declare function toThrow<T>(this: T): JoinExpectations<T, Function>;
4
+ /**
5
+ * Expects the value to be a `function` throwing, and asserts the
6
+ * thrown value with the specified callback.
7
+ */
8
+ declare function toThrow<T>(this: T, assert: AssertionFunction): JoinExpectations<T, Function>;
9
+ /** Expects the value to be a `function` throwing an {@link Error}. */
10
+ declare function toThrowError<T>(this: T): JoinExpectations<T, Function>;
11
+ /**
12
+ * Expects the value to be a `function` throwing an {@link Error} with the
13
+ * specified _message_.
14
+ */
15
+ declare function toThrowError<T>(this: T, message: string): JoinExpectations<T, Function>;
16
+ /**
17
+ * Expects the value to be a `function` throwing an {@link Error} with its
18
+ * _message_ matching the specified {@link RegExp}.
19
+ */
20
+ declare function toThrowError<T>(this: T, expession: RegExp): JoinExpectations<T, Function>;
21
+ /**
22
+ * Expects the value to be a `function` throwing an {@link Error} of the
23
+ * specified _type_.
24
+ */
25
+ declare function toThrowError<T>(this: T, constructor: Constructor<Error>): JoinExpectations<T, Function>;
26
+ /**
27
+ * Expects the value to be a `function` throwing an {@link Error} of the
28
+ * specified _type_ with the specified _message_.
29
+ */
30
+ declare function toThrowError<T>(this: T, constructor: Constructor<Error>, message: string): JoinExpectations<T, Function>;
31
+ /**
32
+ * Expects the value to be a `function` throwing an {@link Error} of the
33
+ * specified _type_ with its _message_ matching the specified {@link RegExp}.
34
+ */
35
+ declare function toThrowError<T>(this: T, constructor: Constructor<Error>, expression: RegExp): JoinExpectations<T, Function>;
36
+ export { toThrow, toThrowError, };
@@ -1,32 +1,32 @@
1
1
  // expectation/throwing.ts
2
- import { ExpectationError, assertType } from "./types.mjs";
3
- var ToThrow = class {
4
- expect(context, negative, assert) {
5
- assertType(context, "function");
6
- let thrown;
7
- let error;
8
- try {
9
- context.value();
10
- thrown = false;
11
- error = void 0;
12
- } catch (caught) {
13
- thrown = true;
14
- error = caught;
15
- }
16
- if (thrown === negative) {
17
- throw new ExpectationError(context, negative, "to throw");
18
- } else if (thrown && assert) {
19
- assert(context.forValue(error));
20
- }
2
+ import { ExpectationError, assertContextType } from "./types.mjs";
3
+ function toThrow(assert) {
4
+ assertContextType(this, "function");
5
+ let thrown;
6
+ let error;
7
+ try {
8
+ this.value();
9
+ thrown = false;
10
+ error = void 0;
11
+ } catch (caught) {
12
+ thrown = true;
13
+ error = caught;
21
14
  }
22
- };
23
- var ToThrowError = class {
24
- expect(context, negative, ...args) {
25
- context.negated(negative).toThrow((assert) => assert.toBeError(...args));
15
+ if (thrown === this.negative) {
16
+ throw new ExpectationError(this, "to throw");
17
+ } else if (thrown && assert) {
18
+ assert(this.forValue(error));
26
19
  }
27
- };
20
+ return this.expects;
21
+ }
22
+ function toThrowError(...args) {
23
+ return this.negated.toThrow((assert) => (
24
+ // @ts-ignore // can't reconcile the types with overloads...
25
+ assert.toBeError(...args)
26
+ ));
27
+ }
28
28
  export {
29
- ToThrow,
30
- ToThrowError
29
+ toThrow,
30
+ toThrowError
31
31
  };
32
32
  //# sourceMappingURL=throwing.mjs.map
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/expectation/throwing.ts"],
4
- "mappings": ";AAAA,SAAS,kBAAkB,kBAAkB;AAKtC,IAAM,UAAN,MAAqC;AAAA,EAC1C,OACI,SACA,UACA,QACI;AACN,eAAW,SAAS,UAAU;AAE9B,QAAI;AACJ,QAAI;AACJ,QAAI;AACF,cAAQ,MAAM;AACd,eAAS;AACT,cAAQ;AAAA,IACV,SAAS,QAAP;AACA,eAAS;AACT,cAAQ;AAAA,IACV;AAEA,QAAI,WAAW,UAAU;AACvB,YAAM,IAAI,iBAAiB,SAAS,UAAU,UAAU;AAAA,IAC1D,WAAW,UAAU,QAAQ;AAC3B,aAAO,QAAQ,SAAS,KAAK,CAAC;AAAA,IAChC;AAAA,EACF;AACF;AAEO,IAAM,eAAN,MAA0C;AAAA,EAC/C,OACI,SACA,aACG,MAKC;AACN,YAAQ,QAAQ,QAAQ,EAAE,QAAQ,CAAC,WAAW,OAAO,UAAU,GAAG,IAAI,CAAC;AAAA,EACzE;AACF;",
4
+ "mappings": ";AAAA,SAAS,kBAAkB,yBAAyB;AAsBpD,SAAS,QAEL,QACY;AACd,oBAAkB,MAAM,UAAU;AAElC,MAAI;AACJ,MAAI;AACJ,MAAI;AACF,SAAK,MAAM;AACX,aAAS;AACT,YAAQ;AAAA,EACV,SAAS,QAAP;AACA,aAAS;AACT,YAAQ;AAAA,EACV;AAEA,MAAI,WAAW,KAAK,UAAU;AAC5B,UAAM,IAAI,iBAAiB,MAAM,UAAU;AAAA,EAC7C,WAAW,UAAU,QAAQ;AAC3B,WAAO,KAAK,SAAS,KAAK,CAAC;AAAA,EAC7B;AAEA,SAAO,KAAK;AACd;AAsCA,SAAS,gBAEF,MAOS;AACd,SAAO,KAAK,QAAQ,QAAQ,CAAC;AAAA;AAAA,IAE3B,OAAO,UAAU,GAAG,IAAI;AAAA,GAAC;AAC7B;",
5
5
  "names": []
6
6
  }
@@ -0,0 +1,96 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // expectation/trivial.ts
21
+ var trivial_exports = {};
22
+ __export(trivial_exports, {
23
+ toBeDefined: () => toBeDefined,
24
+ toBeFalse: () => toBeFalse,
25
+ toBeFalsy: () => toBeFalsy,
26
+ toBeNaN: () => toBeNaN,
27
+ toBeNegativeInfinity: () => toBeNegativeInfinity,
28
+ toBeNull: () => toBeNull,
29
+ toBeNullable: () => toBeNullable,
30
+ toBePositiveInfinity: () => toBePositiveInfinity,
31
+ toBeTrue: () => toBeTrue,
32
+ toBeTruthy: () => toBeTruthy,
33
+ toBeUndefined: () => toBeUndefined
34
+ });
35
+ module.exports = __toCommonJS(trivial_exports);
36
+ var import_types = require("./types.cjs");
37
+ function toBeDefined() {
38
+ return check(this, "to be defined", (value) => value !== null && value !== void 0);
39
+ }
40
+ function toBeFalse() {
41
+ return check(this, `to be ${(0, import_types.stringifyValue)(false)}`, (value) => value === false);
42
+ }
43
+ function toBeFalsy() {
44
+ return check(this, "to be falsy", (value) => !value);
45
+ }
46
+ function toBeNaN() {
47
+ return check(this, `to be ${(0, import_types.stringifyValue)(NaN)}`, (value) => typeof value === "number" && isNaN(value));
48
+ }
49
+ function toBeNegativeInfinity() {
50
+ return check(this, `to equal ${(0, import_types.stringifyValue)(Number.NEGATIVE_INFINITY)}`, (value) => value === Number.NEGATIVE_INFINITY);
51
+ }
52
+ function toBeNull() {
53
+ return check(this, `to be ${(0, import_types.stringifyValue)(null)}`, (value) => value === null);
54
+ }
55
+ function toBeNullable() {
56
+ return check(
57
+ this,
58
+ `to be ${(0, import_types.stringifyValue)(null)} or ${(0, import_types.stringifyValue)(void 0)}`,
59
+ (value) => value === null || value === void 0
60
+ );
61
+ }
62
+ function toBePositiveInfinity() {
63
+ return check(this, `to equal ${(0, import_types.stringifyValue)(Number.POSITIVE_INFINITY)}`, (value) => value === Number.POSITIVE_INFINITY);
64
+ }
65
+ function toBeTrue() {
66
+ return check(this, `to be ${(0, import_types.stringifyValue)(true)}`, (value) => value === true);
67
+ }
68
+ function toBeTruthy() {
69
+ return check(this, "to be truthy", (value) => !!value);
70
+ }
71
+ function toBeUndefined() {
72
+ return check(this, `to be ${(0, import_types.stringifyValue)(void 0)}`, (value) => value === void 0);
73
+ }
74
+ function check(context, details, cb) {
75
+ const match = cb(context.value);
76
+ if (match === context.negative) {
77
+ throw new import_types.ExpectationError(context, details);
78
+ } else {
79
+ return context.expects;
80
+ }
81
+ }
82
+ // Annotate the CommonJS export names for ESM import in node:
83
+ 0 && (module.exports = {
84
+ toBeDefined,
85
+ toBeFalse,
86
+ toBeFalsy,
87
+ toBeNaN,
88
+ toBeNegativeInfinity,
89
+ toBeNull,
90
+ toBeNullable,
91
+ toBePositiveInfinity,
92
+ toBeTrue,
93
+ toBeTruthy,
94
+ toBeUndefined
95
+ });
96
+ //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;AAIA,SAAS,aAAmD;AAC1D,SAAO,MAAM,MAAM,gBAAgB,CAAC,UAAU,CAAC,CAAE,KAAK;AACxD;AAIA,SAAS,gBAAuD;AAC9D,SAAO,MAAM,MAAM,aAAS,6BAAe,MAAS,KAAK,CAAC,UAAU,UAAU,MAAS;AACzF;AAuBA,SAAS,MACL,SACA,SACA,IACY;AACd,QAAM,QAAQ,GAAG,QAAQ,KAAK;AAC9B,MAAI,UAAU,QAAQ,UAAU;AAC9B,UAAM,IAAI,8BAAiB,SAAS,OAAO;AAAA,EAC7C,OAAO;AACL,WAAO,QAAQ;AAAA,EACjB;AACF;",
5
+ "names": []
6
+ }
@@ -0,0 +1,13 @@
1
+ import type { Expectations } from './expect';
2
+ declare function toBeDefined<T>(this: T): T;
3
+ declare function toBeFalse(): Expectations<false>;
4
+ declare function toBeFalsy<T>(this: T): T;
5
+ declare function toBeNaN(): Expectations<number>;
6
+ declare function toBeNegativeInfinity(): Expectations<number>;
7
+ declare function toBeNull(): Expectations<null>;
8
+ declare function toBeNullable(): Expectations<null | undefined>;
9
+ declare function toBePositiveInfinity(): Expectations<number>;
10
+ declare function toBeTrue(): Expectations<true>;
11
+ declare function toBeTruthy<T>(this: T): T;
12
+ declare function toBeUndefined(): Expectations<undefined>;
13
+ export { toBeDefined, toBeFalse, toBeFalsy, toBeNaN, toBeNegativeInfinity, toBeNull, toBeNullable, toBePositiveInfinity, toBeTrue, toBeTruthy, toBeUndefined, };
@@ -0,0 +1,61 @@
1
+ // expectation/trivial.ts
2
+ import { ExpectationError, stringifyValue } from "./types.mjs";
3
+ function toBeDefined() {
4
+ return check(this, "to be defined", (value) => value !== null && value !== void 0);
5
+ }
6
+ function toBeFalse() {
7
+ return check(this, `to be ${stringifyValue(false)}`, (value) => value === false);
8
+ }
9
+ function toBeFalsy() {
10
+ return check(this, "to be falsy", (value) => !value);
11
+ }
12
+ function toBeNaN() {
13
+ return check(this, `to be ${stringifyValue(NaN)}`, (value) => typeof value === "number" && isNaN(value));
14
+ }
15
+ function toBeNegativeInfinity() {
16
+ return check(this, `to equal ${stringifyValue(Number.NEGATIVE_INFINITY)}`, (value) => value === Number.NEGATIVE_INFINITY);
17
+ }
18
+ function toBeNull() {
19
+ return check(this, `to be ${stringifyValue(null)}`, (value) => value === null);
20
+ }
21
+ function toBeNullable() {
22
+ return check(
23
+ this,
24
+ `to be ${stringifyValue(null)} or ${stringifyValue(void 0)}`,
25
+ (value) => value === null || value === void 0
26
+ );
27
+ }
28
+ function toBePositiveInfinity() {
29
+ return check(this, `to equal ${stringifyValue(Number.POSITIVE_INFINITY)}`, (value) => value === Number.POSITIVE_INFINITY);
30
+ }
31
+ function toBeTrue() {
32
+ return check(this, `to be ${stringifyValue(true)}`, (value) => value === true);
33
+ }
34
+ function toBeTruthy() {
35
+ return check(this, "to be truthy", (value) => !!value);
36
+ }
37
+ function toBeUndefined() {
38
+ return check(this, `to be ${stringifyValue(void 0)}`, (value) => value === void 0);
39
+ }
40
+ function check(context, details, cb) {
41
+ const match = cb(context.value);
42
+ if (match === context.negative) {
43
+ throw new ExpectationError(context, details);
44
+ } else {
45
+ return context.expects;
46
+ }
47
+ }
48
+ export {
49
+ toBeDefined,
50
+ toBeFalse,
51
+ toBeFalsy,
52
+ toBeNaN,
53
+ toBeNegativeInfinity,
54
+ toBeNull,
55
+ toBeNullable,
56
+ toBePositiveInfinity,
57
+ toBeTrue,
58
+ toBeTruthy,
59
+ toBeUndefined
60
+ };
61
+ //# sourceMappingURL=trivial.mjs.map
@@ -0,0 +1,6 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/expectation/trivial.ts"],
4
+ "mappings": ";AAAA,SAAS,kBAAkB,sBAAsB;AAOjD,SAAS,cAAqD;AAC5D,SAAO,MAAM,MAAM,iBAAiB,CAAC,UAAW,UAAU,QAAU,UAAU,MAAU;AAC1F;AAIA,SAAS,YAAmD;AAC1D,SAAO,MAAM,MAAM,SAAS,eAAe,KAAK,KAAK,CAAC,UAAU,UAAU,K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S = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
21
21
  var types_exports = {};
22
22
  __export(types_exports, {
23
23
  ExpectationError: () => ExpectationError,
24
- assertType: () => assertType,
24
+ assertContextType: () => assertContextType,
25
25
  isMatcher: () => isMatcher,
26
- isType: () => isType,
27
26
  matcherMarker: () => matcherMarker,
28
27
  prefixType: () => prefixType,
29
28
  stringifyConstructor: () => stringifyConstructor,
@@ -62,14 +61,10 @@ function typeOf(value) {
62
61
  return "set";
63
62
  return "object";
64
63
  }
65
- function isType(context, type) {
66
- return typeOf(context.value) === type;
67
- }
68
- function assertType(context, type) {
69
- const { value } = context;
70
- if (typeOf(value) === type)
64
+ function assertContextType(context, type) {
65
+ if (typeOf(context.value) === type)
71
66
  return;
72
- throw new ExpectationError(context, false, `to be ${prefixType(type)}`);
67
+ throw new ExpectationError(context, `to be ${prefixType(type)}`, false);
73
68
  }
74
69
  function constructorName(value) {
75
70
  return Object.getPrototypeOf(value)?.constructor?.name;
@@ -174,7 +169,10 @@ function isMatcher(what) {
174
169
  }
175
170
  var ExpectationError = class extends Error {
176
171
  diff;
177
- constructor(context, negative, details, diff) {
172
+ /* Overloaded constructor implementation */
173
+ constructor(context, details, diffOrForcedNegative, maybeForcedNegative) {
174
+ const diff = typeof diffOrForcedNegative === "object" ? diffOrForcedNegative : null;
175
+ const negative = typeof diffOrForcedNegative === "boolean" ? diffOrForcedNegative : typeof maybeForcedNegative === "boolean" ? maybeForcedNegative : context.negative;
178
176
  const { value } = context;
179
177
  const not = negative ? " not" : "";
180
178
  let preamble = stringifyValue(value);
@@ -199,9 +197,8 @@ var ExpectationError = class extends Error {
199
197
  // Annotate the CommonJS export names for ESM import in node:
200
198
  0 && (module.exports = {
201
199
  ExpectationError,
202
- assertType,
200
+ assertContextType,
203
201
  isMatcher,
204
- isType,
205
202
  matcherMarker,
206
203
  prefixType,
207
204
  stringifyConstructor,