@everyonesoftware/common 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.
Files changed (163) hide show
  1. package/.c8rc.json +12 -0
  2. package/.github/workflows/publish.yml +38 -0
  3. package/.mocharc.json +9 -0
  4. package/README.md +9 -0
  5. package/package.json +36 -0
  6. package/sources/assertMessageParameters.ts +22 -0
  7. package/sources/asyncIterator.ts +437 -0
  8. package/sources/asyncIteratorToJavascriptAsyncIteratorAdapter.ts +48 -0
  9. package/sources/asyncResult.ts +95 -0
  10. package/sources/basicDisposable.ts +57 -0
  11. package/sources/byteList.ts +202 -0
  12. package/sources/byteListStream.ts +121 -0
  13. package/sources/byteReadStream.ts +24 -0
  14. package/sources/byteWriteStream.ts +16 -0
  15. package/sources/bytes.ts +25 -0
  16. package/sources/characterList.ts +195 -0
  17. package/sources/characterListStream.ts +151 -0
  18. package/sources/characterReadStream.ts +81 -0
  19. package/sources/characterReadStreamIterator.ts +128 -0
  20. package/sources/characterWriteStream.ts +45 -0
  21. package/sources/commandLineParameter.ts +45 -0
  22. package/sources/commandLineParameters.ts +21 -0
  23. package/sources/comparable.ts +144 -0
  24. package/sources/comparer.ts +133 -0
  25. package/sources/comparison.ts +20 -0
  26. package/sources/concatenateIterable.ts +119 -0
  27. package/sources/concatenateIterator.ts +165 -0
  28. package/sources/condition.ts +329 -0
  29. package/sources/currentProcess.ts +158 -0
  30. package/sources/dateTime.ts +130 -0
  31. package/sources/depthFirstSearch.ts +230 -0
  32. package/sources/disposable.ts +31 -0
  33. package/sources/emptyError.ts +10 -0
  34. package/sources/english.ts +45 -0
  35. package/sources/equalFunctions.ts +123 -0
  36. package/sources/fetchHttpClient.ts +89 -0
  37. package/sources/fetchHttpResponse.ts +106 -0
  38. package/sources/flatMapIterable.ts +104 -0
  39. package/sources/flatMapIterator.ts +152 -0
  40. package/sources/generator.ts +251 -0
  41. package/sources/httpClient.ts +36 -0
  42. package/sources/httpHeader.ts +37 -0
  43. package/sources/httpHeaders.ts +216 -0
  44. package/sources/httpIncomingRequest.ts +30 -0
  45. package/sources/httpIncomingResponse.ts +19 -0
  46. package/sources/httpMethod.ts +164 -0
  47. package/sources/httpOutgoingRequest.ts +119 -0
  48. package/sources/httpOutgoingResponse.ts +113 -0
  49. package/sources/httpServer.ts +34 -0
  50. package/sources/inMemoryCharacterWriteStream.ts +78 -0
  51. package/sources/index.ts +101 -0
  52. package/sources/iterable.ts +345 -0
  53. package/sources/iterator.ts +481 -0
  54. package/sources/iteratorToJavascriptIteratorAdapter.ts +48 -0
  55. package/sources/javascript.ts +59 -0
  56. package/sources/javascriptArrayList.ts +175 -0
  57. package/sources/javascriptAsyncIteratorToAsyncIteratorAdapter.ts +124 -0
  58. package/sources/javascriptIteratorToIteratorAdapter.ts +133 -0
  59. package/sources/javascriptMapMap.ts +143 -0
  60. package/sources/javascriptSetSet.ts +134 -0
  61. package/sources/list.ts +330 -0
  62. package/sources/listQueue.ts +62 -0
  63. package/sources/listStack.ts +62 -0
  64. package/sources/luxonDateTime.ts +109 -0
  65. package/sources/map.ts +302 -0
  66. package/sources/mapAsyncIterator.ts +141 -0
  67. package/sources/mapIterable.ts +105 -0
  68. package/sources/mapIterator.ts +145 -0
  69. package/sources/mutableCondition.ts +451 -0
  70. package/sources/mutableHttpHeaders.ts +204 -0
  71. package/sources/mutableMap.ts +292 -0
  72. package/sources/network.ts +18 -0
  73. package/sources/node.ts +37 -0
  74. package/sources/nodeJSCharacterWriteStream.ts +42 -0
  75. package/sources/nodeJSHttpIncomingRequest.ts +132 -0
  76. package/sources/nodeJSHttpServer.ts +134 -0
  77. package/sources/notFoundError.ts +12 -0
  78. package/sources/postCondition.ts +284 -0
  79. package/sources/postConditionError.ts +12 -0
  80. package/sources/preCondition.ts +284 -0
  81. package/sources/preConditionError.ts +12 -0
  82. package/sources/promiseAsyncResult.ts +174 -0
  83. package/sources/property.ts +63 -0
  84. package/sources/queue.ts +49 -0
  85. package/sources/realNetwork.ts +28 -0
  86. package/sources/recreationDotGovClient.ts +259 -0
  87. package/sources/searchControl.ts +42 -0
  88. package/sources/set.ts +244 -0
  89. package/sources/skipAsyncIterator.ts +145 -0
  90. package/sources/skipIterator.ts +155 -0
  91. package/sources/stack.ts +48 -0
  92. package/sources/stringComparer.ts +33 -0
  93. package/sources/stringIterator.ts +149 -0
  94. package/sources/strings.ts +322 -0
  95. package/sources/syncResult.ts +300 -0
  96. package/sources/takeAsyncIterator.ts +141 -0
  97. package/sources/takeIterator.ts +151 -0
  98. package/sources/toStringFunctions.ts +185 -0
  99. package/sources/types.ts +371 -0
  100. package/sources/whereAsyncIterator.ts +143 -0
  101. package/sources/whereIterable.ts +108 -0
  102. package/sources/whereIterator.ts +157 -0
  103. package/sources/wonderlandTrailClient.ts +1503 -0
  104. package/tests/assertTest.ts +113 -0
  105. package/tests/assertTestTests.ts +75 -0
  106. package/tests/basicTestSkip.ts +51 -0
  107. package/tests/byteListStreamTests.ts +390 -0
  108. package/tests/byteListTests.ts +27 -0
  109. package/tests/bytesTests.ts +43 -0
  110. package/tests/characterListStreamTests.ts +391 -0
  111. package/tests/characterListTests.ts +250 -0
  112. package/tests/characterWriteStreamTests.ts +12 -0
  113. package/tests/comparerTests.ts +92 -0
  114. package/tests/conditionTests.ts +877 -0
  115. package/tests/consoleTestRunner.ts +404 -0
  116. package/tests/consoleTestRunnerTests.ts +651 -0
  117. package/tests/dateTimeTests.ts +30 -0
  118. package/tests/depthFirstSearchTests.ts +106 -0
  119. package/tests/disposableTests.ts +121 -0
  120. package/tests/englishTests.ts +103 -0
  121. package/tests/equalFunctionsTests.ts +223 -0
  122. package/tests/failedTest.ts +43 -0
  123. package/tests/fetchHttpClientTests.ts +33 -0
  124. package/tests/generatorTests.ts +86 -0
  125. package/tests/httpClientTests.ts +18 -0
  126. package/tests/inMemoryCharacterWriteStreamTests.ts +117 -0
  127. package/tests/iterableTests.ts +141 -0
  128. package/tests/iteratorTests.ts +1086 -0
  129. package/tests/javascriptMapMapTests.ts +21 -0
  130. package/tests/listTests.ts +338 -0
  131. package/tests/mapIteratorTests.ts +55 -0
  132. package/tests/mapTests.ts +104 -0
  133. package/tests/mutableConditionTests.ts +273 -0
  134. package/tests/mutableMapTests.ts +154 -0
  135. package/tests/nodeJSHttpServerTests.ts +75 -0
  136. package/tests/notFoundErrorTests.ts +24 -0
  137. package/tests/postConditionErrorTests.ts +24 -0
  138. package/tests/preConditionErrorTests.ts +24 -0
  139. package/tests/promiseAsyncResultTests.ts +688 -0
  140. package/tests/propertyTests.ts +63 -0
  141. package/tests/queueTests.ts +29 -0
  142. package/tests/recreationDotGovClientTests.ts +191 -0
  143. package/tests/setTests.ts +140 -0
  144. package/tests/skippedTest.ts +39 -0
  145. package/tests/stackTests.ts +66 -0
  146. package/tests/stringComparerTests.ts +60 -0
  147. package/tests/stringIteratorTests.ts +156 -0
  148. package/tests/stringsTests.ts +516 -0
  149. package/tests/syncResultTests.ts +1251 -0
  150. package/tests/test.ts +228 -0
  151. package/tests/testAction.ts +75 -0
  152. package/tests/testActionTests.ts +93 -0
  153. package/tests/testFailureTests.ts +12 -0
  154. package/tests/testRunner.ts +267 -0
  155. package/tests/testRunnerTests.ts +895 -0
  156. package/tests/testSkip.ts +34 -0
  157. package/tests/tests.ts +103 -0
  158. package/tests/toStringFunctionsTests.ts +55 -0
  159. package/tests/typesTests.ts +257 -0
  160. package/tests/whereIteratorTests.ts +77 -0
  161. package/tests/wonderlandTrailClientTests.ts +452 -0
  162. package/tsconfig.json +17 -0
  163. package/tsup.config.ts +13 -0
@@ -0,0 +1,895 @@
1
+ import { Iterable } from "../sources/iterable";
2
+ import { PreConditionError } from "../sources/preConditionError";
3
+ import { join } from "../sources/strings";
4
+ import { Type } from "../sources/types";
5
+ import { Test } from "./test";
6
+ import { TestRunner } from "./testRunner";
7
+ import { TestSkip } from "./testSkip";
8
+
9
+ export function test(runner: TestRunner): void
10
+ {
11
+ runner.testFile("testRunner.ts", () =>
12
+ {
13
+ runner.testType("TestRunner", () =>
14
+ {
15
+ });
16
+ });
17
+ }
18
+
19
+ export function test2(runner: TestRunner, creator: () => TestRunner): void
20
+ {
21
+ runner.testFile("testRunner.ts", () =>
22
+ {
23
+ runner.testType("TestRunner", () =>
24
+ {
25
+ runner.testFunction("andList()", () =>
26
+ {
27
+ function andListErrorTest(values: unknown[] | Iterable<unknown>, expected: Error): void
28
+ {
29
+ runner.test(`with ${runner.toString(values)}`, (test: Test) =>
30
+ {
31
+ const runner2: TestRunner = creator();
32
+ test.assertThrows(() => runner2.andList(values), expected);
33
+ });
34
+ }
35
+
36
+ andListErrorTest(undefined!, new PreConditionError(join("\n", [
37
+ "Expression: values",
38
+ "Expected: not undefined and not null",
39
+ "Actual: undefined",
40
+ ])));
41
+ andListErrorTest(null!, new PreConditionError(join("\n", [
42
+ "Expression: values",
43
+ "Expected: not undefined and not null",
44
+ "Actual: null",
45
+ ])));
46
+
47
+ function andListTest(values: unknown[] | Iterable<unknown>, expected: string): void
48
+ {
49
+ runner.test(`with ${runner.toString(values)}`, (test: Test) =>
50
+ {
51
+ const runner2: TestRunner = creator();
52
+ test.assertEqual(expected, runner2.andList(values));
53
+ });
54
+ }
55
+
56
+ andListTest([], "");
57
+ andListTest(["a"], `"a"`);
58
+ andListTest([1, "a"], `1 and "a"`);
59
+ andListTest([1, "a", {a:7}], `1, "a", and {"a":7}`);
60
+ });
61
+
62
+ runner.testFunction("toString()", () =>
63
+ {
64
+ function toStringTest(value: unknown, expected: string): void
65
+ {
66
+ runner.test(`with ${runner.toString(value)}`, (test: Test) =>
67
+ {
68
+ const runner2: TestRunner = creator();
69
+ test.assertEqual(expected, runner2.toString(value));
70
+ });
71
+ }
72
+
73
+ toStringTest(undefined, "undefined");
74
+ toStringTest(null, "null");
75
+ toStringTest(false, "false");
76
+ toStringTest(true, "true");
77
+ toStringTest(5, "5");
78
+ toStringTest(6.4, "6.4");
79
+ toStringTest("", `""`);
80
+ toStringTest("hello there", `"hello there"`);
81
+ toStringTest({}, "{}");
82
+ toStringTest({a:{b:"c"}}, `{"a":{"b":"c"}}`);
83
+ toStringTest([], "[]");
84
+ toStringTest([false, 1, "d"], `[false,1,"d"]`);
85
+ });
86
+
87
+ runner.testFunction("skip()", () =>
88
+ {
89
+ runner.test("with no arguments", (test: Test) =>
90
+ {
91
+ const runner2: TestRunner = creator();
92
+ const testSkip: TestSkip = runner2.skip();
93
+ test.assertNotUndefinedAndNotNull(testSkip);
94
+ test.assertTrue(testSkip.getShouldSkip());
95
+ test.assertEqual("", testSkip.getMessage());
96
+ });
97
+
98
+ runner.test("with false", (test: Test) =>
99
+ {
100
+ const runner2: TestRunner = creator();
101
+ const testSkip: TestSkip = runner2.skip(false);
102
+ test.assertNotUndefinedAndNotNull(testSkip);
103
+ test.assertFalse(testSkip.getShouldSkip());
104
+ test.assertEqual("", testSkip.getMessage());
105
+ });
106
+
107
+ runner.test("with true", (test: Test) =>
108
+ {
109
+ const runner2: TestRunner = creator();
110
+ const testSkip: TestSkip = runner2.skip(true);
111
+ test.assertNotUndefinedAndNotNull(testSkip);
112
+ test.assertTrue(testSkip.getShouldSkip());
113
+ test.assertEqual("", testSkip.getMessage());
114
+ });
115
+
116
+ runner.test("with message", (test: Test) =>
117
+ {
118
+ const runner2: TestRunner = creator();
119
+ const testSkip: TestSkip = runner2.skip(true, "hello there!");
120
+ test.assertNotUndefinedAndNotNull(testSkip);
121
+ test.assertTrue(testSkip.getShouldSkip());
122
+ test.assertEqual("hello there!", testSkip.getMessage());
123
+ });
124
+ });
125
+
126
+ runner.testFunction("testFile()", () =>
127
+ {
128
+ runner.testGroup("with no skip", () =>
129
+ {
130
+ function testFileErrorTest(testName: string, fileName: string, testAction: () => void, expected: Error): void
131
+ {
132
+ runner.test(testName, (test: Test) =>
133
+ {
134
+ const runner2: TestRunner = creator();
135
+ test.assertThrows(() => runner2.testFile(fileName, testAction), expected);
136
+ })
137
+ }
138
+
139
+ testFileErrorTest(
140
+ "with undefined fileName",
141
+ undefined!,
142
+ () => {},
143
+ new PreConditionError(
144
+ "Expression: fileName",
145
+ "Expected: not undefined and not null",
146
+ "Actual: undefined",
147
+ ),
148
+ )
149
+ testFileErrorTest(
150
+ "with null fileName",
151
+ null!,
152
+ () => {},
153
+ new PreConditionError(
154
+ "Expression: fileName",
155
+ "Expected: not undefined and not null",
156
+ "Actual: null",
157
+ ),
158
+ )
159
+ testFileErrorTest(
160
+ "with empty fileName",
161
+ "",
162
+ () => {},
163
+ new PreConditionError(
164
+ "Expression: fileName",
165
+ "Expected: not empty",
166
+ "Actual: \"\"",
167
+ ),
168
+ )
169
+ testFileErrorTest(
170
+ "with undefined testAction",
171
+ "abc",
172
+ undefined!,
173
+ new PreConditionError(
174
+ "Expression: testAction",
175
+ "Expected: not undefined and not null",
176
+ "Actual: undefined",
177
+ ),
178
+ )
179
+ testFileErrorTest(
180
+ "with null testAction",
181
+ "abc",
182
+ null!,
183
+ new PreConditionError(
184
+ "Expression: testAction",
185
+ "Expected: not undefined and not null",
186
+ "Actual: undefined",
187
+ ),
188
+ )
189
+ });
190
+
191
+ runner.testGroup("with undefined skip", () =>
192
+ {
193
+ function testFileErrorTest(testName: string, fileName: string, testAction: () => void, expected: Error): void
194
+ {
195
+ runner.test(testName, (test: Test) =>
196
+ {
197
+ const runner2: TestRunner = creator();
198
+ test.assertThrows(() => runner2.testFile(fileName, undefined, testAction), expected);
199
+ })
200
+ }
201
+
202
+ testFileErrorTest(
203
+ "with undefined fileName",
204
+ undefined!,
205
+ () => {},
206
+ new PreConditionError(
207
+ "Expression: fileName",
208
+ "Expected: not undefined and not null",
209
+ "Actual: undefined",
210
+ ),
211
+ )
212
+ testFileErrorTest(
213
+ "with null fileName",
214
+ null!,
215
+ () => {},
216
+ new PreConditionError(
217
+ "Expression: fileName",
218
+ "Expected: not undefined and not null",
219
+ "Actual: null",
220
+ ),
221
+ )
222
+ testFileErrorTest(
223
+ "with empty fileName",
224
+ "",
225
+ () => {},
226
+ new PreConditionError(
227
+ "Expression: fileName",
228
+ "Expected: not empty",
229
+ "Actual: \"\"",
230
+ ),
231
+ )
232
+ testFileErrorTest(
233
+ "with undefined testAction",
234
+ "abc",
235
+ undefined!,
236
+ new PreConditionError(
237
+ "Expression: testAction",
238
+ "Expected: not undefined and not null",
239
+ "Actual: undefined",
240
+ ),
241
+ )
242
+ testFileErrorTest(
243
+ "with null testAction",
244
+ "abc",
245
+ null!,
246
+ new PreConditionError(
247
+ "Expression: testAction",
248
+ "Expected: not undefined and not null",
249
+ "Actual: null",
250
+ ),
251
+ )
252
+ });
253
+
254
+ runner.testGroup("with null skip", () =>
255
+ {
256
+ function testFileErrorTest(testName: string, fileName: string, testAction: () => void, expected: Error): void
257
+ {
258
+ runner.test(testName, (test: Test) =>
259
+ {
260
+ const runner2: TestRunner = creator();
261
+ test.assertThrows(() => runner2.testFile(fileName, null!, testAction), expected);
262
+ })
263
+ }
264
+
265
+ testFileErrorTest(
266
+ "with undefined fileName",
267
+ undefined!,
268
+ () => {},
269
+ new PreConditionError(
270
+ "Expression: fileName",
271
+ "Expected: not undefined and not null",
272
+ "Actual: undefined",
273
+ ),
274
+ )
275
+ testFileErrorTest(
276
+ "with null fileName",
277
+ null!,
278
+ () => {},
279
+ new PreConditionError(
280
+ "Expression: fileName",
281
+ "Expected: not undefined and not null",
282
+ "Actual: null",
283
+ ),
284
+ )
285
+ testFileErrorTest(
286
+ "with empty fileName",
287
+ "",
288
+ () => {},
289
+ new PreConditionError(
290
+ "Expression: fileName",
291
+ "Expected: not empty",
292
+ "Actual: \"\"",
293
+ ),
294
+ )
295
+ testFileErrorTest(
296
+ "with undefined testAction",
297
+ "abc",
298
+ undefined!,
299
+ new PreConditionError(
300
+ "Expression: testAction",
301
+ "Expected: not undefined and not null",
302
+ "Actual: undefined",
303
+ ),
304
+ )
305
+ testFileErrorTest(
306
+ "with null testAction",
307
+ "abc",
308
+ null!,
309
+ new PreConditionError(
310
+ "Expression: testAction",
311
+ "Expected: not undefined and not null",
312
+ "Actual: null",
313
+ ),
314
+ )
315
+ });
316
+
317
+ runner.testGroup("with skip", () =>
318
+ {
319
+ function testFileErrorTest(testName: string, fileName: string, testAction: () => void, expected: Error): void
320
+ {
321
+ runner.test(testName, (test: Test) =>
322
+ {
323
+ const runner2: TestRunner = creator();
324
+ const skip: TestSkip = runner2.skip();
325
+ test.assertThrows(() => runner2.testFile(fileName, skip, testAction), expected);
326
+ })
327
+ }
328
+
329
+ testFileErrorTest(
330
+ "with undefined fileName",
331
+ undefined!,
332
+ () => {},
333
+ new PreConditionError(
334
+ "Expression: fileName",
335
+ "Expected: not undefined and not null",
336
+ "Actual: undefined",
337
+ ),
338
+ )
339
+ testFileErrorTest(
340
+ "with null fileName",
341
+ null!,
342
+ () => {},
343
+ new PreConditionError(
344
+ "Expression: fileName",
345
+ "Expected: not undefined and not null",
346
+ "Actual: null",
347
+ ),
348
+ )
349
+ testFileErrorTest(
350
+ "with empty fileName",
351
+ "",
352
+ () => {},
353
+ new PreConditionError(
354
+ "Expression: fileName",
355
+ "Expected: not empty",
356
+ "Actual: \"\"",
357
+ ),
358
+ )
359
+ testFileErrorTest(
360
+ "with undefined testAction",
361
+ "abc",
362
+ undefined!,
363
+ new PreConditionError(
364
+ "Expression: testAction",
365
+ "Expected: not undefined and not null",
366
+ "Actual: undefined",
367
+ ),
368
+ )
369
+ testFileErrorTest(
370
+ "with null testAction",
371
+ "abc",
372
+ null!,
373
+ new PreConditionError(
374
+ "Expression: testAction",
375
+ "Expected: not undefined and not null",
376
+ "Actual: null",
377
+ ),
378
+ )
379
+ });
380
+ });
381
+
382
+ runner.testFunction("testType()", () =>
383
+ {
384
+ runner.testGroup("with no skip", () =>
385
+ {
386
+ function testTypeErrorTest(testName: string, typeNameOrType: string | Type<unknown>, testAction: () => void, expected: Error): void
387
+ {
388
+ runner.test(testName, (test: Test) =>
389
+ {
390
+ const runner2: TestRunner = creator();
391
+ test.assertThrows(() => runner2.testType(typeNameOrType, testAction), expected);
392
+ })
393
+ }
394
+
395
+ testTypeErrorTest(
396
+ "with undefined typeNameOrType",
397
+ undefined!,
398
+ () => {},
399
+ new PreConditionError(
400
+ "Expression: typeNameOrType",
401
+ "Expected: not undefined and not null",
402
+ "Actual: undefined",
403
+ ),
404
+ )
405
+ testTypeErrorTest(
406
+ "with null typeNameOrType",
407
+ null!,
408
+ () => {},
409
+ new PreConditionError(
410
+ "Expression: typeNameOrType",
411
+ "Expected: not undefined and not null",
412
+ "Actual: null",
413
+ ),
414
+ )
415
+ testTypeErrorTest(
416
+ "with empty typeNameOrType",
417
+ "",
418
+ () => {},
419
+ new PreConditionError(
420
+ "Expression: typeName",
421
+ "Expected: not empty",
422
+ "Actual: \"\"",
423
+ ),
424
+ )
425
+ testTypeErrorTest(
426
+ "with undefined testAction",
427
+ "abc",
428
+ undefined!,
429
+ new PreConditionError(
430
+ "Expression: testAction",
431
+ "Expected: not undefined and not null",
432
+ "Actual: undefined",
433
+ ),
434
+ )
435
+ testTypeErrorTest(
436
+ "with null testAction",
437
+ "abc",
438
+ null!,
439
+ new PreConditionError(
440
+ "Expression: testAction",
441
+ "Expected: not undefined and not null",
442
+ "Actual: undefined",
443
+ ),
444
+ )
445
+ });
446
+
447
+ runner.testGroup("with undefined skip", () =>
448
+ {
449
+ function testTypeErrorTest(testName: string, typeNameOrType: string | Type<unknown>, testAction: () => void, expected: Error): void
450
+ {
451
+ runner.test(testName, (test: Test) =>
452
+ {
453
+ const runner2: TestRunner = creator();
454
+ test.assertThrows(() => runner2.testType(typeNameOrType, undefined, testAction), expected);
455
+ })
456
+ }
457
+
458
+ testTypeErrorTest(
459
+ "with undefined typeNameOrType",
460
+ undefined!,
461
+ () => {},
462
+ new PreConditionError(
463
+ "Expression: typeNameOrType",
464
+ "Expected: not undefined and not null",
465
+ "Actual: undefined",
466
+ ),
467
+ )
468
+ testTypeErrorTest(
469
+ "with null typeNameOrType",
470
+ null!,
471
+ () => {},
472
+ new PreConditionError(
473
+ "Expression: typeNameOrType",
474
+ "Expected: not undefined and not null",
475
+ "Actual: null",
476
+ ),
477
+ )
478
+ testTypeErrorTest(
479
+ "with empty typeNameOrType",
480
+ "",
481
+ () => {},
482
+ new PreConditionError(
483
+ "Expression: typeName",
484
+ "Expected: not empty",
485
+ "Actual: \"\"",
486
+ ),
487
+ )
488
+ testTypeErrorTest(
489
+ "with undefined testAction",
490
+ "abc",
491
+ undefined!,
492
+ new PreConditionError(
493
+ "Expression: testAction",
494
+ "Expected: not undefined and not null",
495
+ "Actual: undefined",
496
+ ),
497
+ )
498
+ testTypeErrorTest(
499
+ "with null testAction",
500
+ "abc",
501
+ null!,
502
+ new PreConditionError(
503
+ "Expression: testAction",
504
+ "Expected: not undefined and not null",
505
+ "Actual: null",
506
+ ),
507
+ )
508
+ });
509
+
510
+ runner.testGroup("with null skip", () =>
511
+ {
512
+ function testTypeErrorTest(testName: string, typeNameOrType: string | Type<unknown>, testAction: () => void, expected: Error): void
513
+ {
514
+ runner.test(testName, (test: Test) =>
515
+ {
516
+ const runner2: TestRunner = creator();
517
+ test.assertThrows(() => runner2.testType(typeNameOrType, null!, testAction), expected);
518
+ })
519
+ }
520
+
521
+ testTypeErrorTest(
522
+ "with undefined typeNameOrType",
523
+ undefined!,
524
+ () => {},
525
+ new PreConditionError(
526
+ "Expression: typeNameOrType",
527
+ "Expected: not undefined and not null",
528
+ "Actual: undefined",
529
+ ),
530
+ )
531
+ testTypeErrorTest(
532
+ "with null typeNameOrType",
533
+ null!,
534
+ () => {},
535
+ new PreConditionError(
536
+ "Expression: typeNameOrType",
537
+ "Expected: not undefined and not null",
538
+ "Actual: null",
539
+ ),
540
+ )
541
+ testTypeErrorTest(
542
+ "with empty typeNameOrType",
543
+ "",
544
+ () => {},
545
+ new PreConditionError(
546
+ "Expression: typeName",
547
+ "Expected: not empty",
548
+ "Actual: \"\"",
549
+ ),
550
+ )
551
+ testTypeErrorTest(
552
+ "with undefined testAction",
553
+ "abc",
554
+ undefined!,
555
+ new PreConditionError(
556
+ "Expression: testAction",
557
+ "Expected: not undefined and not null",
558
+ "Actual: undefined",
559
+ ),
560
+ )
561
+ testTypeErrorTest(
562
+ "with null testAction",
563
+ "abc",
564
+ null!,
565
+ new PreConditionError(
566
+ "Expression: testAction",
567
+ "Expected: not undefined and not null",
568
+ "Actual: null",
569
+ ),
570
+ )
571
+ });
572
+
573
+ runner.testGroup("with skip", () =>
574
+ {
575
+ function testTypeErrorTest(testName: string, typeNameOrType: string | Type<unknown>, testAction: () => void, expected: Error): void
576
+ {
577
+ runner.test(testName, (test: Test) =>
578
+ {
579
+ const runner2: TestRunner = creator();
580
+ const skip: TestSkip = runner2.skip();
581
+ test.assertThrows(() => runner2.testType(typeNameOrType, skip, testAction), expected);
582
+ })
583
+ }
584
+
585
+ testTypeErrorTest(
586
+ "with undefined typeNameOrType",
587
+ undefined!,
588
+ () => {},
589
+ new PreConditionError(
590
+ "Expression: typeNameOrType",
591
+ "Expected: not undefined and not null",
592
+ "Actual: undefined",
593
+ ),
594
+ )
595
+ testTypeErrorTest(
596
+ "with null typeNameOrType",
597
+ null!,
598
+ () => {},
599
+ new PreConditionError(
600
+ "Expression: typeNameOrType",
601
+ "Expected: not undefined and not null",
602
+ "Actual: null",
603
+ ),
604
+ )
605
+ testTypeErrorTest(
606
+ "with empty typeNameOrType",
607
+ "",
608
+ () => {},
609
+ new PreConditionError(
610
+ "Expression: typeName",
611
+ "Expected: not empty",
612
+ "Actual: \"\"",
613
+ ),
614
+ )
615
+ testTypeErrorTest(
616
+ "with undefined testAction",
617
+ "abc",
618
+ undefined!,
619
+ new PreConditionError(
620
+ "Expression: testAction",
621
+ "Expected: not undefined and not null",
622
+ "Actual: undefined",
623
+ ),
624
+ )
625
+ testTypeErrorTest(
626
+ "with null testAction",
627
+ "abc",
628
+ null!,
629
+ new PreConditionError(
630
+ "Expression: testAction",
631
+ "Expected: not undefined and not null",
632
+ "Actual: null",
633
+ ),
634
+ )
635
+ });
636
+ });
637
+
638
+ runner.testFunction("testFunction()", () =>
639
+ {
640
+ runner.testGroup("with no skip", () =>
641
+ {
642
+ function testFunctionErrorTest(testName: string, functionSignature: string, testAction: () => void, expected: Error): void
643
+ {
644
+ runner.test(testName, (test: Test) =>
645
+ {
646
+ const runner2: TestRunner = creator();
647
+ test.assertThrows(() => runner2.testFunction(functionSignature, testAction), expected);
648
+ })
649
+ }
650
+
651
+ testFunctionErrorTest(
652
+ "with undefined functionSignature",
653
+ undefined!,
654
+ () => {},
655
+ new PreConditionError(
656
+ "Expression: functionSignature",
657
+ "Expected: not undefined and not null",
658
+ "Actual: undefined",
659
+ ),
660
+ )
661
+ testFunctionErrorTest(
662
+ "with null functionSignature",
663
+ null!,
664
+ () => {},
665
+ new PreConditionError(
666
+ "Expression: functionSignature",
667
+ "Expected: not undefined and not null",
668
+ "Actual: null",
669
+ ),
670
+ )
671
+ testFunctionErrorTest(
672
+ "with empty functionSignature",
673
+ "",
674
+ () => {},
675
+ new PreConditionError(
676
+ "Expression: functionSignature",
677
+ "Expected: not empty",
678
+ "Actual: \"\"",
679
+ ),
680
+ )
681
+ testFunctionErrorTest(
682
+ "with undefined testAction",
683
+ "abc",
684
+ undefined!,
685
+ new PreConditionError(
686
+ "Expression: testAction",
687
+ "Expected: not undefined and not null",
688
+ "Actual: undefined",
689
+ ),
690
+ )
691
+ testFunctionErrorTest(
692
+ "with null testAction",
693
+ "abc",
694
+ null!,
695
+ new PreConditionError(
696
+ "Expression: testAction",
697
+ "Expected: not undefined and not null",
698
+ "Actual: undefined",
699
+ ),
700
+ )
701
+ });
702
+
703
+ runner.testGroup("with undefined skip", () =>
704
+ {
705
+ function testFunctionErrorTest(testName: string, functionSignature: string, testAction: () => void, expected: Error): void
706
+ {
707
+ runner.test(testName, (test: Test) =>
708
+ {
709
+ const runner2: TestRunner = creator();
710
+ test.assertThrows(() => runner2.testFunction(functionSignature, undefined, testAction), expected);
711
+ })
712
+ }
713
+
714
+ testFunctionErrorTest(
715
+ "with undefined functionSignature",
716
+ undefined!,
717
+ () => {},
718
+ new PreConditionError(
719
+ "Expression: functionSignature",
720
+ "Expected: not undefined and not null",
721
+ "Actual: undefined",
722
+ ),
723
+ )
724
+ testFunctionErrorTest(
725
+ "with null functionSignature",
726
+ null!,
727
+ () => {},
728
+ new PreConditionError(
729
+ "Expression: functionSignature",
730
+ "Expected: not undefined and not null",
731
+ "Actual: null",
732
+ ),
733
+ )
734
+ testFunctionErrorTest(
735
+ "with empty functionSignature",
736
+ "",
737
+ () => {},
738
+ new PreConditionError(
739
+ "Expression: functionSignature",
740
+ "Expected: not empty",
741
+ "Actual: \"\"",
742
+ ),
743
+ )
744
+ testFunctionErrorTest(
745
+ "with undefined testAction",
746
+ "abc",
747
+ undefined!,
748
+ new PreConditionError(
749
+ "Expression: testAction",
750
+ "Expected: not undefined and not null",
751
+ "Actual: undefined",
752
+ ),
753
+ )
754
+ testFunctionErrorTest(
755
+ "with null testAction",
756
+ "abc",
757
+ null!,
758
+ new PreConditionError(
759
+ "Expression: testAction",
760
+ "Expected: not undefined and not null",
761
+ "Actual: null",
762
+ ),
763
+ )
764
+ });
765
+
766
+ runner.testGroup("with null skip", () =>
767
+ {
768
+ function testFunctionErrorTest(testName: string, functionSignature: string, testAction: () => void, expected: Error): void
769
+ {
770
+ runner.test(testName, (test: Test) =>
771
+ {
772
+ const runner2: TestRunner = creator();
773
+ test.assertThrows(() => runner2.testFunction(functionSignature, null!, testAction), expected);
774
+ })
775
+ }
776
+
777
+ testFunctionErrorTest(
778
+ "with undefined functionSignature",
779
+ undefined!,
780
+ () => {},
781
+ new PreConditionError(
782
+ "Expression: functionSignature",
783
+ "Expected: not undefined and not null",
784
+ "Actual: undefined",
785
+ ),
786
+ )
787
+ testFunctionErrorTest(
788
+ "with null functionSignature",
789
+ null!,
790
+ () => {},
791
+ new PreConditionError(
792
+ "Expression: functionSignature",
793
+ "Expected: not undefined and not null",
794
+ "Actual: null",
795
+ ),
796
+ )
797
+ testFunctionErrorTest(
798
+ "with empty functionSignature",
799
+ "",
800
+ () => {},
801
+ new PreConditionError(
802
+ "Expression: functionSignature",
803
+ "Expected: not empty",
804
+ "Actual: \"\"",
805
+ ),
806
+ )
807
+ testFunctionErrorTest(
808
+ "with undefined testAction",
809
+ "abc",
810
+ undefined!,
811
+ new PreConditionError(
812
+ "Expression: testAction",
813
+ "Expected: not undefined and not null",
814
+ "Actual: undefined",
815
+ ),
816
+ )
817
+ testFunctionErrorTest(
818
+ "with null testAction",
819
+ "abc",
820
+ null!,
821
+ new PreConditionError(
822
+ "Expression: testAction",
823
+ "Expected: not undefined and not null",
824
+ "Actual: null",
825
+ ),
826
+ )
827
+ });
828
+
829
+ runner.testGroup("with skip", () =>
830
+ {
831
+ function testFunctionErrorTest(testName: string, functionSignature: string, testAction: () => void, expected: Error): void
832
+ {
833
+ runner.test(testName, (test: Test) =>
834
+ {
835
+ const runner2: TestRunner = creator();
836
+ const skip: TestSkip = runner2.skip();
837
+ test.assertThrows(() => runner2.testFunction(functionSignature, skip, testAction), expected);
838
+ })
839
+ }
840
+
841
+ testFunctionErrorTest(
842
+ "with undefined functionSignature",
843
+ undefined!,
844
+ () => {},
845
+ new PreConditionError(
846
+ "Expression: functionSignature",
847
+ "Expected: not undefined and not null",
848
+ "Actual: undefined",
849
+ ),
850
+ )
851
+ testFunctionErrorTest(
852
+ "with null functionSignature",
853
+ null!,
854
+ () => {},
855
+ new PreConditionError(
856
+ "Expression: functionSignature",
857
+ "Expected: not undefined and not null",
858
+ "Actual: null",
859
+ ),
860
+ )
861
+ testFunctionErrorTest(
862
+ "with empty functionSignature",
863
+ "",
864
+ () => {},
865
+ new PreConditionError(
866
+ "Expression: functionSignature",
867
+ "Expected: not empty",
868
+ "Actual: \"\"",
869
+ ),
870
+ )
871
+ testFunctionErrorTest(
872
+ "with undefined testAction",
873
+ "abc",
874
+ undefined!,
875
+ new PreConditionError(
876
+ "Expression: testAction",
877
+ "Expected: not undefined and not null",
878
+ "Actual: undefined",
879
+ ),
880
+ )
881
+ testFunctionErrorTest(
882
+ "with null testAction",
883
+ "abc",
884
+ null!,
885
+ new PreConditionError(
886
+ "Expression: testAction",
887
+ "Expected: not undefined and not null",
888
+ "Actual: null",
889
+ ),
890
+ )
891
+ });
892
+ });
893
+ });
894
+ });
895
+ }