assert-logic 1.0.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/README.md ADDED
@@ -0,0 +1,166 @@
1
+ # assert-logic
2
+
3
+ ![Downloads](https://img.shields.io/npm/dw/assert-logic?style=flat-square) ![Version@npm](https://img.shields.io/npm/v/assert-logic?label=version%40npm&style=flat-square) ![Version@git](https://img.shields.io/github/package-json/v/szikszail/assert-logic/main?label=version%40git&style=flat-square) ![CI](https://img.shields.io/github/actions/workflow/status/szikszail/assert-logic/ci.yml?branch=main&label=ci&style=flat-square) ![Docs](https://img.shields.io/github/actions/workflow/status/szikszail/assert-logic/docs.yml?branch=main&label=docs&style=flat-square)
4
+
5
+ This handy tool can be used to implement additional logic into your assertions, either using Chai, Jest, Assert, or
6
+ plain JavaScript.
7
+
8
+ ## Usage
9
+
10
+ Install the package:
11
+
12
+ ```shell
13
+ npm install assert-logic --save-dev
14
+ ```
15
+
16
+ Use it in your tests:
17
+
18
+ ```javascript
19
+ const {and, or} = require('assert-logic');
20
+ const {expect} = require('chai');
21
+
22
+ test("Test if a number is even and greater than 10 or less than 7", () => {
23
+ const number = 12;
24
+ and(
25
+ () => expect(number).to.be.an('number'),
26
+ () => expect(number % 2).to.equal(0),
27
+ or(
28
+ () => expect(number).to.be.lessThan(7),
29
+ () => expect(number).to.be.greaterThan(10),
30
+ ),
31
+ ).evaluate();
32
+ });
33
+ ```
34
+
35
+ ## API
36
+
37
+ ### Pass/Fail
38
+
39
+ In the context of this package, a value is considered failed if it is:
40
+
41
+ 1. a (sync) function that throws an error
42
+ 2. a (sync) function that returns a falsy value (except for `undefined`)
43
+ 3. a (async) function that returns a Promise that rejects
44
+ 4. a (async) function that returns a Promise that resolves to a falsy value (except for `undefined`)
45
+ 5. a Promise that rejects
46
+ 6. a Promise that resolves to a falsy value (except for `undefined`)
47
+ 7. value that is falsy (except for `undefined`)
48
+
49
+ In all other cases, the value is considered passed.
50
+
51
+ ### Operations
52
+
53
+ The API contains the following functions: `and`, `or`, `not`, `xor`, `nand`, `nor`, `xnor`, and also the `evaluate`
54
+ function. All accept any number of sync/async functions, Promises, or values as arguments.
55
+
56
+ | Operation | Description |
57
+ |-----------|---------------------------------------------------------|
58
+ | and | Passes if all of its arguments pass |
59
+ | or | Passes if any of its arguments pass |
60
+ | not | Negates the result of its argument |
61
+ | xor | Passes if odd number of its arguments passes |
62
+ | nand | Passes if any of its arguments fails |
63
+ | nor | Passes if all of its arguments fail |
64
+ | xnor | Passes if all of its arguments pass or all of them fail |
65
+
66
+ #### Append
67
+
68
+ The `append` function can be used to append additional logic to an existing variadic logic (all except `pass`).
69
+
70
+ ```javascript
71
+ const {and} = require('assert-logic');
72
+
73
+ const logic = and(
74
+ () => true,
75
+ () => false,
76
+ );
77
+ logic.append(() => true).evaluate(); // will throw an error
78
+ ```
79
+
80
+ ### Evaluation
81
+
82
+ The `evaluate` function will evaluate the logic and throw an error if it fails.
83
+
84
+ The `evaluate` function does not need to be called if the logic is used as an argument to an assertion, as the assertion
85
+ will call it automatically.
86
+
87
+ The evaluate function will return a Promise if any of the arguments are async.
88
+
89
+ ### AssertionError
90
+
91
+ Given the following expression what is expected to fail:
92
+ ```javascript
93
+ and(
94
+ xor(true, false, true),
95
+ true,
96
+ ).evaluate()
97
+ ```
98
+
99
+ The error message will look like this:
100
+
101
+ ```
102
+ AssertionError (AND): Expected all expression to pass, but not all did.
103
+ Results:
104
+ - AssertionError (XOR): Expected odd number of expressions to pass, but even number did.
105
+ Results:
106
+ - Pass
107
+ - AssertionError (PASS): Expected expression to pass.
108
+ Results:
109
+ - Error: "Failed expression: (boolean false)"
110
+ Expression: (boolean false)
111
+ - Pass
112
+ Expression: |-
113
+ XOR(
114
+ (boolean true)
115
+ (boolean false)
116
+ (boolean true)
117
+ )
118
+ - Pass
119
+ Expression: |-
120
+ AND(
121
+ XOR(
122
+ (boolean true)
123
+ (boolean false)
124
+ (boolean true)
125
+ )
126
+ (boolean true)
127
+ )
128
+ ```
129
+
130
+ ## How NOT to use it
131
+
132
+ ### As a replacement for assertions
133
+
134
+ This package is not meant to be used as a replacement for assertions, but rather as a tool to implement additional logic
135
+ into your assertions.
136
+
137
+ ### With passing the assertions directly
138
+
139
+ ```javascript
140
+ const {and} = require('assert-logic');
141
+ const {expect} = require('chai');
142
+
143
+ test("Test if a number is even and greater than 10 or less than 7", () => {
144
+ const number = 12;
145
+ and(
146
+ expect(number).to.be.an('number'),
147
+ expect(number % 2).to.equal(0),
148
+ or(
149
+ expect(number).to.be.lessThan(7),
150
+ expect(number).to.be.greaterThan(10),
151
+ ),
152
+ ).evaluate();
153
+ });
154
+ ```
155
+
156
+ This will not work as expected, as the assertions will be evaluated before the logic is evaluated.
157
+
158
+ ## Other
159
+
160
+ For detailed documentation see the [TypeDocs documentation](https://szikszail.github.io/assert-logic/).
161
+
162
+ This package uses [debug](https://www.npmjs.com/package/debug) for logging, use `assert-logic` to see debug logs:
163
+
164
+ ```shell
165
+ DEBUG=assert-logic node my-script.js
166
+ ```
@@ -0,0 +1,7 @@
1
+ import { Assertion } from "./assertion";
2
+ import type { AssertionValue, EvaluationResult } from "../types";
3
+ import { VariadicAssertion } from "./variadic";
4
+ export declare class ANDAssertion extends VariadicAssertion {
5
+ constructor(...values: (AssertionValue | Assertion)[]);
6
+ onEvaluation(results: EvaluationResult[]): void | Promise<void>;
7
+ }
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ANDAssertion = void 0;
4
+ const variadic_1 = require("./variadic");
5
+ class ANDAssertion extends variadic_1.VariadicAssertion {
6
+ constructor(...values) {
7
+ super("AND", "Expected all expression to pass, but not all did.", ...values);
8
+ }
9
+ onEvaluation(results) {
10
+ const failed = results.filter((result) => result instanceof Error);
11
+ if (failed.length > 0) {
12
+ this.fail(results);
13
+ }
14
+ }
15
+ }
16
+ exports.ANDAssertion = ANDAssertion;
17
+ //# sourceMappingURL=and.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"and.js","sourceRoot":"","sources":["../../src/assertion/and.ts"],"names":[],"mappings":";;;AAEA,yCAA6C;AAE7C,MAAa,YAAa,SAAQ,4BAAiB;IACjD,YAAY,GAAG,MAAsC;QACnD,KAAK,CAAC,KAAK,EAAE,mDAAmD,EAAE,GAAG,MAAM,CAAC,CAAC;IAC/E,CAAC;IAED,YAAY,CAAC,OAA2B;QACtC,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,YAAY,KAAK,CAAC,CAAC;QACnE,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACtB,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACrB,CAAC;IACH,CAAC;CACF;AAXD,oCAWC"}
@@ -0,0 +1,9 @@
1
+ import { EvaluationResult } from "../types";
2
+ export declare class Assertion {
3
+ protected readonly operator: string;
4
+ protected readonly expectation: string;
5
+ constructor(operator: string, expectation: string);
6
+ evaluate(): void | Promise<void>;
7
+ onEvaluation(results: EvaluationResult[]): void | Promise<void>;
8
+ protected fail(results: EvaluationResult[]): void;
9
+ }
@@ -0,0 +1,23 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Assertion = void 0;
4
+ const error_1 = require("../error");
5
+ class Assertion {
6
+ constructor(operator, expectation) {
7
+ this.operator = operator;
8
+ this.expectation = expectation;
9
+ }
10
+ evaluate() {
11
+ // pass
12
+ }
13
+ // @ts-ignore
14
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
15
+ onEvaluation(results) {
16
+ // pass
17
+ }
18
+ fail(results) {
19
+ throw new error_1.AssertionError(this.operator, this.expectation, this, results);
20
+ }
21
+ }
22
+ exports.Assertion = Assertion;
23
+ //# sourceMappingURL=assertion.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assertion.js","sourceRoot":"","sources":["../../src/assertion/assertion.ts"],"names":[],"mappings":";;;AAAA,oCAAwC;AAGxC,MAAa,SAAS;IACpB,YACqB,QAAgB,EAChB,WAAmB;QADnB,aAAQ,GAAR,QAAQ,CAAQ;QAChB,gBAAW,GAAX,WAAW,CAAQ;IAExC,CAAC;IAED,QAAQ;QACN,OAAO;IACT,CAAC;IAED,aAAa;IACb,6DAA6D;IAC7D,YAAY,CAAC,OAA2B;QACtC,OAAO;IACT,CAAC;IAES,IAAI,CAAC,OAA2B;QACxC,MAAM,IAAI,sBAAc,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,WAAW,EAAE,IAAI,EAAE,OAAO,CAAC,CAAC;IAC3E,CAAC;CACF;AApBD,8BAoBC"}
@@ -0,0 +1,7 @@
1
+ import { Assertion } from "./assertion";
2
+ import type { AssertionValue, EvaluationResult } from "../types";
3
+ import { VariadicAssertion } from "./variadic";
4
+ export declare class NANDAssertion extends VariadicAssertion {
5
+ constructor(...values: (AssertionValue | Assertion)[]);
6
+ onEvaluation(results: EvaluationResult[]): void | Promise<void>;
7
+ }
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NANDAssertion = void 0;
4
+ const variadic_1 = require("./variadic");
5
+ class NANDAssertion extends variadic_1.VariadicAssertion {
6
+ constructor(...values) {
7
+ super("NAND", "Expected any expressions to fail, but non did.", ...values);
8
+ }
9
+ onEvaluation(results) {
10
+ const failed = results.filter((result) => result instanceof Error);
11
+ if (failed.length === 0) {
12
+ this.fail(results);
13
+ }
14
+ }
15
+ }
16
+ exports.NANDAssertion = NANDAssertion;
17
+ //# sourceMappingURL=nand.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nand.js","sourceRoot":"","sources":["../../src/assertion/nand.ts"],"names":[],"mappings":";;;AAEA,yCAA6C;AAE7C,MAAa,aAAc,SAAQ,4BAAiB;IAClD,YAAY,GAAG,MAAsC;QACnD,KAAK,CAAC,MAAM,EAAE,gDAAgD,EAAE,GAAG,MAAM,CAAC,CAAC;IAC7E,CAAC;IAED,YAAY,CAAC,OAA2B;QACtC,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,YAAY,KAAK,CAAC,CAAC;QACnE,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YACxB,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACrB,CAAC;IACH,CAAC;CACF;AAXD,sCAWC"}
@@ -0,0 +1,7 @@
1
+ import { Assertion } from "./assertion";
2
+ import type { AssertionValue, EvaluationResult } from "../types";
3
+ import { VariadicAssertion } from "./variadic";
4
+ export declare class NORAssertion extends VariadicAssertion {
5
+ constructor(...values: (AssertionValue | Assertion)[]);
6
+ onEvaluation(results: EvaluationResult[]): void | Promise<void>;
7
+ }
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NORAssertion = void 0;
4
+ const variadic_1 = require("./variadic");
5
+ class NORAssertion extends variadic_1.VariadicAssertion {
6
+ constructor(...values) {
7
+ super("NOR", "Expected all expressions to fail, but some passed.", ...values);
8
+ }
9
+ onEvaluation(results) {
10
+ const failed = results.filter((result) => result instanceof Error);
11
+ if (failed.length !== results.length) {
12
+ this.fail(results);
13
+ }
14
+ }
15
+ }
16
+ exports.NORAssertion = NORAssertion;
17
+ //# sourceMappingURL=nor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"nor.js","sourceRoot":"","sources":["../../src/assertion/nor.ts"],"names":[],"mappings":";;;AAEA,yCAA6C;AAE7C,MAAa,YAAa,SAAQ,4BAAiB;IACjD,YAAY,GAAG,MAAsC;QACnD,KAAK,CAAC,KAAK,EAAE,oDAAoD,EAAE,GAAG,MAAM,CAAC,CAAC;IAChF,CAAC;IAED,YAAY,CAAC,OAA2B;QACtC,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,YAAY,KAAK,CAAC,CAAC;QACnE,IAAI,MAAM,CAAC,MAAM,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC;YACrC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACrB,CAAC;IACH,CAAC;CACF;AAXD,oCAWC"}
@@ -0,0 +1,7 @@
1
+ import { Assertion } from "./assertion";
2
+ import { AssertionValue, EvaluationResult } from "../types";
3
+ import { UnaryAssertion } from "./unary";
4
+ export declare class NOTAssertion extends UnaryAssertion {
5
+ constructor(value: AssertionValue | Assertion);
6
+ onEvaluation(results: EvaluationResult[]): void | Promise<void>;
7
+ }
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NOTAssertion = void 0;
4
+ const unary_1 = require("./unary");
5
+ class NOTAssertion extends unary_1.UnaryAssertion {
6
+ constructor(value) {
7
+ super("NOT", "Expected the expression to fail, but it passed.", value);
8
+ }
9
+ onEvaluation(results) {
10
+ if (results[0] === true) {
11
+ this.fail(results);
12
+ }
13
+ }
14
+ }
15
+ exports.NOTAssertion = NOTAssertion;
16
+ //# sourceMappingURL=not.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"not.js","sourceRoot":"","sources":["../../src/assertion/not.ts"],"names":[],"mappings":";;;AAEA,mCAAuC;AAEvC,MAAa,YAAa,SAAQ,sBAAc;IAC9C,YAAY,KAAiC;QAC3C,KAAK,CAAC,KAAK,EAAE,iDAAiD,EAAE,KAAK,CAAC,CAAC;IACzE,CAAC;IAED,YAAY,CAAC,OAA2B;QACtC,IAAI,OAAO,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;YACxB,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACrB,CAAC;IACH,CAAC;CACF;AAVD,oCAUC"}
@@ -0,0 +1,7 @@
1
+ import { Assertion } from "./assertion";
2
+ import type { AssertionValue, EvaluationResult } from "../types";
3
+ import { VariadicAssertion } from "./variadic";
4
+ export declare class ORAssertion extends VariadicAssertion {
5
+ constructor(...values: (AssertionValue | Assertion)[]);
6
+ onEvaluation(results: EvaluationResult[]): void | Promise<void>;
7
+ }
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ORAssertion = void 0;
4
+ const variadic_1 = require("./variadic");
5
+ class ORAssertion extends variadic_1.VariadicAssertion {
6
+ constructor(...values) {
7
+ super("OR", "Expected any expression to pass, but non did.", ...values);
8
+ }
9
+ onEvaluation(results) {
10
+ const failed = results.filter((result) => result instanceof Error);
11
+ if (failed.length === results.length) {
12
+ this.fail(results);
13
+ }
14
+ }
15
+ }
16
+ exports.ORAssertion = ORAssertion;
17
+ //# sourceMappingURL=or.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"or.js","sourceRoot":"","sources":["../../src/assertion/or.ts"],"names":[],"mappings":";;;AAEA,yCAA6C;AAE7C,MAAa,WAAY,SAAQ,4BAAiB;IAChD,YAAY,GAAG,MAAsC;QACnD,KAAK,CAAC,IAAI,EAAE,+CAA+C,EAAE,GAAG,MAAM,CAAC,CAAC;IAC1E,CAAC;IAED,YAAY,CAAC,OAA2B;QACtC,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,YAAY,KAAK,CAAC,CAAC;QACnE,IAAI,MAAM,CAAC,MAAM,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC;YACrC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACrB,CAAC;IACH,CAAC;CACF;AAXD,kCAWC"}
@@ -0,0 +1,9 @@
1
+ import { Assertion } from "./assertion";
2
+ import type { AssertionValue } from "../types";
3
+ export declare function valueToString(value: AssertionValue): string;
4
+ export declare class PASSAssertion extends Assertion {
5
+ private value;
6
+ constructor(value: AssertionValue);
7
+ evaluate(): void | Promise<void>;
8
+ toString(): string;
9
+ }
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PASSAssertion = exports.valueToString = void 0;
4
+ const assertion_1 = require("./assertion");
5
+ const error_1 = require("../error");
6
+ function valueToString(value) {
7
+ if (value instanceof Function) {
8
+ let name = value === null || value === void 0 ? void 0 : value.name;
9
+ if (!name) {
10
+ return '(function)';
11
+ }
12
+ if (name.length > 20) {
13
+ name = name.slice(0, 17) + "...";
14
+ }
15
+ return `(function ${name})`;
16
+ }
17
+ if (value instanceof Promise) {
18
+ return '(promise)';
19
+ }
20
+ return `(${typeof value} ${String(value)})`;
21
+ }
22
+ exports.valueToString = valueToString;
23
+ class PASSAssertion extends assertion_1.Assertion {
24
+ constructor(value) {
25
+ super("PASS", "Expected expression to pass.");
26
+ this.value = value;
27
+ if (value instanceof assertion_1.Assertion) {
28
+ return value;
29
+ }
30
+ }
31
+ evaluate() {
32
+ let result = this.value;
33
+ if (result instanceof Function) {
34
+ try {
35
+ result = result();
36
+ }
37
+ catch (e) {
38
+ this.fail([e]);
39
+ }
40
+ }
41
+ if (result instanceof Promise) {
42
+ return result.then((value) => {
43
+ if (value !== undefined && !value) {
44
+ this.fail([new error_1.FailedAssertionError(value)]);
45
+ }
46
+ }, (error) => {
47
+ this.fail([error]);
48
+ });
49
+ }
50
+ if (result !== undefined && !result) {
51
+ this.fail([new error_1.FailedAssertionError(result)]);
52
+ }
53
+ }
54
+ toString() {
55
+ return valueToString(this.value);
56
+ }
57
+ }
58
+ exports.PASSAssertion = PASSAssertion;
59
+ //# sourceMappingURL=pass.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pass.js","sourceRoot":"","sources":["../../src/assertion/pass.ts"],"names":[],"mappings":";;;AAAA,2CAAsC;AAEtC,oCAA8C;AAE9C,SAAgB,aAAa,CAAC,KAAqB;IACjD,IAAI,KAAK,YAAY,QAAQ,EAAE,CAAC;QAC9B,IAAI,IAAI,GAAG,KAAK,aAAL,KAAK,uBAAL,KAAK,CAAE,IAAI,CAAC;QACvB,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,OAAO,YAAY,CAAC;QACtB,CAAC;QACD,IAAI,IAAI,CAAC,MAAM,GAAG,EAAE,EAAE,CAAC;YACrB,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,KAAK,CAAC;QACnC,CAAC;QACD,OAAO,aAAa,IAAI,GAAG,CAAC;IAC9B,CAAC;IACD,IAAI,KAAK,YAAY,OAAO,EAAE,CAAC;QAC7B,OAAO,WAAW,CAAC;IACrB,CAAC;IACD,OAAO,IAAI,OAAO,KAAK,IAAI,MAAM,CAAC,KAAK,CAAC,GAAG,CAAA;AAC7C,CAAC;AAfD,sCAeC;AAED,MAAa,aAAc,SAAQ,qBAAS;IAC1C,YAAoB,KAAqB;QACvC,KAAK,CAAC,MAAM,EAAE,8BAA8B,CAAC,CAAC;QAD5B,UAAK,GAAL,KAAK,CAAgB;QAGvC,IAAI,KAAK,YAAY,qBAAS,EAAE,CAAC;YAC/B,OAAO,KAAsB,CAAC;QAChC,CAAC;IACH,CAAC;IAED,QAAQ;QACN,IAAI,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC;QACxB,IAAI,MAAM,YAAY,QAAQ,EAAE,CAAC;YAC/B,IAAI,CAAC;gBACH,MAAM,GAAG,MAAM,EAAE,CAAC;YACpB,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACX,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;YACjB,CAAC;QACH,CAAC;QACD,IAAI,MAAM,YAAY,OAAO,EAAE,CAAC;YAC9B,OAAO,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE;gBAC3B,IAAI,KAAK,KAAK,SAAS,IAAI,CAAC,KAAK,EAAE,CAAC;oBAClC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,4BAAoB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;gBAC/C,CAAC;YACH,CAAC,EAAE,CAAC,KAAK,EAAE,EAAE;gBACX,IAAI,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC;YACrB,CAAC,CAAC,CAAC;QACL,CAAC;QACD,IAAI,MAAM,KAAK,SAAS,IAAI,CAAC,MAAM,EAAE,CAAC;YACpC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,4BAAoB,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;QAChD,CAAC;IACH,CAAC;IAED,QAAQ;QACN,OAAO,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IACnC,CAAC;CACF;AAnCD,sCAmCC"}
@@ -0,0 +1,8 @@
1
+ import { AssertionValue } from "../types";
2
+ import { Assertion } from "./assertion";
3
+ export declare class UnaryAssertion extends Assertion {
4
+ protected readonly value: Assertion;
5
+ constructor(operator: string, expectation: string, value: AssertionValue | Assertion);
6
+ toString(): string;
7
+ evaluate(): void | Promise<void>;
8
+ }
@@ -0,0 +1,42 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UnaryAssertion = void 0;
4
+ const pass_1 = require("./pass");
5
+ const assertion_1 = require("./assertion");
6
+ class UnaryAssertion extends assertion_1.Assertion {
7
+ constructor(operator, expectation, value) {
8
+ super(operator, expectation);
9
+ if (value instanceof assertion_1.Assertion) {
10
+ this.value = value;
11
+ }
12
+ else {
13
+ this.value = new pass_1.PASSAssertion(value);
14
+ }
15
+ }
16
+ toString() {
17
+ return `${this.operator}(${this.value.toString()})`;
18
+ }
19
+ evaluate() {
20
+ let result;
21
+ let handled = false;
22
+ try {
23
+ result = this.value.evaluate();
24
+ }
25
+ catch (e) {
26
+ this.onEvaluation(e);
27
+ handled = true;
28
+ }
29
+ if (!handled) {
30
+ if (result instanceof Promise) {
31
+ return result.then(() => {
32
+ this.onEvaluation([true]);
33
+ }, (e) => {
34
+ this.onEvaluation([e]);
35
+ });
36
+ }
37
+ this.onEvaluation([true]);
38
+ }
39
+ }
40
+ }
41
+ exports.UnaryAssertion = UnaryAssertion;
42
+ //# sourceMappingURL=unary.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"unary.js","sourceRoot":"","sources":["../../src/assertion/unary.ts"],"names":[],"mappings":";;;AACA,iCAAqC;AACrC,2CAAsC;AAEtC,MAAa,cAAe,SAAQ,qBAAS;IAG3C,YAAY,QAAgB,EAAE,WAAmB,EAAE,KAAiC;QAClF,KAAK,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;QAE7B,IAAI,KAAK,YAAY,qBAAS,EAAE,CAAC;YAC/B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACrB,CAAC;aAAM,CAAC;YACN,IAAI,CAAC,KAAK,GAAG,IAAI,oBAAa,CAAC,KAAK,CAAC,CAAC;QACxC,CAAC;IACH,CAAC;IAED,QAAQ;QACN,OAAO,GAAG,IAAI,CAAC,QAAQ,IAAI,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,GAAG,CAAC;IACtD,CAAC;IAED,QAAQ;QACN,IAAI,MAA4B,CAAC;QACjC,IAAI,OAAO,GAAG,KAAK,CAAC;QACpB,IAAI,CAAC;YACH,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC;QACjC,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC;YACrB,OAAO,GAAG,IAAI,CAAC;QACjB,CAAC;QACD,IAAI,CAAC,OAAO,EAAE,CAAC;YACb,IAAI,MAAM,YAAY,OAAO,EAAE,CAAC;gBAC9B,OAAO,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE;oBACtB,IAAI,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;gBAC5B,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE;oBACP,IAAI,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;gBACzB,CAAC,CAAC,CAAC;YACL,CAAC;YACD,IAAI,CAAC,YAAY,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;QAC5B,CAAC;IACH,CAAC;CACF;AArCD,wCAqCC"}
@@ -0,0 +1,9 @@
1
+ import { AssertionValue } from "../types";
2
+ import { Assertion } from "./assertion";
3
+ export declare class VariadicAssertion extends Assertion {
4
+ protected readonly values: Assertion[];
5
+ constructor(operator: string, expectation: string, ...values: (AssertionValue | Assertion)[]);
6
+ append(...values: (AssertionValue | Assertion)[]): void;
7
+ evaluate(): void | Promise<void>;
8
+ toString(): string;
9
+ }
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VariadicAssertion = void 0;
4
+ const pass_1 = require("./pass");
5
+ const lines_builder_1 = require("lines-builder");
6
+ const assertion_1 = require("./assertion");
7
+ class VariadicAssertion extends assertion_1.Assertion {
8
+ constructor(operator, expectation, ...values) {
9
+ if (values.length < 1) {
10
+ throw new Error(`At least one value is required for ${operator} assertion.`);
11
+ }
12
+ super(operator, expectation);
13
+ this.values = [];
14
+ this.append(...values);
15
+ }
16
+ append(...values) {
17
+ this.values.push(...values.map((value) => {
18
+ if (value instanceof assertion_1.Assertion) {
19
+ return value;
20
+ }
21
+ return new pass_1.PASSAssertion(value);
22
+ }));
23
+ }
24
+ evaluate() {
25
+ const results = this.values.map((value) => {
26
+ try {
27
+ return value.evaluate();
28
+ }
29
+ catch (e) {
30
+ return e;
31
+ }
32
+ });
33
+ if (results.some((result) => result instanceof Promise)) {
34
+ return Promise.allSettled(results).then((settledResults) => {
35
+ this.onEvaluation(settledResults.map((settledResult) => {
36
+ if (settledResult.status === "fulfilled") {
37
+ return true;
38
+ }
39
+ return settledResult.reason;
40
+ }));
41
+ });
42
+ }
43
+ this.onEvaluation(results);
44
+ }
45
+ toString() {
46
+ return (0, lines_builder_1.lines)(this.operator + "(", (0, lines_builder_1.lines)(...this.values.map((value) => value.toString())), ")").toString();
47
+ }
48
+ }
49
+ exports.VariadicAssertion = VariadicAssertion;
50
+ //# sourceMappingURL=variadic.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"variadic.js","sourceRoot":"","sources":["../../src/assertion/variadic.ts"],"names":[],"mappings":";;;AACA,iCAAqC;AACrC,iDAAoC;AACpC,2CAAsC;AAEtC,MAAa,iBAAkB,SAAQ,qBAAS;IAG9C,YAAY,QAAgB,EAAE,WAAmB,EAAE,GAAG,MAAsC;QAC1F,IAAI,MAAM,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACtB,MAAM,IAAI,KAAK,CAAC,sCAAsC,QAAQ,aAAa,CAAC,CAAC;QAC/E,CAAC;QACD,KAAK,CAAC,QAAQ,EAAE,WAAW,CAAC,CAAC;QANZ,WAAM,GAAgB,EAAE,CAAC;QAO1C,IAAI,CAAC,MAAM,CAAC,GAAG,MAAM,CAAC,CAAC;IACzB,CAAC;IAED,MAAM,CAAC,GAAG,MAAsC;QAC9C,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;YACvC,IAAI,KAAK,YAAY,qBAAS,EAAE,CAAC;gBAC/B,OAAO,KAAK,CAAC;YACf,CAAC;YACD,OAAO,IAAI,oBAAa,CAAC,KAAK,CAAC,CAAC;QAClC,CAAC,CAAC,CAAC,CAAC;IACN,CAAC;IAED,QAAQ;QACN,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE;YACxC,IAAI,CAAC;gBACH,OAAO,KAAK,CAAC,QAAQ,EAAE,CAAC;YAC1B,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACX,OAAO,CAAC,CAAC;YACX,CAAC;QACH,CAAC,CAAC,CAAC;QACH,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,YAAY,OAAO,CAAC,EAAE,CAAC;YACxD,OAAO,OAAO,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,cAAc,EAAE,EAAE;gBACzD,IAAI,CAAC,YAAY,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC,aAAa,EAAE,EAAE;oBACrD,IAAI,aAAa,CAAC,MAAM,KAAK,WAAW,EAAE,CAAC;wBACzC,OAAO,IAAI,CAAC;oBACd,CAAC;oBACD,OAAO,aAAa,CAAC,MAAM,CAAC;gBAC9B,CAAC,CAAC,CAAC,CAAC;YACN,CAAC,CAAC,CAAC;QACL,CAAC;QACD,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;IAC7B,CAAC;IAED,QAAQ;QACN,OAAO,IAAA,qBAAK,EACV,IAAI,CAAC,QAAQ,GAAG,GAAG,EACnB,IAAA,qBAAK,EACH,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAChD,EACD,GAAG,CACJ,CAAC,QAAQ,EAAE,CAAC;IACf,CAAC;CACF;AAlDD,8CAkDC"}
@@ -0,0 +1,7 @@
1
+ import { Assertion } from "./assertion";
2
+ import type { AssertionValue, EvaluationResult } from "../types";
3
+ import { VariadicAssertion } from "./variadic";
4
+ export declare class XNORAssertion extends VariadicAssertion {
5
+ constructor(...values: (AssertionValue | Assertion)[]);
6
+ onEvaluation(results: EvaluationResult[]): void | Promise<void>;
7
+ }
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.XNORAssertion = void 0;
4
+ const variadic_1 = require("./variadic");
5
+ class XNORAssertion extends variadic_1.VariadicAssertion {
6
+ constructor(...values) {
7
+ super("XNOR", "Expected all expressions to have the same state (pass or fail), but there are few outliers.", ...values);
8
+ }
9
+ onEvaluation(results) {
10
+ const failed = results.filter((result) => result instanceof Error);
11
+ if (failed.length !== 0 && failed.length !== results.length) {
12
+ this.fail(results);
13
+ }
14
+ }
15
+ }
16
+ exports.XNORAssertion = XNORAssertion;
17
+ //# sourceMappingURL=xnor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xnor.js","sourceRoot":"","sources":["../../src/assertion/xnor.ts"],"names":[],"mappings":";;;AAEA,yCAA6C;AAE7C,MAAa,aAAc,SAAQ,4BAAiB;IAClD,YAAY,GAAG,MAAsC;QACnD,KAAK,CAAC,MAAM,EAAE,6FAA6F,EAAE,GAAG,MAAM,CAAC,CAAC;IAC1H,CAAC;IAED,YAAY,CAAC,OAA2B;QACtC,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,YAAY,KAAK,CAAC,CAAC;QACnE,IAAI,MAAM,CAAC,MAAM,KAAK,CAAC,IAAI,MAAM,CAAC,MAAM,KAAK,OAAO,CAAC,MAAM,EAAE,CAAC;YAC5D,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACrB,CAAC;IACH,CAAC;CACF;AAXD,sCAWC"}
@@ -0,0 +1,7 @@
1
+ import { Assertion } from "./assertion";
2
+ import type { AssertionValue, EvaluationResult } from "../types";
3
+ import { VariadicAssertion } from "./variadic";
4
+ export declare class XORAssertion extends VariadicAssertion {
5
+ constructor(...values: (AssertionValue | Assertion)[]);
6
+ onEvaluation(results: EvaluationResult[]): void | Promise<void>;
7
+ }
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.XORAssertion = void 0;
4
+ const variadic_1 = require("./variadic");
5
+ class XORAssertion extends variadic_1.VariadicAssertion {
6
+ constructor(...values) {
7
+ super("XOR", "Expected odd number of expressions to pass, but even number did.", ...values);
8
+ }
9
+ onEvaluation(results) {
10
+ const failed = results.filter((result) => result instanceof Error);
11
+ const nPassed = results.length - failed.length;
12
+ if (nPassed % 2 === 0) {
13
+ this.fail(results);
14
+ }
15
+ }
16
+ }
17
+ exports.XORAssertion = XORAssertion;
18
+ //# sourceMappingURL=xor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"xor.js","sourceRoot":"","sources":["../../src/assertion/xor.ts"],"names":[],"mappings":";;;AAEA,yCAA6C;AAE7C,MAAa,YAAa,SAAQ,4BAAiB;IACjD,YAAY,GAAG,MAAsC;QACnD,KAAK,CAAC,KAAK,EAAE,kEAAkE,EAAE,GAAG,MAAM,CAAC,CAAC;IAC9F,CAAC;IAED,YAAY,CAAC,OAA2B;QACtC,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,MAAM,YAAY,KAAK,CAAC,CAAC;QACnE,MAAM,OAAO,GAAG,OAAO,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QAC/C,IAAI,OAAO,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;YACtB,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACrB,CAAC;IACH,CAAC;CACF;AAZD,oCAYC"}
package/error.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ import { Assertion } from "./assertion/assertion";
2
+ import { AnyValue, EvaluationResult } from "./types";
3
+ export declare class AssertionError extends Error {
4
+ readonly operator: string;
5
+ readonly expectation: string;
6
+ readonly assertion: Assertion;
7
+ readonly results?: EvaluationResult[];
8
+ constructor(operator: string, expectation: string, assertion: Assertion, results?: EvaluationResult[]);
9
+ }
10
+ export declare class FailedAssertionError extends Error {
11
+ constructor(value: AnyValue);
12
+ }
package/error.js ADDED
@@ -0,0 +1,53 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FailedAssertionError = exports.AssertionError = void 0;
4
+ const yaml_1 = require("yaml");
5
+ const pass_1 = require("./assertion/pass");
6
+ function getErrorRepresentation(operator, expectation, assertion, results) {
7
+ const repr = {
8
+ [`AssertionError (${operator})`]: expectation,
9
+ };
10
+ if ((results === null || results === void 0 ? void 0 : results.length) > 0) {
11
+ repr.Results = results.map((result) => {
12
+ if (result instanceof AssertionError) {
13
+ return getErrorRepresentation(result.operator, result.expectation, result.assertion, result.results);
14
+ }
15
+ if (result instanceof Error) {
16
+ return {
17
+ // eslint-disable-next-line no-control-regex
18
+ Error: result.message.replace(/\u001b\[\d+m/g, ''),
19
+ };
20
+ }
21
+ return "Pass";
22
+ });
23
+ }
24
+ repr.Expression = assertion.toString();
25
+ return repr;
26
+ }
27
+ class AssertionError extends Error {
28
+ constructor(operator, expectation, assertion, results) {
29
+ super((0, yaml_1.stringify)(getErrorRepresentation(operator, expectation, assertion, results), {
30
+ indent: 2,
31
+ // defaultStringType: "PLAIN",
32
+ // defaultKeyType: "PLAIN",
33
+ collectionStyle: 'block',
34
+ // lineWidth: 0,
35
+ // blockQuote: true,
36
+ doubleQuotedMinMultiLineLength: Infinity,
37
+ }));
38
+ this.operator = operator;
39
+ this.expectation = expectation;
40
+ this.assertion = assertion;
41
+ this.results = results;
42
+ this.name = "AssertionError";
43
+ }
44
+ }
45
+ exports.AssertionError = AssertionError;
46
+ class FailedAssertionError extends Error {
47
+ constructor(value) {
48
+ super(`Failed expression: ${(0, pass_1.valueToString)(value)}`);
49
+ this.name = "FailedAssertionError";
50
+ }
51
+ }
52
+ exports.FailedAssertionError = FailedAssertionError;
53
+ //# sourceMappingURL=error.js.map
package/error.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.js","sourceRoot":"","sources":["../src/error.ts"],"names":[],"mappings":";;;AACA,+BAA+B;AAE/B,2CAA+C;AAI/C,SAAS,sBAAsB,CAAC,QAAgB,EAAE,WAAmB,EAAE,SAAoB,EAAE,OAA4B;IACvH,MAAM,IAAI,GAAc;QACtB,CAAC,mBAAmB,QAAQ,GAAG,CAAC,EAAE,WAAW;KAC9C,CAAC;IACF,IAAI,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,MAAM,IAAG,CAAC,EAAE,CAAC;QACxB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,MAAM,EAAE,EAAE;YACpC,IAAI,MAAM,YAAY,cAAc,EAAE,CAAC;gBACrC,OAAO,sBAAsB,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,SAAS,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;YACvG,CAAC;YACD,IAAI,MAAM,YAAY,KAAK,EAAE,CAAC;gBAC5B,OAAO;oBACL,4CAA4C;oBAC5C,KAAK,EAAE,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,eAAe,EAAE,EAAE,CAAC;iBACnD,CAAC;YACJ,CAAC;YACD,OAAO,MAAM,CAAC;QAChB,CAAC,CAAC,CAAC;IACL,CAAC;IACD,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC,QAAQ,EAAE,CAAC;IACvC,OAAO,IAAI,CAAC;AACd,CAAC;AAED,MAAa,cAAe,SAAQ,KAAK;IACvC,YACkB,QAAgB,EAChB,WAAmB,EACnB,SAAoB,EACpB,OAA4B;QAE5C,KAAK,CAAC,IAAA,gBAAS,EACb,sBAAsB,CAAC,QAAQ,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,CAAC,EACjE;YACE,MAAM,EAAE,CAAC;YACT,8BAA8B;YAC9B,2BAA2B;YAC3B,eAAe,EAAE,OAAO;YACxB,gBAAgB;YAChB,oBAAoB;YACpB,8BAA8B,EAAE,QAAQ;SACzC,CACF,CAAC,CAAC;QAhBa,aAAQ,GAAR,QAAQ,CAAQ;QAChB,gBAAW,GAAX,WAAW,CAAQ;QACnB,cAAS,GAAT,SAAS,CAAW;QACpB,YAAO,GAAP,OAAO,CAAqB;QAc5C,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;IAC/B,CAAC;CACF;AArBD,wCAqBC;AAED,MAAa,oBAAqB,SAAQ,KAAK;IAC7C,YAAY,KAAe;QACzB,KAAK,CAAC,sBAAsB,IAAA,oBAAa,EAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACpD,IAAI,CAAC,IAAI,GAAG,sBAAsB,CAAC;IACrC,CAAC;CACF;AALD,oDAKC"}
package/index.d.ts ADDED
@@ -0,0 +1,17 @@
1
+ import type { AssertionValue } from "./types";
2
+ import { PASSAssertion } from "./assertion/pass";
3
+ import { NOTAssertion } from "./assertion/not";
4
+ import { ORAssertion } from "./assertion/or";
5
+ import { ANDAssertion } from "./assertion/and";
6
+ import { XORAssertion } from "./assertion/xor";
7
+ import { NORAssertion } from "./assertion/nor";
8
+ import { NANDAssertion } from "./assertion/nand";
9
+ import { XNORAssertion } from "./assertion/xnor";
10
+ export declare const pass: (value: AssertionValue) => PASSAssertion;
11
+ export declare const not: (value: AssertionValue) => NOTAssertion;
12
+ export declare const or: (...values: AssertionValue[]) => ORAssertion;
13
+ export declare const and: (...values: AssertionValue[]) => ANDAssertion;
14
+ export declare const nor: (...values: AssertionValue[]) => NORAssertion;
15
+ export declare const nand: (...values: AssertionValue[]) => NANDAssertion;
16
+ export declare const xor: (...values: AssertionValue[]) => XORAssertion;
17
+ export declare const xnor: (...values: AssertionValue[]) => XNORAssertion;
package/index.js ADDED
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ // import debug = require("debug");
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.xnor = exports.xor = exports.nand = exports.nor = exports.and = exports.or = exports.not = exports.pass = void 0;
5
+ const pass_1 = require("./assertion/pass");
6
+ const not_1 = require("./assertion/not");
7
+ const or_1 = require("./assertion/or");
8
+ const and_1 = require("./assertion/and");
9
+ const xor_1 = require("./assertion/xor");
10
+ const nor_1 = require("./assertion/nor");
11
+ const nand_1 = require("./assertion/nand");
12
+ const xnor_1 = require("./assertion/xnor");
13
+ const lines_builder_1 = require("lines-builder");
14
+ (0, lines_builder_1.setDefaultOptions)({
15
+ // Need to force EOL to be Unix style, because Windows style is not supported by YAML
16
+ eol: "\n",
17
+ trimLeft: false,
18
+ skipFirstLevelIndent: true,
19
+ indent: 2
20
+ });
21
+ const pass = (value) => new pass_1.PASSAssertion(value);
22
+ exports.pass = pass;
23
+ const not = (value) => new not_1.NOTAssertion(value);
24
+ exports.not = not;
25
+ const or = (...values) => new or_1.ORAssertion(...values);
26
+ exports.or = or;
27
+ const and = (...values) => new and_1.ANDAssertion(...values);
28
+ exports.and = and;
29
+ const nor = (...values) => new nor_1.NORAssertion(...values);
30
+ exports.nor = nor;
31
+ const nand = (...values) => new nand_1.NANDAssertion(...values);
32
+ exports.nand = nand;
33
+ const xor = (...values) => new xor_1.XORAssertion(...values);
34
+ exports.xor = xor;
35
+ const xnor = (...values) => new xnor_1.XNORAssertion(...values);
36
+ exports.xnor = xnor;
37
+ //# sourceMappingURL=index.js.map
package/index.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,mCAAmC;;;AAKnC,2CAA+C;AAC/C,yCAA6C;AAC7C,uCAA2C;AAC3C,yCAA6C;AAC7C,yCAA6C;AAC7C,yCAA6C;AAC7C,2CAA+C;AAC/C,2CAA+C;AAE/C,iDAAgD;AAEhD,IAAA,iCAAiB,EAAC;IAChB,qFAAqF;IACrF,GAAG,EAAE,IAAI;IACT,QAAQ,EAAE,KAAK;IACf,oBAAoB,EAAE,IAAI;IAC1B,MAAM,EAAE,CAAC;CACV,CAAC,CAAC;AAEI,MAAM,IAAI,GAAG,CAAC,KAAqB,EAAE,EAAE,CAAC,IAAI,oBAAa,CAAC,KAAK,CAAC,CAAC;AAA3D,QAAA,IAAI,QAAuD;AACjE,MAAM,GAAG,GAAG,CAAC,KAAqB,EAAE,EAAE,CAAC,IAAI,kBAAY,CAAC,KAAK,CAAC,CAAC;AAAzD,QAAA,GAAG,OAAsD;AAC/D,MAAM,EAAE,GAAG,CAAC,GAAG,MAAwB,EAAE,EAAE,CAAC,IAAI,gBAAW,CAAC,GAAG,MAAM,CAAC,CAAC;AAAjE,QAAA,EAAE,MAA+D;AACvE,MAAM,GAAG,GAAG,CAAC,GAAG,MAAwB,EAAE,EAAE,CAAC,IAAI,kBAAY,CAAC,GAAG,MAAM,CAAC,CAAC;AAAnE,QAAA,GAAG,OAAgE;AACzE,MAAM,GAAG,GAAG,CAAC,GAAG,MAAwB,EAAE,EAAE,CAAC,IAAI,kBAAY,CAAC,GAAG,MAAM,CAAC,CAAC;AAAnE,QAAA,GAAG,OAAgE;AACzE,MAAM,IAAI,GAAG,CAAC,GAAG,MAAwB,EAAE,EAAE,CAAC,IAAI,oBAAa,CAAC,GAAG,MAAM,CAAC,CAAC;AAArE,QAAA,IAAI,QAAiE;AAC3E,MAAM,GAAG,GAAG,CAAC,GAAG,MAAwB,EAAE,EAAE,CAAC,IAAI,kBAAY,CAAC,GAAG,MAAM,CAAC,CAAC;AAAnE,QAAA,GAAG,OAAgE;AACzE,MAAM,IAAI,GAAG,CAAC,GAAG,MAAwB,EAAE,EAAE,CAAC,IAAI,oBAAa,CAAC,GAAG,MAAM,CAAC,CAAC;AAArE,QAAA,IAAI,QAAiE"}
package/package.json ADDED
@@ -0,0 +1,96 @@
1
+ {
2
+ "name": "assert-logic",
3
+ "version": "1.0.0",
4
+ "description": "This repository/project is a template/placeholder for new NPM packages.",
5
+ "main": "index.js",
6
+ "types": "index.d.ts",
7
+ "scripts": {
8
+ "build": "npm run buildUpdate && npm test && npm run typedoc",
9
+ "buildUpdate": "npm run clean && npm run compile && npm run copyToDist",
10
+ "copyToDist": "copyfiles -f *.txt *.md package.json dist",
11
+ "typedoc": "typedoc --out ./docs ./src && touch ./docs/.nojekyll",
12
+ "clean": "rimraf ./dist ./docs ./reports ./coverage",
13
+ "test": "dotenv-ng --var JEST_JUNIT_OUTPUT_DIR=./reports -- jest --coverage -u",
14
+ "lint": "eslint . --ext .ts --fix",
15
+ "compile": "tsc && npm run lint"
16
+ },
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/szikszail/assert-logic.git"
20
+ },
21
+ "keywords": [],
22
+ "author": "Laszlo Szikszai <sziklaszlo@gmail.com>",
23
+ "license": "MIT",
24
+ "files": [
25
+ "**/*.js",
26
+ "**/*.d.ts",
27
+ "**/*.js.map"
28
+ ],
29
+ "engines": {
30
+ "node": ">=12.0.0"
31
+ },
32
+ "bugs": {
33
+ "url": "https://github.com/szikszail/assert-logic/issues"
34
+ },
35
+ "homepage": "https://github.com/szikszail/assert-logic#readme",
36
+ "devDependencies": {
37
+ "@types/chai": "^4.2.21",
38
+ "@types/debug": "^4.1.12",
39
+ "@types/jest": "^29.5.12",
40
+ "@types/js-yaml": "^4.0.9",
41
+ "@types/node": "^20.11.20",
42
+ "@typescript-eslint/eslint-plugin": "^7.0.2",
43
+ "@typescript-eslint/parser": "^7.0.2",
44
+ "chai": "^4.3.4",
45
+ "copyfiles": "^2.4.1",
46
+ "dotenv-ng": "^1.3.0",
47
+ "eslint": "^8.57.0",
48
+ "jest": "^29.7.0",
49
+ "jest-junit": "^16.0.0",
50
+ "rimraf": "^5.0.5",
51
+ "ts-jest": "^29.1.2",
52
+ "typedoc": "^0.25.9",
53
+ "typescript": "^5.3.3"
54
+ },
55
+ "dependencies": {
56
+ "debug": "^4.3.4",
57
+ "lines-builder": "^1.5.1",
58
+ "yaml": "^2.4.0"
59
+ },
60
+ "jest": {
61
+ "reporters": [
62
+ "default",
63
+ "jest-junit"
64
+ ],
65
+ "transform": {
66
+ "^.+\\.ts?$": "ts-jest"
67
+ },
68
+ "testEnvironment": "node",
69
+ "testMatch": [
70
+ "**/tests/**/*.test.ts"
71
+ ],
72
+ "testPathIgnorePatterns": [
73
+ "/node_modules/",
74
+ "dist"
75
+ ],
76
+ "setupFilesAfterEnv": [
77
+ "./tests/setup/areStringsMatch.ts"
78
+ ],
79
+ "coverageDirectory": "./coverage",
80
+ "collectCoverageFrom": [
81
+ "./src/**/*.ts"
82
+ ],
83
+ "moduleFileExtensions": [
84
+ "ts",
85
+ "js"
86
+ ],
87
+ "coverageThreshold": {
88
+ "global": {
89
+ "branches": 85,
90
+ "functions": 85,
91
+ "lines": 85,
92
+ "statements": 85
93
+ }
94
+ }
95
+ }
96
+ }