@everyonesoftware/common 2.0.0 → 3.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.
Files changed (59) hide show
  1. package/.github/workflows/publish.yml +54 -36
  2. package/package.json +6 -2
  3. package/sources/asyncIterator.ts +436 -436
  4. package/sources/asyncIteratorToJavascriptAsyncIteratorAdapter.ts +47 -47
  5. package/sources/asyncResult.ts +95 -95
  6. package/sources/byteList.ts +201 -201
  7. package/sources/byteListStream.ts +120 -120
  8. package/sources/byteReadStream.ts +23 -23
  9. package/sources/byteWriteStream.ts +15 -15
  10. package/sources/characterList.ts +194 -194
  11. package/sources/characterListStream.ts +150 -150
  12. package/sources/characterReadStream.ts +80 -80
  13. package/sources/characterReadStreamIterator.ts +127 -127
  14. package/sources/concatenateIterable.ts +118 -118
  15. package/sources/concatenateIterator.ts +164 -164
  16. package/sources/currentProcess.ts +157 -157
  17. package/sources/dateTime.ts +129 -129
  18. package/sources/depthFirstSearch.ts +229 -229
  19. package/sources/flatMapIterable.ts +103 -103
  20. package/sources/flatMapIterator.ts +151 -151
  21. package/sources/generator.ts +250 -250
  22. package/sources/index.ts +1 -1
  23. package/sources/iterator.ts +480 -480
  24. package/sources/javascriptAsyncIteratorToAsyncIteratorAdapter.ts +123 -123
  25. package/sources/javascriptSetSet.ts +133 -133
  26. package/sources/listQueue.ts +61 -61
  27. package/sources/listStack.ts +61 -61
  28. package/sources/luxonDateTime.ts +108 -108
  29. package/sources/mapAsyncIterator.ts +140 -140
  30. package/sources/mutableMap.ts +291 -291
  31. package/sources/node.ts +36 -36
  32. package/sources/promiseAsyncResult.ts +173 -173
  33. package/sources/queue.ts +48 -48
  34. package/sources/recreationDotGovClient.ts +258 -258
  35. package/sources/searchControl.ts +41 -41
  36. package/sources/set.ts +243 -243
  37. package/sources/skipAsyncIterator.ts +144 -144
  38. package/sources/stack.ts +47 -47
  39. package/sources/syncResult.ts +299 -299
  40. package/sources/takeAsyncIterator.ts +140 -140
  41. package/sources/whereAsyncIterator.ts +142 -142
  42. package/sources/wonderlandTrailClient.ts +1502 -1502
  43. package/tests/assertTestTests.ts +74 -74
  44. package/tests/byteListStreamTests.ts +389 -389
  45. package/tests/byteListTests.ts +26 -26
  46. package/tests/characterListStreamTests.ts +390 -390
  47. package/tests/characterListTests.ts +249 -249
  48. package/tests/dateTimeTests.ts +29 -29
  49. package/tests/depthFirstSearchTests.ts +105 -105
  50. package/tests/generatorTests.ts +85 -85
  51. package/tests/mutableMapTests.ts +153 -153
  52. package/tests/promiseAsyncResultTests.ts +687 -687
  53. package/tests/queueTests.ts +28 -28
  54. package/tests/recreationDotGovClientTests.ts +190 -190
  55. package/tests/setTests.ts +139 -139
  56. package/tests/stackTests.ts +65 -65
  57. package/tests/syncResultTests.ts +1250 -1250
  58. package/tests/wonderlandTrailClientTests.ts +451 -451
  59. package/tsup.config.ts +12 -12
@@ -1,250 +1,250 @@
1
- import { CharacterList } from "../sources/characterList";
2
- import { EqualFunctions } from "../sources/equalFunctions";
3
- import { JavascriptIterable } from "../sources/javascript";
4
- import { NotFoundError } from "../sources/notFoundError";
5
- import { PreConditionError } from "../sources/preConditionError";
6
- import { isNumber, isString } from "../sources/types";
7
- import { Test } from "./test";
8
- import { TestRunner } from "./testRunner";
9
-
10
- export function test(runner: TestRunner): void
11
- {
12
- runner.testFile("characterList.ts", () =>
13
- {
14
- runner.testType("CharacterList", () =>
15
- {
16
- runner.testFunction("create()", () =>
17
- {
18
- runner.test("with no arguments", (test: Test) =>
19
- {
20
- const list: CharacterList = CharacterList.create();
21
- test.assertNotUndefinedAndNotNull(list);
22
- test.assertEqual(0, list.getCount().await());
23
- test.assertFalse(list.any().await());
24
- test.assertEqual([], list.toArray().await());
25
- });
26
-
27
- runner.test("with undefined", (test: Test) =>
28
- {
29
- const list: CharacterList = CharacterList.create(undefined);
30
- test.assertNotUndefinedAndNotNull(list);
31
- test.assertEqual(0, list.getCount().await());
32
- test.assertFalse(list.any().await());
33
- test.assertEqual([], list.toArray().await());
34
- });
35
-
36
- runner.test("with null", (test: Test) =>
37
- {
38
- const list: CharacterList = CharacterList.create(null!);
39
- test.assertNotUndefinedAndNotNull(list);
40
- test.assertEqual(0, list.getCount().await());
41
- test.assertFalse(list.any().await());
42
- test.assertEqual([], list.toArray().await());
43
- });
44
-
45
- runner.test("with empty initialValues", (test: Test) =>
46
- {
47
- const list: CharacterList = CharacterList.create([]);
48
- test.assertNotUndefinedAndNotNull(list);
49
- test.assertEqual(0, list.getCount().await());
50
- test.assertFalse(list.any().await());
51
- test.assertEqual([], list.toArray().await());
52
- });
53
-
54
- runner.test("with one value", (test: Test) =>
55
- {
56
- const list: CharacterList = CharacterList.create(["m"]);
57
- test.assertNotUndefinedAndNotNull(list);
58
- test.assertEqual(1, list.getCount().await());
59
- test.assertTrue(list.any().await());
60
- test.assertEqual(["m"], list.toArray().await());
61
- });
62
-
63
- runner.test("with two values", (test: Test) =>
64
- {
65
- const list: CharacterList = CharacterList.create(["n", "l"]);
66
- test.assertNotUndefinedAndNotNull(list);
67
- test.assertEqual(2, list.getCount().await());
68
- test.assertTrue(list.any().await());
69
- test.assertEqual(["n", "l"], list.toArray().await());
70
- });
71
- });
72
-
73
- runner.testFunction("add()", () =>
74
- {
75
- function addErrorTest(value: string, expected: Error): void
76
- {
77
- runner.test(`with ${runner.toString(value)}`, (test: Test) =>
78
- {
79
- const list: CharacterList = CharacterList.create();
80
- test.assertThrows(() => list.add(value), expected);
81
- test.assertEqual([], list.toArray().await());
82
- });
83
- }
84
-
85
- addErrorTest("", new PreConditionError(
86
- "Expression: value",
87
- "Expected: character",
88
- "Actual: \"\"",
89
- ));
90
- addErrorTest("ab", new PreConditionError(
91
- "Expression: value",
92
- "Expected: character",
93
- "Actual: \"ab\"",
94
- ));
95
-
96
- runner.test("with valid value", (test: Test) =>
97
- {
98
- const list: CharacterList = CharacterList.create();
99
-
100
- const addResult1: CharacterList = list.add("a");
101
- test.assertSame(list, addResult1);
102
- test.assertEqual(["a"], addResult1.toArray().await());
103
-
104
- const addResult2: CharacterList = list.add("b");
105
- test.assertSame(list, addResult2);
106
- test.assertEqual(["a", "b"], addResult2.toArray().await());
107
-
108
- const addResult3: CharacterList = list.add("c");
109
- test.assertSame(list, addResult3);
110
- test.assertEqual(["a", "b", "c"], addResult3.toArray().await());
111
-
112
- const addResult4: CharacterList = list.add("d");
113
- test.assertSame(list, addResult4);
114
- test.assertEqual(["a", "b", "c", "d"], addResult4.toArray().await());
115
- });
116
- });
117
-
118
- runner.testFunction("addAll()", () =>
119
- {
120
- runner.test("with empty values", (test: Test) =>
121
- {
122
- const list: CharacterList = CharacterList.create();
123
-
124
- const addAllResult: CharacterList = list.addAll([]);
125
- test.assertSame(list, addAllResult);
126
- test.assertEqual([], list.toArray().await());
127
- });
128
-
129
- runner.test("with non-empty values", (test: Test) =>
130
- {
131
- const list: CharacterList = CharacterList.create();
132
-
133
- const addAllResult: CharacterList = list.addAll("abcde");
134
- test.assertSame(list, addAllResult);
135
- test.assertEqual(["a", "b", "c", "d", "e"], list.toArray().await());
136
- });
137
- });
138
-
139
- runner.testFunction("insert()", () =>
140
- {
141
- function insertErrorTest(initialValues: string[], index: number, value: string, expected: Error): void
142
- {
143
- runner.test(`with ${runner.andList([initialValues, index, value])}`, (test: Test) =>
144
- {
145
- const list: CharacterList = CharacterList.create(initialValues);
146
- test.assertThrows(() => list.insert(index, value), expected);
147
- test.assertEqual(initialValues, list.toArray().await());
148
- });
149
- }
150
-
151
- insertErrorTest([], -1, "a", new PreConditionError(
152
- "Expression: index",
153
- "Expected: 0",
154
- "Actual: -1",
155
- ));
156
- insertErrorTest([], 1, "a", new PreConditionError(
157
- "Expression: index",
158
- "Expected: 0",
159
- "Actual: 1",
160
- ));
161
- insertErrorTest(["z"], -1, "a", new PreConditionError(
162
- "Expression: index",
163
- "Expected: between 0 and 1",
164
- "Actual: -1",
165
- ));
166
- insertErrorTest(["z"], 2, "a", new PreConditionError(
167
- "Expression: index",
168
- "Expected: between 0 and 1",
169
- "Actual: 2",
170
- ));
171
- insertErrorTest([], 0, "", new PreConditionError(
172
- "Expression: value",
173
- "Expected: character",
174
- "Actual: \"\"",
175
- ));
176
- insertErrorTest([], 0, "ab", new PreConditionError(
177
- "Expression: value",
178
- "Expected: character",
179
- "Actual: \"ab\"",
180
- ));
181
-
182
- function insertTest(initialValues: JavascriptIterable<string>, index: number, value: string, expected: string[]): void
183
- {
184
- runner.test(`with ${runner.andList([initialValues, index, value])}`, (test: Test) =>
185
- {
186
- const list: CharacterList = CharacterList.create(initialValues);
187
-
188
- const insertResult: CharacterList = list.insert(index, value);
189
- test.assertSame(list, insertResult);
190
- test.assertEqual(expected, list.toArray().await());
191
- });
192
- }
193
-
194
- insertTest([], 0, "z", ["z"]);
195
- insertTest(["a"], 0, "y", ["y", "a"]);
196
- insertTest(["a"], 1, "y", ["a", "y"]);
197
- insertTest(["a", "b", "c"], 0, "z", ["z", "a", "b", "c"]);
198
- insertTest(["a", "b", "c"], 1, "z", ["a", "z", "b", "c"]);
199
- insertTest(["a", "b", "c"], 2, "z", ["a", "b", "z", "c"]);
200
- insertTest(["a", "b", "c"], 3, "z", ["a", "b", "c", "z"]);
201
- insertTest(["a", "b", "c", "d", "e"], 2, "z", ["a", "b", "z", "c", "d", "e"]);
202
- });
203
-
204
- runner.testFunction("remove()", () =>
205
- {
206
- runner.test("with not-found value", (test: Test) =>
207
- {
208
- const list: CharacterList = CharacterList.create();
209
-
210
- test.assertThrows(() => list.remove("a").await(), new NotFoundError("Could not find the value to remove: \"a\""));
211
- test.assertEqual([], list.toArray().await());
212
- });
213
-
214
- runner.test("with found value", (test: Test) =>
215
- {
216
- const list: CharacterList = CharacterList.create(["a"]);
217
-
218
- const removeResult: string = list.remove("a").await();
219
- test.assertEqual("a", removeResult);
220
- test.assertEqual([], list.toArray().await());
221
- });
222
-
223
- runner.test("with multiple found values", (test: Test) =>
224
- {
225
- const list: CharacterList = CharacterList.create(["a", "a", "a"]);
226
-
227
- const removeResult: string = list.remove("a").await();
228
- test.assertEqual("a", removeResult);
229
- test.assertEqual(["a", "a"], list.toArray().await());
230
- });
231
-
232
- runner.test("with multiple found values and equalFunctions", (test: Test) =>
233
- {
234
- const list: CharacterList = CharacterList.create(["a", "b", "c", "d", "e"]);
235
- const isVowel = (character: string) => ["a", "e", "i", "o", "u"].includes(character);
236
- const equalFunctions: EqualFunctions = EqualFunctions.create()
237
- .add((left: unknown, right: unknown) =>
238
- {
239
- return isString(left) && isString(right)
240
- ? isVowel(left) === isVowel(right)
241
- : undefined;
242
- });
243
- const removeResult: string = list.remove("i", equalFunctions).await();
244
- test.assertEqual("a", removeResult);
245
- test.assertEqual(["b", "c", "d", "e"], list.toArray().await());
246
- });
247
- });
248
- });
249
- });
1
+ import { CharacterList } from "../sources/characterList";
2
+ import { EqualFunctions } from "../sources/equalFunctions";
3
+ import { JavascriptIterable } from "../sources/javascript";
4
+ import { NotFoundError } from "../sources/notFoundError";
5
+ import { PreConditionError } from "../sources/preConditionError";
6
+ import { isNumber, isString } from "../sources/types";
7
+ import { Test } from "./test";
8
+ import { TestRunner } from "./testRunner";
9
+
10
+ export function test(runner: TestRunner): void
11
+ {
12
+ runner.testFile("characterList.ts", () =>
13
+ {
14
+ runner.testType("CharacterList", () =>
15
+ {
16
+ runner.testFunction("create()", () =>
17
+ {
18
+ runner.test("with no arguments", (test: Test) =>
19
+ {
20
+ const list: CharacterList = CharacterList.create();
21
+ test.assertNotUndefinedAndNotNull(list);
22
+ test.assertEqual(0, list.getCount().await());
23
+ test.assertFalse(list.any().await());
24
+ test.assertEqual([], list.toArray().await());
25
+ });
26
+
27
+ runner.test("with undefined", (test: Test) =>
28
+ {
29
+ const list: CharacterList = CharacterList.create(undefined);
30
+ test.assertNotUndefinedAndNotNull(list);
31
+ test.assertEqual(0, list.getCount().await());
32
+ test.assertFalse(list.any().await());
33
+ test.assertEqual([], list.toArray().await());
34
+ });
35
+
36
+ runner.test("with null", (test: Test) =>
37
+ {
38
+ const list: CharacterList = CharacterList.create(null!);
39
+ test.assertNotUndefinedAndNotNull(list);
40
+ test.assertEqual(0, list.getCount().await());
41
+ test.assertFalse(list.any().await());
42
+ test.assertEqual([], list.toArray().await());
43
+ });
44
+
45
+ runner.test("with empty initialValues", (test: Test) =>
46
+ {
47
+ const list: CharacterList = CharacterList.create([]);
48
+ test.assertNotUndefinedAndNotNull(list);
49
+ test.assertEqual(0, list.getCount().await());
50
+ test.assertFalse(list.any().await());
51
+ test.assertEqual([], list.toArray().await());
52
+ });
53
+
54
+ runner.test("with one value", (test: Test) =>
55
+ {
56
+ const list: CharacterList = CharacterList.create(["m"]);
57
+ test.assertNotUndefinedAndNotNull(list);
58
+ test.assertEqual(1, list.getCount().await());
59
+ test.assertTrue(list.any().await());
60
+ test.assertEqual(["m"], list.toArray().await());
61
+ });
62
+
63
+ runner.test("with two values", (test: Test) =>
64
+ {
65
+ const list: CharacterList = CharacterList.create(["n", "l"]);
66
+ test.assertNotUndefinedAndNotNull(list);
67
+ test.assertEqual(2, list.getCount().await());
68
+ test.assertTrue(list.any().await());
69
+ test.assertEqual(["n", "l"], list.toArray().await());
70
+ });
71
+ });
72
+
73
+ runner.testFunction("add()", () =>
74
+ {
75
+ function addErrorTest(value: string, expected: Error): void
76
+ {
77
+ runner.test(`with ${runner.toString(value)}`, (test: Test) =>
78
+ {
79
+ const list: CharacterList = CharacterList.create();
80
+ test.assertThrows(() => list.add(value), expected);
81
+ test.assertEqual([], list.toArray().await());
82
+ });
83
+ }
84
+
85
+ addErrorTest("", new PreConditionError(
86
+ "Expression: value",
87
+ "Expected: character",
88
+ "Actual: \"\"",
89
+ ));
90
+ addErrorTest("ab", new PreConditionError(
91
+ "Expression: value",
92
+ "Expected: character",
93
+ "Actual: \"ab\"",
94
+ ));
95
+
96
+ runner.test("with valid value", (test: Test) =>
97
+ {
98
+ const list: CharacterList = CharacterList.create();
99
+
100
+ const addResult1: CharacterList = list.add("a");
101
+ test.assertSame(list, addResult1);
102
+ test.assertEqual(["a"], addResult1.toArray().await());
103
+
104
+ const addResult2: CharacterList = list.add("b");
105
+ test.assertSame(list, addResult2);
106
+ test.assertEqual(["a", "b"], addResult2.toArray().await());
107
+
108
+ const addResult3: CharacterList = list.add("c");
109
+ test.assertSame(list, addResult3);
110
+ test.assertEqual(["a", "b", "c"], addResult3.toArray().await());
111
+
112
+ const addResult4: CharacterList = list.add("d");
113
+ test.assertSame(list, addResult4);
114
+ test.assertEqual(["a", "b", "c", "d"], addResult4.toArray().await());
115
+ });
116
+ });
117
+
118
+ runner.testFunction("addAll()", () =>
119
+ {
120
+ runner.test("with empty values", (test: Test) =>
121
+ {
122
+ const list: CharacterList = CharacterList.create();
123
+
124
+ const addAllResult: CharacterList = list.addAll([]);
125
+ test.assertSame(list, addAllResult);
126
+ test.assertEqual([], list.toArray().await());
127
+ });
128
+
129
+ runner.test("with non-empty values", (test: Test) =>
130
+ {
131
+ const list: CharacterList = CharacterList.create();
132
+
133
+ const addAllResult: CharacterList = list.addAll("abcde");
134
+ test.assertSame(list, addAllResult);
135
+ test.assertEqual(["a", "b", "c", "d", "e"], list.toArray().await());
136
+ });
137
+ });
138
+
139
+ runner.testFunction("insert()", () =>
140
+ {
141
+ function insertErrorTest(initialValues: string[], index: number, value: string, expected: Error): void
142
+ {
143
+ runner.test(`with ${runner.andList([initialValues, index, value])}`, (test: Test) =>
144
+ {
145
+ const list: CharacterList = CharacterList.create(initialValues);
146
+ test.assertThrows(() => list.insert(index, value), expected);
147
+ test.assertEqual(initialValues, list.toArray().await());
148
+ });
149
+ }
150
+
151
+ insertErrorTest([], -1, "a", new PreConditionError(
152
+ "Expression: index",
153
+ "Expected: 0",
154
+ "Actual: -1",
155
+ ));
156
+ insertErrorTest([], 1, "a", new PreConditionError(
157
+ "Expression: index",
158
+ "Expected: 0",
159
+ "Actual: 1",
160
+ ));
161
+ insertErrorTest(["z"], -1, "a", new PreConditionError(
162
+ "Expression: index",
163
+ "Expected: between 0 and 1",
164
+ "Actual: -1",
165
+ ));
166
+ insertErrorTest(["z"], 2, "a", new PreConditionError(
167
+ "Expression: index",
168
+ "Expected: between 0 and 1",
169
+ "Actual: 2",
170
+ ));
171
+ insertErrorTest([], 0, "", new PreConditionError(
172
+ "Expression: value",
173
+ "Expected: character",
174
+ "Actual: \"\"",
175
+ ));
176
+ insertErrorTest([], 0, "ab", new PreConditionError(
177
+ "Expression: value",
178
+ "Expected: character",
179
+ "Actual: \"ab\"",
180
+ ));
181
+
182
+ function insertTest(initialValues: JavascriptIterable<string>, index: number, value: string, expected: string[]): void
183
+ {
184
+ runner.test(`with ${runner.andList([initialValues, index, value])}`, (test: Test) =>
185
+ {
186
+ const list: CharacterList = CharacterList.create(initialValues);
187
+
188
+ const insertResult: CharacterList = list.insert(index, value);
189
+ test.assertSame(list, insertResult);
190
+ test.assertEqual(expected, list.toArray().await());
191
+ });
192
+ }
193
+
194
+ insertTest([], 0, "z", ["z"]);
195
+ insertTest(["a"], 0, "y", ["y", "a"]);
196
+ insertTest(["a"], 1, "y", ["a", "y"]);
197
+ insertTest(["a", "b", "c"], 0, "z", ["z", "a", "b", "c"]);
198
+ insertTest(["a", "b", "c"], 1, "z", ["a", "z", "b", "c"]);
199
+ insertTest(["a", "b", "c"], 2, "z", ["a", "b", "z", "c"]);
200
+ insertTest(["a", "b", "c"], 3, "z", ["a", "b", "c", "z"]);
201
+ insertTest(["a", "b", "c", "d", "e"], 2, "z", ["a", "b", "z", "c", "d", "e"]);
202
+ });
203
+
204
+ runner.testFunction("remove()", () =>
205
+ {
206
+ runner.test("with not-found value", (test: Test) =>
207
+ {
208
+ const list: CharacterList = CharacterList.create();
209
+
210
+ test.assertThrows(() => list.remove("a").await(), new NotFoundError("Could not find the value to remove: \"a\""));
211
+ test.assertEqual([], list.toArray().await());
212
+ });
213
+
214
+ runner.test("with found value", (test: Test) =>
215
+ {
216
+ const list: CharacterList = CharacterList.create(["a"]);
217
+
218
+ const removeResult: string = list.remove("a").await();
219
+ test.assertEqual("a", removeResult);
220
+ test.assertEqual([], list.toArray().await());
221
+ });
222
+
223
+ runner.test("with multiple found values", (test: Test) =>
224
+ {
225
+ const list: CharacterList = CharacterList.create(["a", "a", "a"]);
226
+
227
+ const removeResult: string = list.remove("a").await();
228
+ test.assertEqual("a", removeResult);
229
+ test.assertEqual(["a", "a"], list.toArray().await());
230
+ });
231
+
232
+ runner.test("with multiple found values and equalFunctions", (test: Test) =>
233
+ {
234
+ const list: CharacterList = CharacterList.create(["a", "b", "c", "d", "e"]);
235
+ const isVowel = (character: string) => ["a", "e", "i", "o", "u"].includes(character);
236
+ const equalFunctions: EqualFunctions = EqualFunctions.create()
237
+ .add((left: unknown, right: unknown) =>
238
+ {
239
+ return isString(left) && isString(right)
240
+ ? isVowel(left) === isVowel(right)
241
+ : undefined;
242
+ });
243
+ const removeResult: string = list.remove("i", equalFunctions).await();
244
+ test.assertEqual("a", removeResult);
245
+ test.assertEqual(["b", "c", "d", "e"], list.toArray().await());
246
+ });
247
+ });
248
+ });
249
+ });
250
250
  }
@@ -1,30 +1,30 @@
1
- import { DateTime } from "../sources/dateTime";
2
- import { Test } from "./test";
3
- import { TestRunner } from "./testRunner";
4
-
5
- export function test(runner: TestRunner): void
6
- {
7
- runner.testFile("dateTime.ts", () =>
8
- {
9
- runner.testType("DateTime", () =>
10
- {
11
- runner.testFunction("parse()", () =>
12
- {
13
- runner.test(`with "2025-03-14T20:18:30"`, (test: Test) =>
14
- {
15
- const dateTime: DateTime = DateTime.parse("2025-03-14T20:18:30");
16
- test.assertNotUndefinedAndNotNull(dateTime);
17
- test.assertEqual(2025, dateTime.getYear());
18
- test.assertEqual(3, dateTime.getMonth());
19
- test.assertEqual(14, dateTime.getDay());
20
- test.assertEqual(20, dateTime.getHour());
21
- test.assertEqual(18, dateTime.getMinute());
22
- test.assertEqual(30, dateTime.getSecond());
23
- test.assertEqual("2025-03-14", dateTime.toDateString());
24
- test.assertEqual("2025-03-14T20:18:30.000-07:00", dateTime.toString());
25
- test.assertEqual("2025-03-14T20:18:30.000-07:00", dateTime.debug);
26
- });
27
- });
28
- });
29
- });
1
+ import { DateTime } from "../sources/dateTime";
2
+ import { Test } from "./test";
3
+ import { TestRunner } from "./testRunner";
4
+
5
+ export function test(runner: TestRunner): void
6
+ {
7
+ runner.testFile("dateTime.ts", () =>
8
+ {
9
+ runner.testType("DateTime", () =>
10
+ {
11
+ runner.testFunction("parse()", () =>
12
+ {
13
+ runner.test(`with "2025-03-14T20:18:30"`, (test: Test) =>
14
+ {
15
+ const dateTime: DateTime = DateTime.parse("2025-03-14T20:18:30");
16
+ test.assertNotUndefinedAndNotNull(dateTime);
17
+ test.assertEqual(2025, dateTime.getYear());
18
+ test.assertEqual(3, dateTime.getMonth());
19
+ test.assertEqual(14, dateTime.getDay());
20
+ test.assertEqual(20, dateTime.getHour());
21
+ test.assertEqual(18, dateTime.getMinute());
22
+ test.assertEqual(30, dateTime.getSecond());
23
+ test.assertEqual("2025-03-14", dateTime.toDateString());
24
+ test.assertEqual("2025-03-14T20:18:30.000-07:00", dateTime.toString());
25
+ test.assertEqual("2025-03-14T20:18:30.000-07:00", dateTime.debug);
26
+ });
27
+ });
28
+ });
29
+ });
30
30
  }