@elaraai/east-node-std 0.0.1-beta.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.
Files changed (101) hide show
  1. package/CLA.md +26 -0
  2. package/CONTRIBUTING.md +28 -0
  3. package/README.md +135 -0
  4. package/dist/console.d.ts +192 -0
  5. package/dist/console.d.ts.map +1 -0
  6. package/dist/console.js +228 -0
  7. package/dist/console.js.map +1 -0
  8. package/dist/crypto.d.ts +212 -0
  9. package/dist/crypto.d.ts.map +1 -0
  10. package/dist/crypto.js +259 -0
  11. package/dist/crypto.js.map +1 -0
  12. package/dist/fetch.d.ts +310 -0
  13. package/dist/fetch.d.ts.map +1 -0
  14. package/dist/fetch.js +336 -0
  15. package/dist/fetch.js.map +1 -0
  16. package/dist/fs.d.ts +520 -0
  17. package/dist/fs.d.ts.map +1 -0
  18. package/dist/fs.js +630 -0
  19. package/dist/fs.js.map +1 -0
  20. package/dist/index.d.ts +59 -0
  21. package/dist/index.d.ts.map +1 -0
  22. package/dist/index.js +86 -0
  23. package/dist/index.js.map +1 -0
  24. package/dist/path.d.ts +241 -0
  25. package/dist/path.d.ts.map +1 -0
  26. package/dist/path.js +299 -0
  27. package/dist/path.js.map +1 -0
  28. package/dist/random/crypto-rng.d.ts +31 -0
  29. package/dist/random/crypto-rng.d.ts.map +1 -0
  30. package/dist/random/crypto-rng.js +44 -0
  31. package/dist/random/crypto-rng.js.map +1 -0
  32. package/dist/random/distributions/bates.d.ts +12 -0
  33. package/dist/random/distributions/bates.d.ts.map +1 -0
  34. package/dist/random/distributions/bates.js +15 -0
  35. package/dist/random/distributions/bates.js.map +1 -0
  36. package/dist/random/distributions/bernoulli.d.ts +12 -0
  37. package/dist/random/distributions/bernoulli.d.ts.map +1 -0
  38. package/dist/random/distributions/bernoulli.js +13 -0
  39. package/dist/random/distributions/bernoulli.js.map +1 -0
  40. package/dist/random/distributions/binomial.d.ts +12 -0
  41. package/dist/random/distributions/binomial.d.ts.map +1 -0
  42. package/dist/random/distributions/binomial.js +24 -0
  43. package/dist/random/distributions/binomial.js.map +1 -0
  44. package/dist/random/distributions/exponential.d.ts +12 -0
  45. package/dist/random/distributions/exponential.d.ts.map +1 -0
  46. package/dist/random/distributions/exponential.js +13 -0
  47. package/dist/random/distributions/exponential.js.map +1 -0
  48. package/dist/random/distributions/geometric.d.ts +12 -0
  49. package/dist/random/distributions/geometric.d.ts.map +1 -0
  50. package/dist/random/distributions/geometric.js +14 -0
  51. package/dist/random/distributions/geometric.js.map +1 -0
  52. package/dist/random/distributions/irwin-hall.d.ts +12 -0
  53. package/dist/random/distributions/irwin-hall.d.ts.map +1 -0
  54. package/dist/random/distributions/irwin-hall.js +18 -0
  55. package/dist/random/distributions/irwin-hall.js.map +1 -0
  56. package/dist/random/distributions/log-normal.d.ts +12 -0
  57. package/dist/random/distributions/log-normal.d.ts.map +1 -0
  58. package/dist/random/distributions/log-normal.js +12 -0
  59. package/dist/random/distributions/log-normal.js.map +1 -0
  60. package/dist/random/distributions/normal.d.ts +13 -0
  61. package/dist/random/distributions/normal.d.ts.map +1 -0
  62. package/dist/random/distributions/normal.js +16 -0
  63. package/dist/random/distributions/normal.js.map +1 -0
  64. package/dist/random/distributions/pareto.d.ts +12 -0
  65. package/dist/random/distributions/pareto.d.ts.map +1 -0
  66. package/dist/random/distributions/pareto.js +14 -0
  67. package/dist/random/distributions/pareto.js.map +1 -0
  68. package/dist/random/distributions/poisson.d.ts +12 -0
  69. package/dist/random/distributions/poisson.d.ts.map +1 -0
  70. package/dist/random/distributions/poisson.js +81 -0
  71. package/dist/random/distributions/poisson.js.map +1 -0
  72. package/dist/random/distributions/uniform-int.d.ts +12 -0
  73. package/dist/random/distributions/uniform-int.d.ts.map +1 -0
  74. package/dist/random/distributions/uniform-int.js +16 -0
  75. package/dist/random/distributions/uniform-int.js.map +1 -0
  76. package/dist/random/distributions/uniform.d.ts +12 -0
  77. package/dist/random/distributions/uniform.d.ts.map +1 -0
  78. package/dist/random/distributions/uniform.js +10 -0
  79. package/dist/random/distributions/uniform.js.map +1 -0
  80. package/dist/random/rng.d.ts +17 -0
  81. package/dist/random/rng.d.ts.map +1 -0
  82. package/dist/random/rng.js +7 -0
  83. package/dist/random/rng.js.map +1 -0
  84. package/dist/random/xorshift128.d.ts +35 -0
  85. package/dist/random/xorshift128.d.ts.map +1 -0
  86. package/dist/random/xorshift128.js +112 -0
  87. package/dist/random/xorshift128.js.map +1 -0
  88. package/dist/random.d.ts +773 -0
  89. package/dist/random.d.ts.map +1 -0
  90. package/dist/random.js +934 -0
  91. package/dist/random.js.map +1 -0
  92. package/dist/test.d.ts +253 -0
  93. package/dist/test.d.ts.map +1 -0
  94. package/dist/test.js +407 -0
  95. package/dist/test.js.map +1 -0
  96. package/dist/time.d.ts +130 -0
  97. package/dist/time.d.ts.map +1 -0
  98. package/dist/time.js +154 -0
  99. package/dist/time.js.map +1 -0
  100. package/dist/tsconfig.tsbuildinfo +1 -0
  101. package/package.json +84 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"random.js","sourceRoot":"","sources":["../src/random.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEvE,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AAInD,OAAO,SAAS,MAAM,wBAAwB,CAAC;AAC/C,OAAO,cAAc,MAAM,yBAAyB,CAAC;AACrD,OAAO,WAAW,MAAM,mCAAmC,CAAC;AAC5D,OAAO,cAAc,MAAM,uCAAuC,CAAC;AACnE,OAAO,UAAU,MAAM,kCAAkC,CAAC;AAC1D,OAAO,eAAe,MAAM,uCAAuC,CAAC;AACpE,OAAO,aAAa,MAAM,qCAAqC,CAAC;AAChE,OAAO,YAAY,MAAM,oCAAoC,CAAC;AAC9D,OAAO,aAAa,MAAM,qCAAqC,CAAC;AAChE,OAAO,WAAW,MAAM,mCAAmC,C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IAE3B;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,QAAQ,EAAE,eAAe;IAEzB;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,SAAS,EAAE,gBAAgB;IAE3B;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,OAAO,EAAE,cAAc;IAEvB;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,MAAM,EAAE,aAAa;IAErB;;;;;;;;;;;;;;;;;;;;;OAqBG;IACH,SAAS,EAAE,iBAAiB;IAE5B;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,SAAS,EAAE,iBAAiB;IAE5B;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,KAAK,EAAE,YAAY;IAEnB;;;;;;;;;;;;;;;;;;;;;;;;OAwBG;IACH,IAAI,EAAE,WAAW;IAEjB;;;;OAIG;IACH,cAAc,EAAE,UAAU;CACpB,CAAC;AAEX,gDAAgD;AAChD,OAAO,EAAE,UAAU,EAAE,CAAC"}
package/dist/test.d.ts ADDED
@@ -0,0 +1,253 @@
1
+ import { Expr, NullType, StringType, BlockBuilder, type SubtypeExprOrValue, type ExprType, type EastType } from "@elaraai/east";
2
+ import type { PlatformFunction, PlatformFunctionDef } from "@elaraai/east/internal";
3
+ /**
4
+ * Signals that a test assertion passed.
5
+ *
6
+ * This platform function is used internally by East test assertions to indicate
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
34
+ */
35
+ export declare const testPass: PlatformFunctionDef<[], typeof NullType>;
36
+ export declare const NodeTestTypes: any[];
37
+ export declare const NodeTest: PlatformFunction[];
38
+ /**
39
+ * Configuration options for East test suites.
40
+ */
41
+ export interface DescribeEastOptions {
42
+ /**
43
+ * Platform functions to include in all tests and hooks.
44
+ */
45
+ platformFns?: PlatformFunction[];
46
+ /**
47
+ * Setup function run once before all tests.
48
+ * Use for opening database connections, initializing resources, etc.
49
+ */
50
+ beforeAll?: ($: BlockBuilder<NullType>) => void;
51
+ /**
52
+ * Cleanup function run once after all tests.
53
+ * Use for closing database connections, cleaning up resources, etc.
54
+ * Runs even if tests fail.
55
+ */
56
+ afterAll?: ($: BlockBuilder<NullType>) => void;
57
+ /**
58
+ * Setup function run before each test.
59
+ */
60
+ beforeEach?: ($: BlockBuilder<NullType>) => void;
61
+ /**
62
+ * Cleanup function run after each test.
63
+ * Runs even if the test fails.
64
+ */
65
+ afterEach?: ($: BlockBuilder<NullType>) => void;
66
+ }
67
+ /**
68
+ * Wrapper around Node.js `describe` that also exports test IR for cross-platform testing.
69
+ *
70
+ * This function behaves exactly like Node.js `describe` - it runs all the tests normally.
71
+ * Additionally, it creates a single East function that runs all tests in sequence,
72
+ * making it easy to export the entire test suite for running in other East implementations.
73
+ *
74
+ * Supports lifecycle hooks (beforeAll, afterAll, beforeEach, afterEach) as East functions
75
+ * to properly set up and tear down resources like database connections.
76
+ *
77
+ * @param suiteName - The name of the test suite
78
+ * @param builder - A function that receives a `test` function for defining tests
79
+ * @param options - Configuration options including platform functions and lifecycle hooks
80
+ *
81
+ * @example
82
+ * ```ts
83
+ * // Basic usage with platform functions
84
+ * describeEast("Array tests", (test) => {
85
+ * test("addition", $ => {
86
+ * $(Test.equal(East.value(1n).add(1n), 2n));
87
+ * });
88
+ * }, { platformFns: [] });
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));
101
+ * });
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
+ * });
110
+ * ```
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
+ *
116
+ * These functions generate East expressions that perform runtime assertions
117
+ * using platform functions, enabling testing of East code.
118
+ */
119
+ /**
120
+ * East assertion functions that match Node.js assert API naming.
121
+ *
122
+ * These functions generate East expressions that perform runtime assertions
123
+ * using platform functions, enabling testing of East code.
124
+ */
125
+ export declare const Test: {
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>;
171
+ /**
172
+ * Asserts that two values are the same reference (meaning if one is mutated, the other reflects the change - and they are always equal).
173
+ *
174
+ * @typeParam E - The type of the actual expression
175
+ * @param actual - The actual value to test
176
+ * @param expected - The expected value to compare against
177
+ * @returns An East expression that performs the equality check
178
+ */
179
+ is<E extends EastType>(actual: Expr<E>, expected: SubtypeExprOrValue<NoInfer<E>>): ExprType<NullType>;
180
+ /**
181
+ * Asserts that two values are equal.
182
+ *
183
+ * @typeParam E - The type of the actual expression
184
+ * @param actual - The actual value to test
185
+ * @param expected - The expected value to compare against
186
+ * @returns An East expression that performs the equality check
187
+ */
188
+ equal<E extends EastType>(actual: Expr<E>, expected: SubtypeExprOrValue<NoInfer<E>>): ExprType<NullType>;
189
+ /**
190
+ * Asserts that two values are not equal.
191
+ *
192
+ * @typeParam E - The type of the actual expression
193
+ * @param actual - The actual value to test
194
+ * @param expected - The value that should not be equal
195
+ * @returns An East expression that performs the inequality check
196
+ */
197
+ notEqual<E extends EastType>(actual: Expr<E>, expected: SubtypeExprOrValue<NoInfer<E>>): ExprType<NullType>;
198
+ /**
199
+ * Asserts that actual is less than expected.
200
+ *
201
+ * @typeParam E - The type of the actual expression
202
+ * @param actual - The actual value to test
203
+ * @param expected - The value that actual should be less than
204
+ * @returns An East expression that performs the less-than check
205
+ */
206
+ less<E extends EastType>(actual: Expr<E>, expected: SubtypeExprOrValue<NoInfer<E>>): ExprType<NullType>;
207
+ /**
208
+ * Asserts that actual is less than or equal to expected.
209
+ *
210
+ * @typeParam E - The type of the actual expression
211
+ * @param actual - The actual value to test
212
+ * @param expected - The value that actual should be less than or equal to
213
+ * @returns An East expression that performs the less-than-or-equal check
214
+ */
215
+ lessEqual<E extends EastType>(actual: Expr<E>, expected: SubtypeExprOrValue<NoInfer<E>>): ExprType<NullType>;
216
+ /**
217
+ * Asserts that actual is greater than expected.
218
+ *
219
+ * @typeParam E - The type of the actual expression
220
+ * @param actual - The actual value to test
221
+ * @param expected - The value that actual should be greater than
222
+ * @returns An East expression that performs the greater-than check
223
+ */
224
+ greater<E extends EastType>(actual: Expr<E>, expected: SubtypeExprOrValue<NoInfer<E>>): ExprType<NullType>;
225
+ /**
226
+ * Asserts that actual is greater than or equal to expected.
227
+ *
228
+ * @typeParam E - The type of the actual expression
229
+ * @param actual - The actual value to test
230
+ * @param expected - The value that actual should be greater than or equal to
231
+ * @returns An East expression that performs the greater-than-or-equal check
232
+ */
233
+ greaterEqual<E extends EastType>(actual: Expr<E>, expected: SubtypeExprOrValue<NoInfer<E>>): ExprType<NullType>;
234
+ /**
235
+ * Asserts that actual is between min and max (inclusive).
236
+ *
237
+ * @typeParam E - The type of the actual expression
238
+ * @param actual - The actual value to test
239
+ * @param min - The minimum value (inclusive)
240
+ * @param max - The maximum value (inclusive)
241
+ * @returns An East expression that performs the range check
242
+ */
243
+ between<E extends EastType>(actual: Expr<E>, min: SubtypeExprOrValue<NoInfer<E>>, max: SubtypeExprOrValue<NoInfer<E>>): ExprType<NullType>;
244
+ /**
245
+ * Asserts that an expression throws an error.
246
+ *
247
+ * @param fn - The expression that should throw an error when evaluated
248
+ * @param pattern - Optional regex pattern to match against the error message
249
+ * @returns An East expression that verifies an error is thrown
250
+ */
251
+ throws(fn: Expr<any>, pattern?: RegExp): ExprType<NullType>;
252
+ };
253
+ //# s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OG;iBACU,CAAC,SAAS,QAAQ,UAAU,IAAI,CAAC,CAAC,CAAC,YAAY,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,QAAQ,CAAC;IAgB/G;;;;;;;;OAQG;YACK,CAAC,SAAS,QAAQ,UAAU,IAAI,CAAC,CAAC,CAAC,OAAO,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,OAAO,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,QAAQ,CAAC;IAgB1I;;;;;;OAMG;eACQ,IAAI,CAAC,GAAG,CAAC,YAAY,MAAM,GAAG,QAAQ,CAAC,QAAQ,CAAC;CAsB9D,CAAC"}
package/dist/test.js ADDED
@@ -0,0 +1,407 @@
1
+ /**
2
+ * Copyright (c) 2025 Elara AI Pty Ltd
3
+ * Dual-licensed under AGPL-3.0 and commercial license. See LICENSE for details.
4
+ */
5
+ import assert from "node:assert/strict";
6
+ import { test as testNode, describe as describeNode } from "node:test";
7
+ import { East, Expr, get_location, NullType, StringType, BlockBuilder, FunctionType } from "@elaraai/east";
8
+ const { str } = East;
9
+ /**
10
+ * Signals that a test assertion passed.
11
+ *
12
+ * This platform function is used internally by East test assertions to indicate
13
+ * successful validation. When executed in Node.js, it performs no action (the test
14
+ * continues normally). Other platform implementations may log or track passes.
15
+ *
16
+ * This function is primarily used within the {@link Test} assertion helpers rather
17
+ * than being called directly in test code.
18
+ *
19
+ * @returns `null` - Has no meaningful return value
20
+ *
21
+ * @example
22
+ * ```ts
23
+ * import { East, NullType } from "@elaraai/east";
24
+ * import { Test } from "@elaraai/east-node-std";
25
+ *
26
+ * // Used internally by Test assertions
27
+ * const myTest = East.function([], NullType, $ => {
28
+ * // Test.equal internally calls testPass when the assertion succeeds
29
+ * $(Test.equal(East.value(42n), 42n));
30
+ * });
31
+ *
32
+ * const compiled = East.compile(myTest.toIR(), Test.Implementation);
33
+ * compiled(); // Test passes silently
34
+ * ```
35
+ *
36
+ * @remarks
37
+ * - Does not throw or produce output in Node.js implementation
38
+ * - Used by all {@link Test} assertion methods to signal success
39
+ * - Can be called directly for custom assertion logic
40
+ */
41
+ export const testPass = East.platform("testPass", [], NullType);
42
+ /**
43
+ * Signals that a test assertion failed with a message.
44
+ *
45
+ * This platform function is used internally by East test assertions to indicate
46
+ * validation failures. When executed in Node.js, it throws an assertion error with
47
+ * the provided message, causing the test to fail.
48
+ *
49
+ * This function is primarily used within the {@link Test} assertion helpers rather
50
+ * than being called directly, though it can be used for custom failure conditions.
51
+ *
52
+ * @param message - The error message describing why the assertion failed
53
+ * @returns `null` - Never actually returns (throws in implementation)
54
+ *
55
+ * @throws {AssertionError} Always throws with the provided message (Node.js implementation)
56
+ *
57
+ * @example
58
+ * ```ts
59
+ * import { East, StringType, NullType } from "@elaraai/east";
60
+ * import { Test } from "@elaraai/east-node-std";
61
+ *
62
+ * // Used internally by Test assertions
63
+ * const myTest = East.function([], NullType, $ => {
64
+ * // Test.equal internally calls testFail when the assertion fails
65
+ * $(Test.equal(East.value(42n), 99n));
66
+ * // Throws: "Expected 42 to equal 99 (...)"
67
+ * });
68
+ * ```
69
+ *
70
+ * @example
71
+ * ```ts
72
+ * // Direct usage for custom validation
73
+ * const validatePositive = East.function([IntegerType], NullType, ($, n) => {
74
+ * return n.greater(0n).ifElse(
75
+ * _ => Test.pass(),
76
+ * _ => Test.fail("Number must be positive")
77
+ * );
78
+ * });
79
+ *
80
+ * const compiled = East.compile(validatePositive.toIR(), Test.Implementation);
81
+ * compiled(-5n); // Throws: "Number must be positive"
82
+ * ```
83
+ *
84
+ * @remarks
85
+ * - Always throws in Node.js implementation (test fails immediately)
86
+ * - Used by all {@link Test} assertion methods to signal failure
87
+ * - Accepts location information in message for debugging
88
+ */
89
+ const testFail = East.platform("testFail", [StringType], NullType);
90
+ const test = East.platform("test", [StringType, FunctionType([], NullType, null),], NullType);
91
+ const describe = East.platform("describe", [StringType, FunctionType([], NullType, null),], NullType);
92
+ export const NodeTestTypes = [
93
+ testPass,
94
+ testFail,
95
+ test,
96
+ describe,
97
+ ];
98
+ export const NodeTest = [
99
+ testPass.implement(() => { }), // Assertion passed - do nothing (test continues)
100
+ testFail.implement((message) => {
101
+ // Assertion failed - throw to fail the test
102
+ assert.fail(message);
103
+ }),
104
+ test.implement((name, body) => {
105
+ testNode(name, () => {
106
+ body();
107
+ });
108
+ }),
109
+ describe.implement((name, body) => {
110
+ describeNode(name, () => {
111
+ body();
112
+ });
113
+ }),
114
+ ];
115
+ /**
116
+ * Wrapper around Node.js `describe` that also exports test IR for cross-platform testing.
117
+ *
118
+ * This function behaves exactly like Node.js `describe` - it runs all the tests normally.
119
+ * Additionally, it creates a single East function that runs all tests in sequence,
120
+ * making it easy to export the entire test suite for running in other East implementations.
121
+ *
122
+ * Supports lifecycle hooks (beforeAll, afterAll, beforeEach, afterEach) as East functions
123
+ * to properly set up and tear down resources like database connections.
124
+ *
125
+ * @param suiteName - The name of the test suite
126
+ * @param builder - A function that receives a `test` function for defining tests
127
+ * @param options - Configuration options including platform functions and lifecycle hooks
128
+ *
129
+ * @example
130
+ * ```ts
131
+ * // Basic usage with platform functions
132
+ * describeEast("Array tests", (test) => {
133
+ * test("addition", $ => {
134
+ * $(Test.equal(East.value(1n).add(1n), 2n));
135
+ * });
136
+ * }, { platformFns: [] });
137
+ * ```
138
+ *
139
+ * @example
140
+ * ```ts
141
+ * // With database cleanup hooks
142
+ * import { SQL } from "@elaraai/east-node-io";
143
+ *
144
+ * describeEast("Database tests", (test) => {
145
+ * test("query users", $ => {
146
+ * const conn = $.let(SQL.Postgres.connect(config));
147
+ * const result = $.let(SQL.Postgres.query(conn, "SELECT * FROM users", []));
148
+ * $(Test.equal(result.rows.length(), 2n));
149
+ * });
150
+ * }, {
151
+ * platformFns: SQL.Postgres.Implementation,
152
+ * afterEach: $ => {
153
+ * // Close connections even if test fails
154
+ * const conn = $.let(SQL.Postgres.connect(config));
155
+ * $(SQL.Postgres.close(conn));
156
+ * }
157
+ * });
158
+ * ```
159
+ */
160
+ export function describeEast(suiteName, builder, options = {}) {
161
+ const platformFns = options.platformFns ?? [];
162
+ const tests = [];
163
+ // Collect all test names and bodies
164
+ builder((name, body) => tests.push({ name, body }));
165
+ // Create a single East function that uses describe/test platform functions
166
+ const suiteFunction = East.function([], NullType, $ => {
167
+ $(describe.call($, suiteName, East.function([], NullType, $ => {
168
+ if (options.beforeAll)
169
+ $(test.call($, "beforeAll", East.function([], NullType, options.beforeAll)));
170
+ for (const { name, body } of tests) {
171
+ if (options.beforeEach)
172
+ $(test.call($, "beforeEach", East.function([], NullType, options.beforeEach)));
173
+ $(test.call($, name, East.function([], NullType, body)));
174
+ if (options.afterEach)
175
+ $(test.call($, "afterEach", East.function([], NullType, options.afterEach)));
176
+ }
177
+ if (options.afterAll)
178
+ $(test.call($, "afterAll", East.function([], NullType, options.afterAll)));
179
+ })));
180
+ });
181
+ const funcs = [...NodeTest, ...platformFns];
182
+ if (funcs.some(f => f.type === 'async')) {
183
+ suiteFunction.toIR().compileAsync([...NodeTest, ...platformFns]);
184
+ }
185
+ else {
186
+ suiteFunction.toIR().compile([...NodeTest, ...platformFns]);
187
+ }
188
+ // Run the test suite using the Node.js platform implementation
189
+ }
190
+ /**
191
+ * East assertion functions that match Node.js assert API naming.
192
+ *
193
+ * These functions generate East expressions that perform runtime assertions
194
+ * using platform functions, enabling testing of East code.
195
+ */
196
+ /**
197
+ * East assertion functions that match Node.js assert API naming.
198
+ *
199
+ * These functions generate East expressions that perform runtime assertions
200
+ * using platform functions, enabling testing of East code.
201
+ */
202
+ export const Test = {
203
+ /**
204
+ * Platform function that signals a test assertion passed.
205
+ *
206
+ * Used internally by assertion methods to indicate successful validation.
207
+ * Does nothing in Node.js implementation - test continues normally.
208
+ *
209
+ * @returns An East expression that returns `null`
210
+ *
211
+ * @example
212
+ * ```ts
213
+ * import { East, NullType } from "@elaraai/east";
214
+ * import { Test } from "@elaraai/east-node-std";
215
+ *
216
+ * const customAssertion = East.function([], NullType, $ => {
217
+ * return East.value(true).ifElse(
218
+ * _ => Test.pass(),
219
+ * _ => Test.fail("Condition was false")
220
+ * );
221
+ * });
222
+ * ```
223
+ */
224
+ pass: testPass,
225
+ /**
226
+ * Platform function that signals a test assertion failed.
227
+ *
228
+ * Used internally by assertion methods to indicate validation failures.
229
+ * Throws an assertion error in Node.js implementation - test fails immediately.
230
+ *
231
+ * @param message - Error message describing the failure
232
+ * @returns An East expression that returns `null` (never actually returns - throws)
233
+ *
234
+ * @example
235
+ * ```ts
236
+ * import { East, StringType, NullType } from "@elaraai/east";
237
+ * import { Test } from "@elaraai/east-node-std";
238
+ *
239
+ * const validateRange = East.function([IntegerType], NullType, ($, value) => {
240
+ * return value.between(0n, 100n).ifElse(
241
+ * _ => Test.pass(),
242
+ * _ => Test.fail("Value must be between 0 and 100")
243
+ * );
244
+ * });
245
+ * ```
246
+ */
247
+ fail: testFail,
248
+ /**
249
+ * Asserts that two values are the same reference (meaning if one is mutated, the other reflects the change - and they are always equal).
250
+ *
251
+ * @typeParam E - The type of the actual expression
252
+ * @param actual - The actual value to test
253
+ * @param expected - The expected value to compare against
254
+ * @returns An East expression that performs the equality check
255
+ */
256
+ is(actual, expected) {
257
+ const location = get_location(2);
258
+ const expected_expr = Expr.from(expected, Expr.type(actual));
259
+ return Expr.tryCatch(Expr.block($ => {
260
+ const act = $.let(actual);
261
+ const exp = $.let(expected_expr);
262
+ return East.is(act, exp).ifElse(_$ => testPass(), _$ => testFail(str `Expected ${act} to equal ${exp} (${East.value(`${location.filename} ${location.line}:${location.column}`)})`));
263
+ }), (_$, message, stack) => testFail(East.String.printError(message, stack)));
264
+ },
265
+ /**
266
+ * Asserts that two values are equal.
267
+ *
268
+ * @typeParam E - The type of the actual expression
269
+ * @param actual - The actual value to test
270
+ * @param expected - The expected value to compare against
271
+ * @returns An East expression that performs the equality check
272
+ */
273
+ equal(actual, expected) {
274
+ const location = get_location(2);
275
+ const expected_expr = Expr.from(expected, Expr.type(actual));
276
+ return Expr.tryCatch(Expr.block($ => {
277
+ const act = $.let(actual);
278
+ const exp = $.let(expected_expr);
279
+ return East.equal(act, exp).ifElse(_$ => testPass(), _$ => testFail(str `Expected ${act} to equal ${exp} (${East.value(`${location.filename} ${location.line}:${location.column}`)})`));
280
+ }), (_$, message, stack) => testFail(East.String.printError(message, stack)));
281
+ },
282
+ /**
283
+ * Asserts that two values are not equal.
284
+ *
285
+ * @typeParam E - The type of the actual expression
286
+ * @param actual - The actual value to test
287
+ * @param expected - The value that should not be equal
288
+ * @returns An East expression that performs the inequality check
289
+ */
290
+ notEqual(actual, expected) {
291
+ const location = get_location(2);
292
+ const expected_expr = Expr.from(expected, Expr.type(actual));
293
+ return Expr.tryCatch(Expr.block($ => {
294
+ const act = $.let(actual);
295
+ const exp = $.let(expected_expr);
296
+ return East.notEqual(act, exp).ifElse(_$ => testPass(), _$ => testFail(str `Expected ${act} to not equal ${exp} (${East.value(`${location.filename} ${location.line}:${location.column}`)})`));
297
+ }), (_$, message, stack) => testFail(East.String.printError(message, stack)));
298
+ },
299
+ /**
300
+ * Asserts that actual is less than expected.
301
+ *
302
+ * @typeParam E - The type of the actual expression
303
+ * @param actual - The actual value to test
304
+ * @param expected - The value that actual should be less than
305
+ * @returns An East expression that performs the less-than check
306
+ */
307
+ less(actual, expected) {
308
+ const location = get_location(2);
309
+ const expected_expr = Expr.from(expected, Expr.type(actual));
310
+ return Expr.tryCatch(Expr.block($ => {
311
+ const act = $.let(actual);
312
+ const exp = $.let(expected_expr);
313
+ return East.less(act, exp).ifElse(_$ => testPass(), _$ => testFail(str `Expected ${act} to be less than ${exp} (${`${location.filename} ${location.line}:${location.column}`})`));
314
+ }), (_$, message, stack) => testFail(East.String.printError(message, stack)));
315
+ },
316
+ /**
317
+ * Asserts that actual is less than or equal to expected.
318
+ *
319
+ * @typeParam E - The type of the actual expression
320
+ * @param actual - The actual value to test
321
+ * @param expected - The value that actual should be less than or equal to
322
+ * @returns An East expression that performs the less-than-or-equal check
323
+ */
324
+ lessEqual(actual, expected) {
325
+ const location = get_location(2);
326
+ const expected_expr = Expr.from(expected, Expr.type(actual));
327
+ return Expr.tryCatch(Expr.block($ => {
328
+ const act = $.let(actual);
329
+ const exp = $.let(expected_expr);
330
+ return East.lessEqual(act, exp).ifElse(_$ => testPass(), _$ => testFail(str `Expected ${act} to be less than or equal to ${exp} (${`${location.filename} ${location.line}:${location.column}`})`));
331
+ }), (_$, message, stack) => testFail(East.String.printError(message, stack)));
332
+ },
333
+ /**
334
+ * Asserts that actual is greater than expected.
335
+ *
336
+ * @typeParam E - The type of the actual expression
337
+ * @param actual - The actual value to test
338
+ * @param expected - The value that actual should be greater than
339
+ * @returns An East expression that performs the greater-than check
340
+ */
341
+ greater(actual, expected) {
342
+ const location = get_location(2);
343
+ const expected_expr = Expr.from(expected, Expr.type(actual));
344
+ return Expr.tryCatch(Expr.block($ => {
345
+ const act = $.let(actual);
346
+ const exp = $.let(expected_expr);
347
+ return East.greater(act, exp).ifElse(_$ => testPass(), _$ => testFail(str `Expected ${act} to be greater than ${exp} (${`${location.filename} ${location.line}:${location.column}`})`));
348
+ }), (_$, message, stack) => testFail(East.String.printError(message, stack)));
349
+ },
350
+ /**
351
+ * Asserts that actual is greater than or equal to expected.
352
+ *
353
+ * @typeParam E - The type of the actual expression
354
+ * @param actual - The actual value to test
355
+ * @param expected - The value that actual should be greater than or equal to
356
+ * @returns An East expression that performs the greater-than-or-equal check
357
+ */
358
+ greaterEqual(actual, expected) {
359
+ const location = get_location(2);
360
+ const expected_expr = Expr.from(expected, Expr.type(actual));
361
+ return Expr.tryCatch(Expr.block($ => {
362
+ const act = $.let(actual);
363
+ const exp = $.let(expected_expr);
364
+ return East.greaterEqual(act, exp).ifElse(_$ => testPass(), _$ => testFail(str `Expected ${act} to be greater than or equal to ${exp} (${`${location.filename} ${location.line}:${location.column}`})`));
365
+ }), (_$, message, stack) => testFail(East.String.printError(message, stack)));
366
+ },
367
+ /**
368
+ * Asserts that actual is between min and max (inclusive).
369
+ *
370
+ * @typeParam E - The type of the actual expression
371
+ * @param actual - The actual value to test
372
+ * @param min - The minimum value (inclusive)
373
+ * @param max - The maximum value (inclusive)
374
+ * @returns An East expression that performs the range check
375
+ */
376
+ between(actual, min, max) {
377
+ const location = get_location(2);
378
+ const min_expr = Expr.from(min, Expr.type(actual));
379
+ const max_expr = Expr.from(max, Expr.type(actual));
380
+ return Expr.tryCatch(East.greaterEqual(actual, min_expr).ifElse(_$ => East.lessEqual(actual, max_expr).ifElse(_$ => testPass(), _$ => testFail(str `Expected ${actual} to be less than or equal to ${max_expr} (${`${location.filename} ${location.line}:${location.column}`})`)), _$ => testFail(str `Expected ${actual} to be greater than or equal to ${min_expr}`)), (_$, message, stack) => testFail(East.String.printError(message, stack)));
381
+ },
382
+ /**
383
+ * Asserts that an expression throws an error.
384
+ *
385
+ * @param fn - The expression that should throw an error when evaluated
386
+ * @param pattern - Optional regex pattern to match against the error message
387
+ * @returns An East expression that verifies an error is thrown
388
+ */
389
+ throws(fn, pattern) {
390
+ const location = get_location(2);
391
+ return Expr.tryCatch(Expr.block($ => {
392
+ const result = $.let(fn);
393
+ $(testFail(str `Expected error, got ${result} (${East.value(`${location.filename} ${location.line}:${location.column}`)})`));
394
+ return null;
395
+ }), ($, message, stack) => {
396
+ if (pattern) {
397
+ // Validate error message matches the pattern
398
+ return message.contains(pattern).ifElse(_$ => testPass(), _$ => testFail(str `Expected error message to match ${East.value(pattern.source)}, but got: ${East.String.printError(message, stack)}`));
399
+ }
400
+ else {
401
+ // Just verify it threw
402
+ return testPass();
403
+ }
404
+ });
405
+ },
406
+ };
407
+ //# sourceMappingURL=test.js.map