@elaraai/east-node-std 0.0.1-beta.0 → 0.0.1-beta.10
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 +29 -2
- package/dist/console.d.ts +7 -7
- package/dist/console.d.ts.map +1 -1
- package/dist/console.js.map +1 -1
- package/dist/crypto.d.ts +9 -9
- package/dist/crypto.d.ts.map +1 -1
- package/dist/crypto.js.map +1 -1
- package/dist/fetch.d.ts +26 -7
- package/dist/fetch.d.ts.map +1 -1
- package/dist/fetch.js +8 -8
- package/dist/fetch.js.map +1 -1
- package/dist/fs.d.ts +23 -23
- package/dist/fs.d.ts.map +1 -1
- package/dist/fs.js +2 -1
- package/dist/fs.js.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/path.d.ts +11 -11
- package/dist/path.d.ts.map +1 -1
- package/dist/path.js.map +1 -1
- package/dist/platform.d.ts +15 -0
- package/dist/platform.d.ts.map +1 -0
- package/dist/platform.js +15 -0
- package/dist/platform.js.map +1 -0
- package/dist/random.d.ts +29 -29
- package/dist/random.d.ts.map +1 -1
- package/dist/random.js.map +1 -1
- package/dist/test.d.ts +44 -124
- package/dist/test.d.ts.map +1 -1
- package/dist/test.js +611 -190
- package/dist/test.js.map +1 -1
- package/dist/time.d.ts +5 -5
- package/dist/time.d.ts.map +1 -1
- package/dist/time.js +2 -2
- package/dist/time.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +12 -8
package/dist/test.d.ts
CHANGED
|
@@ -1,40 +1,11 @@
|
|
|
1
|
-
import { Expr, NullType, StringType,
|
|
2
|
-
import type { PlatformFunction,
|
|
1
|
+
import { Expr, NullType, StringType, type SubtypeExprOrValue } from "@elaraai/east";
|
|
2
|
+
import type { BlockBuilder, PlatformFunction, TypeSymbol } from "@elaraai/east/internal";
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
4
|
+
* Creates a test platform that uses Node.js assertions.
|
|
5
5
|
*
|
|
6
|
-
*
|
|
7
|
-
* successful validation. When executed in Node.js, it performs no action (the test
|
|
8
|
-
* continues normally). Other platform implementations may log or track passes.
|
|
9
|
-
*
|
|
10
|
-
* This function is primarily used within the {@link Test} assertion helpers rather
|
|
11
|
-
* than being called directly in test code.
|
|
12
|
-
*
|
|
13
|
-
* @returns `null` - Has no meaningful return value
|
|
14
|
-
*
|
|
15
|
-
* @example
|
|
16
|
-
* ```ts
|
|
17
|
-
* import { East, NullType } from "@elaraai/east";
|
|
18
|
-
* import { Test } from "@elaraai/east-node-std";
|
|
19
|
-
*
|
|
20
|
-
* // Used internally by Test assertions
|
|
21
|
-
* const myTest = East.function([], NullType, $ => {
|
|
22
|
-
* // Test.equal internally calls testPass when the assertion succeeds
|
|
23
|
-
* $(Test.equal(East.value(42n), 42n));
|
|
24
|
-
* });
|
|
25
|
-
*
|
|
26
|
-
* const compiled = East.compile(myTest.toIR(), Test.Implementation);
|
|
27
|
-
* compiled(); // Test passes silently
|
|
28
|
-
* ```
|
|
29
|
-
*
|
|
30
|
-
* @remarks
|
|
31
|
-
* - Does not throw or produce output in Node.js implementation
|
|
32
|
-
* - Used by all {@link Test} assertion methods to signal success
|
|
33
|
-
* - Can be called directly for custom assertion logic
|
|
6
|
+
* @returns A platform object with `testPass`, `testFail`, `test`, and `describe` functions
|
|
34
7
|
*/
|
|
35
|
-
export declare const
|
|
36
|
-
export declare const NodeTestTypes: any[];
|
|
37
|
-
export declare const NodeTest: PlatformFunction[];
|
|
8
|
+
export declare const TestImpl: PlatformFunction[];
|
|
38
9
|
/**
|
|
39
10
|
* Configuration options for East test suites.
|
|
40
11
|
*/
|
|
@@ -63,111 +34,53 @@ export interface DescribeEastOptions {
|
|
|
63
34
|
* Runs even if the test fails.
|
|
64
35
|
*/
|
|
65
36
|
afterEach?: ($: BlockBuilder<NullType>) => void;
|
|
37
|
+
/**
|
|
38
|
+
* If true (and if process.env.EXPORT_TEST_IR is a valid path), only exports the test IR without running the tests.
|
|
39
|
+
* Useful for generating test IR for other East implementations.
|
|
40
|
+
* Defaults to false.
|
|
41
|
+
* @default false
|
|
42
|
+
*/
|
|
43
|
+
exportOnly?: boolean;
|
|
66
44
|
}
|
|
67
45
|
/**
|
|
68
|
-
*
|
|
46
|
+
* Defines and runs an East test suite using platform functions.
|
|
69
47
|
*
|
|
70
|
-
* This
|
|
71
|
-
*
|
|
72
|
-
*
|
|
48
|
+
* This creates a single East function that calls `describe` and `test` platform functions.
|
|
49
|
+
* The entire suite can be exported as IR and run on any East implementation that provides
|
|
50
|
+
* the test platform (testPass, testFail, test, describe).
|
|
73
51
|
*
|
|
74
|
-
*
|
|
75
|
-
*
|
|
52
|
+
* When the `EXPORT_TEST_IR` environment variable is set to a directory path, the IR for
|
|
53
|
+
* each test suite is exported to `<path>/<suite_name>.json`.
|
|
76
54
|
*
|
|
77
55
|
* @param suiteName - The name of the test suite
|
|
78
56
|
* @param builder - A function that receives a `test` function for defining tests
|
|
79
|
-
* @param options - Configuration options including platform functions and lifecycle hooks
|
|
80
57
|
*
|
|
81
58
|
* @example
|
|
82
59
|
* ```ts
|
|
83
|
-
* // Basic usage with platform functions
|
|
84
60
|
* describeEast("Array tests", (test) => {
|
|
85
61
|
* test("addition", $ => {
|
|
86
|
-
* $(
|
|
62
|
+
* $(assertEast.equal(East.value(1n).add(1n), 2n));
|
|
87
63
|
* });
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
* @example
|
|
92
|
-
* ```ts
|
|
93
|
-
* // With database cleanup hooks
|
|
94
|
-
* import { SQL } from "@elaraai/east-node-io";
|
|
95
|
-
*
|
|
96
|
-
* describeEast("Database tests", (test) => {
|
|
97
|
-
* test("query users", $ => {
|
|
98
|
-
* const conn = $.let(SQL.Postgres.connect(config));
|
|
99
|
-
* const result = $.let(SQL.Postgres.query(conn, "SELECT * FROM users", []));
|
|
100
|
-
* $(Test.equal(result.rows.length(), 2n));
|
|
64
|
+
* test("subtraction", $ => {
|
|
65
|
+
* $(assertEast.equal(East.value(2n).subtract(1n), 1n));
|
|
101
66
|
* });
|
|
102
|
-
* }, {
|
|
103
|
-
* platformFns: SQL.Postgres.Implementation,
|
|
104
|
-
* afterEach: $ => {
|
|
105
|
-
* // Close connections even if test fails
|
|
106
|
-
* const conn = $.let(SQL.Postgres.connect(config));
|
|
107
|
-
* $(SQL.Postgres.close(conn));
|
|
108
|
-
* }
|
|
109
67
|
* });
|
|
110
68
|
* ```
|
|
111
|
-
*/
|
|
112
|
-
export declare function describeEast(suiteName: string, builder: (test: (name: string, body: ($: BlockBuilder<NullType>) => void) => void) => void, options?: DescribeEastOptions): void;
|
|
113
|
-
/**
|
|
114
|
-
* East assertion functions that match Node.js assert API naming.
|
|
115
69
|
*
|
|
116
|
-
*
|
|
117
|
-
*
|
|
70
|
+
* @example
|
|
71
|
+
* ```bash
|
|
72
|
+
* # Export test IR to a directory
|
|
73
|
+
* EXPORT_TEST_IR=./test-ir npm test
|
|
74
|
+
* ```
|
|
118
75
|
*/
|
|
76
|
+
export declare function describeEast(suiteName: string, builder: (test: (name: string, body: ($: BlockBuilder<NullType>) => void) => void) => void, options?: DescribeEastOptions): Promise<null> | undefined;
|
|
119
77
|
/**
|
|
120
78
|
* East assertion functions that match Node.js assert API naming.
|
|
121
79
|
*
|
|
122
80
|
* These functions generate East expressions that perform runtime assertions
|
|
123
81
|
* using platform functions, enabling testing of East code.
|
|
124
82
|
*/
|
|
125
|
-
export declare const
|
|
126
|
-
/**
|
|
127
|
-
* Platform function that signals a test assertion passed.
|
|
128
|
-
*
|
|
129
|
-
* Used internally by assertion methods to indicate successful validation.
|
|
130
|
-
* Does nothing in Node.js implementation - test continues normally.
|
|
131
|
-
*
|
|
132
|
-
* @returns An East expression that returns `null`
|
|
133
|
-
*
|
|
134
|
-
* @example
|
|
135
|
-
* ```ts
|
|
136
|
-
* import { East, NullType } from "@elaraai/east";
|
|
137
|
-
* import { Test } from "@elaraai/east-node-std";
|
|
138
|
-
*
|
|
139
|
-
* const customAssertion = East.function([], NullType, $ => {
|
|
140
|
-
* return East.value(true).ifElse(
|
|
141
|
-
* _ => Test.pass(),
|
|
142
|
-
* _ => Test.fail("Condition was false")
|
|
143
|
-
* );
|
|
144
|
-
* });
|
|
145
|
-
* ```
|
|
146
|
-
*/
|
|
147
|
-
pass: PlatformFunctionDef<[], NullType>;
|
|
148
|
-
/**
|
|
149
|
-
* Platform function that signals a test assertion failed.
|
|
150
|
-
*
|
|
151
|
-
* Used internally by assertion methods to indicate validation failures.
|
|
152
|
-
* Throws an assertion error in Node.js implementation - test fails immediately.
|
|
153
|
-
*
|
|
154
|
-
* @param message - Error message describing the failure
|
|
155
|
-
* @returns An East expression that returns `null` (never actually returns - throws)
|
|
156
|
-
*
|
|
157
|
-
* @example
|
|
158
|
-
* ```ts
|
|
159
|
-
* import { East, StringType, NullType } from "@elaraai/east";
|
|
160
|
-
* import { Test } from "@elaraai/east-node-std";
|
|
161
|
-
*
|
|
162
|
-
* const validateRange = East.function([IntegerType], NullType, ($, value) => {
|
|
163
|
-
* return value.between(0n, 100n).ifElse(
|
|
164
|
-
* _ => Test.pass(),
|
|
165
|
-
* _ => Test.fail("Value must be between 0 and 100")
|
|
166
|
-
* );
|
|
167
|
-
* });
|
|
168
|
-
* ```
|
|
169
|
-
*/
|
|
170
|
-
fail: PlatformFunctionDef<[StringType], NullType>;
|
|
83
|
+
export declare const Assert: {
|
|
171
84
|
/**
|
|
172
85
|
* Asserts that two values are the same reference (meaning if one is mutated, the other reflects the change - and they are always equal).
|
|
173
86
|
*
|
|
@@ -176,7 +89,7 @@ export declare const Test: {
|
|
|
176
89
|
* @param expected - The expected value to compare against
|
|
177
90
|
* @returns An East expression that performs the equality check
|
|
178
91
|
*/
|
|
179
|
-
is<E extends
|
|
92
|
+
is<E extends Expr>(actual: E, expected: SubtypeExprOrValue<NoInfer<E>[TypeSymbol]>): import("@elaraai/east").NullExpr;
|
|
180
93
|
/**
|
|
181
94
|
* Asserts that two values are equal.
|
|
182
95
|
*
|
|
@@ -185,7 +98,7 @@ export declare const Test: {
|
|
|
185
98
|
* @param expected - The expected value to compare against
|
|
186
99
|
* @returns An East expression that performs the equality check
|
|
187
100
|
*/
|
|
188
|
-
equal<E extends
|
|
101
|
+
equal<E extends Expr>(actual: E, expected: SubtypeExprOrValue<NoInfer<E>[TypeSymbol]>): import("@elaraai/east").NullExpr;
|
|
189
102
|
/**
|
|
190
103
|
* Asserts that two values are not equal.
|
|
191
104
|
*
|
|
@@ -194,7 +107,7 @@ export declare const Test: {
|
|
|
194
107
|
* @param expected - The value that should not be equal
|
|
195
108
|
* @returns An East expression that performs the inequality check
|
|
196
109
|
*/
|
|
197
|
-
notEqual<E extends
|
|
110
|
+
notEqual<E extends Expr>(actual: E, expected: SubtypeExprOrValue<NoInfer<E>[TypeSymbol]>): import("@elaraai/east").NullExpr;
|
|
198
111
|
/**
|
|
199
112
|
* Asserts that actual is less than expected.
|
|
200
113
|
*
|
|
@@ -203,7 +116,7 @@ export declare const Test: {
|
|
|
203
116
|
* @param expected - The value that actual should be less than
|
|
204
117
|
* @returns An East expression that performs the less-than check
|
|
205
118
|
*/
|
|
206
|
-
less<E extends
|
|
119
|
+
less<E extends Expr>(actual: E, expected: SubtypeExprOrValue<NoInfer<E>[TypeSymbol]>): import("@elaraai/east").NullExpr;
|
|
207
120
|
/**
|
|
208
121
|
* Asserts that actual is less than or equal to expected.
|
|
209
122
|
*
|
|
@@ -212,7 +125,7 @@ export declare const Test: {
|
|
|
212
125
|
* @param expected - The value that actual should be less than or equal to
|
|
213
126
|
* @returns An East expression that performs the less-than-or-equal check
|
|
214
127
|
*/
|
|
215
|
-
lessEqual<E extends
|
|
128
|
+
lessEqual<E extends Expr>(actual: E, expected: SubtypeExprOrValue<NoInfer<E>[TypeSymbol]>): import("@elaraai/east").NullExpr;
|
|
216
129
|
/**
|
|
217
130
|
* Asserts that actual is greater than expected.
|
|
218
131
|
*
|
|
@@ -221,7 +134,7 @@ export declare const Test: {
|
|
|
221
134
|
* @param expected - The value that actual should be greater than
|
|
222
135
|
* @returns An East expression that performs the greater-than check
|
|
223
136
|
*/
|
|
224
|
-
greater<E extends
|
|
137
|
+
greater<E extends Expr>(actual: E, expected: SubtypeExprOrValue<NoInfer<E>[TypeSymbol]>): import("@elaraai/east").NullExpr;
|
|
225
138
|
/**
|
|
226
139
|
* Asserts that actual is greater than or equal to expected.
|
|
227
140
|
*
|
|
@@ -230,7 +143,7 @@ export declare const Test: {
|
|
|
230
143
|
* @param expected - The value that actual should be greater than or equal to
|
|
231
144
|
* @returns An East expression that performs the greater-than-or-equal check
|
|
232
145
|
*/
|
|
233
|
-
greaterEqual<E extends
|
|
146
|
+
greaterEqual<E extends Expr>(actual: E, expected: SubtypeExprOrValue<NoInfer<E>[TypeSymbol]>): import("@elaraai/east").NullExpr;
|
|
234
147
|
/**
|
|
235
148
|
* Asserts that actual is between min and max (inclusive).
|
|
236
149
|
*
|
|
@@ -240,7 +153,7 @@ export declare const Test: {
|
|
|
240
153
|
* @param max - The maximum value (inclusive)
|
|
241
154
|
* @returns An East expression that performs the range check
|
|
242
155
|
*/
|
|
243
|
-
between<E extends
|
|
156
|
+
between<E extends Expr>(actual: E, min: SubtypeExprOrValue<NoInfer<E>[TypeSymbol]>, max: SubtypeExprOrValue<NoInfer<E>[TypeSymbol]>): import("@elaraai/east").NullExpr;
|
|
244
157
|
/**
|
|
245
158
|
* Asserts that an expression throws an error.
|
|
246
159
|
*
|
|
@@ -248,6 +161,13 @@ export declare const Test: {
|
|
|
248
161
|
* @param pattern - Optional regex pattern to match against the error message
|
|
249
162
|
* @returns An East expression that verifies an error is thrown
|
|
250
163
|
*/
|
|
251
|
-
throws(fn: Expr<any>, pattern?: RegExp):
|
|
164
|
+
throws(fn: Expr<any>, pattern?: RegExp): import("@elaraai/east").NullExpr;
|
|
165
|
+
/**
|
|
166
|
+
* Fails a test with the given message.
|
|
167
|
+
*
|
|
168
|
+
* @param message
|
|
169
|
+
* @returns An East expression that unconditionally fails the test
|
|
170
|
+
*/
|
|
171
|
+
fail(message: SubtypeExprOrValue<StringType>): import("@elaraai/east").NullExpr;
|
|
252
172
|
};
|
|
253
173
|
//# sourceMappingURL=test.d.ts.map
|
package/dist/test.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test.d.ts","sourceRoot":"","sources":["../src/test.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"test.d.ts","sourceRoot":"","sources":["../src/test.ts"],"names":[],"mappings":"AASA,OAAO,EAA2B,IAAI,EAAwB,QAAQ,EAAE,UAAU,EAAa,KAAK,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAC9I,OAAO,KAAK,EAAE,YAAY,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAkDzF;;;;GAIG;AACH,eAAO,MAAM,QAAQ,EAAE,gBAAgB,EAQtC,CAAA;AAID;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAChC;;OAEG;IACH,WAAW,CAAC,EAAE,gBAAgB,EAAE,CAAC;IAEjC;;;OAGG;IACH,SAAS,CAAC,EAAE,CAAC,CAAC,EAAE,YAAY,CAAC,QAAQ,CAAC,KAAK,IAAI,CAAC;IAEhD;;;;OAIG;IACH,QAAQ,CAAC,EAAE,CAAC,CAAC,EAAE,YAAY,CAAC,QAAQ,CAAC,KAAK,IAAI,CAAC;IAE/C;;OAEG;IACH,UAAU,CAAC,EAAE,CAAC,CAAC,EAAE,YAAY,CAAC,QAAQ,CAAC,KAAK,IAAI,CAAC;IAEjD;;;OAGG;IACH,SAAS,CAAC,EAAE,CAAC,CAAC,EAAE,YAAY,CAAC,QAAQ,CAAC,KAAK,IAAI,CAAC;IAEhD;;;;;OAKG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;CACxB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,wBAAgB,YAAY,CACxB,SA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