@everyonesoftware/common 2.0.0 → 4.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 (176) hide show
  1. package/outputs/chunk-AY3YWKOM.js +7741 -0
  2. package/outputs/chunk-AY3YWKOM.js.map +1 -0
  3. package/outputs/sources.cjs +9007 -0
  4. package/outputs/sources.cjs.map +1 -0
  5. package/outputs/sources.d.cts +4082 -0
  6. package/outputs/sources.d.ts +4082 -0
  7. package/outputs/sources.js +1370 -0
  8. package/outputs/sources.js.map +1 -0
  9. package/outputs/tests.cjs +17208 -0
  10. package/outputs/tests.cjs.map +1 -0
  11. package/outputs/tests.d.cts +3 -0
  12. package/outputs/tests.d.ts +3 -0
  13. package/outputs/tests.js +9798 -0
  14. package/outputs/tests.js.map +1 -0
  15. package/package.json +11 -2
  16. package/.c8rc.json +0 -12
  17. package/.github/workflows/publish.yml +0 -36
  18. package/.mocharc.json +0 -9
  19. package/sources/assertMessageParameters.ts +0 -22
  20. package/sources/asyncIterator.ts +0 -437
  21. package/sources/asyncIteratorToJavascriptAsyncIteratorAdapter.ts +0 -48
  22. package/sources/asyncResult.ts +0 -95
  23. package/sources/basicDisposable.ts +0 -57
  24. package/sources/byteList.ts +0 -202
  25. package/sources/byteListStream.ts +0 -121
  26. package/sources/byteReadStream.ts +0 -24
  27. package/sources/byteWriteStream.ts +0 -16
  28. package/sources/bytes.ts +0 -25
  29. package/sources/characterList.ts +0 -195
  30. package/sources/characterListStream.ts +0 -151
  31. package/sources/characterReadStream.ts +0 -81
  32. package/sources/characterReadStreamIterator.ts +0 -128
  33. package/sources/characterWriteStream.ts +0 -45
  34. package/sources/commandLineParameter.ts +0 -45
  35. package/sources/commandLineParameters.ts +0 -21
  36. package/sources/comparable.ts +0 -144
  37. package/sources/comparer.ts +0 -133
  38. package/sources/comparison.ts +0 -20
  39. package/sources/concatenateIterable.ts +0 -119
  40. package/sources/concatenateIterator.ts +0 -165
  41. package/sources/condition.ts +0 -329
  42. package/sources/currentProcess.ts +0 -158
  43. package/sources/dateTime.ts +0 -130
  44. package/sources/depthFirstSearch.ts +0 -230
  45. package/sources/disposable.ts +0 -31
  46. package/sources/emptyError.ts +0 -10
  47. package/sources/english.ts +0 -45
  48. package/sources/equalFunctions.ts +0 -123
  49. package/sources/fetchHttpClient.ts +0 -89
  50. package/sources/fetchHttpResponse.ts +0 -106
  51. package/sources/flatMapIterable.ts +0 -104
  52. package/sources/flatMapIterator.ts +0 -152
  53. package/sources/generator.ts +0 -251
  54. package/sources/httpClient.ts +0 -36
  55. package/sources/httpHeader.ts +0 -37
  56. package/sources/httpHeaders.ts +0 -216
  57. package/sources/httpIncomingRequest.ts +0 -30
  58. package/sources/httpIncomingResponse.ts +0 -19
  59. package/sources/httpMethod.ts +0 -164
  60. package/sources/httpOutgoingRequest.ts +0 -119
  61. package/sources/httpOutgoingResponse.ts +0 -113
  62. package/sources/httpServer.ts +0 -34
  63. package/sources/inMemoryCharacterWriteStream.ts +0 -78
  64. package/sources/index.ts +0 -101
  65. package/sources/iterable.ts +0 -345
  66. package/sources/iterator.ts +0 -481
  67. package/sources/iteratorToJavascriptIteratorAdapter.ts +0 -48
  68. package/sources/javascript.ts +0 -59
  69. package/sources/javascriptArrayList.ts +0 -175
  70. package/sources/javascriptAsyncIteratorToAsyncIteratorAdapter.ts +0 -124
  71. package/sources/javascriptIteratorToIteratorAdapter.ts +0 -133
  72. package/sources/javascriptMapMap.ts +0 -143
  73. package/sources/javascriptSetSet.ts +0 -134
  74. package/sources/list.ts +0 -330
  75. package/sources/listQueue.ts +0 -62
  76. package/sources/listStack.ts +0 -62
  77. package/sources/luxonDateTime.ts +0 -109
  78. package/sources/map.ts +0 -302
  79. package/sources/mapAsyncIterator.ts +0 -141
  80. package/sources/mapIterable.ts +0 -105
  81. package/sources/mapIterator.ts +0 -145
  82. package/sources/mutableCondition.ts +0 -451
  83. package/sources/mutableHttpHeaders.ts +0 -204
  84. package/sources/mutableMap.ts +0 -292
  85. package/sources/network.ts +0 -18
  86. package/sources/node.ts +0 -37
  87. package/sources/nodeJSCharacterWriteStream.ts +0 -42
  88. package/sources/nodeJSHttpIncomingRequest.ts +0 -132
  89. package/sources/nodeJSHttpServer.ts +0 -134
  90. package/sources/notFoundError.ts +0 -12
  91. package/sources/postCondition.ts +0 -284
  92. package/sources/postConditionError.ts +0 -12
  93. package/sources/preCondition.ts +0 -284
  94. package/sources/preConditionError.ts +0 -12
  95. package/sources/promiseAsyncResult.ts +0 -174
  96. package/sources/property.ts +0 -63
  97. package/sources/queue.ts +0 -49
  98. package/sources/realNetwork.ts +0 -28
  99. package/sources/recreationDotGovClient.ts +0 -259
  100. package/sources/searchControl.ts +0 -42
  101. package/sources/set.ts +0 -244
  102. package/sources/skipAsyncIterator.ts +0 -145
  103. package/sources/skipIterator.ts +0 -155
  104. package/sources/stack.ts +0 -48
  105. package/sources/stringComparer.ts +0 -33
  106. package/sources/stringIterator.ts +0 -149
  107. package/sources/strings.ts +0 -322
  108. package/sources/syncResult.ts +0 -300
  109. package/sources/takeAsyncIterator.ts +0 -141
  110. package/sources/takeIterator.ts +0 -151
  111. package/sources/toStringFunctions.ts +0 -185
  112. package/sources/types.ts +0 -371
  113. package/sources/whereAsyncIterator.ts +0 -143
  114. package/sources/whereIterable.ts +0 -108
  115. package/sources/whereIterator.ts +0 -157
  116. package/sources/wonderlandTrailClient.ts +0 -1503
  117. package/tests/assertTest.ts +0 -113
  118. package/tests/assertTestTests.ts +0 -75
  119. package/tests/basicTestSkip.ts +0 -51
  120. package/tests/byteListStreamTests.ts +0 -390
  121. package/tests/byteListTests.ts +0 -27
  122. package/tests/bytesTests.ts +0 -43
  123. package/tests/characterListStreamTests.ts +0 -391
  124. package/tests/characterListTests.ts +0 -250
  125. package/tests/characterWriteStreamTests.ts +0 -12
  126. package/tests/comparerTests.ts +0 -92
  127. package/tests/conditionTests.ts +0 -877
  128. package/tests/consoleTestRunner.ts +0 -404
  129. package/tests/consoleTestRunnerTests.ts +0 -651
  130. package/tests/dateTimeTests.ts +0 -30
  131. package/tests/depthFirstSearchTests.ts +0 -106
  132. package/tests/disposableTests.ts +0 -121
  133. package/tests/englishTests.ts +0 -103
  134. package/tests/equalFunctionsTests.ts +0 -223
  135. package/tests/failedTest.ts +0 -43
  136. package/tests/fetchHttpClientTests.ts +0 -33
  137. package/tests/generatorTests.ts +0 -86
  138. package/tests/httpClientTests.ts +0 -18
  139. package/tests/inMemoryCharacterWriteStreamTests.ts +0 -117
  140. package/tests/iterableTests.ts +0 -141
  141. package/tests/iteratorTests.ts +0 -1086
  142. package/tests/javascriptMapMapTests.ts +0 -21
  143. package/tests/listTests.ts +0 -338
  144. package/tests/mapIteratorTests.ts +0 -55
  145. package/tests/mapTests.ts +0 -104
  146. package/tests/mutableConditionTests.ts +0 -273
  147. package/tests/mutableMapTests.ts +0 -154
  148. package/tests/nodeJSHttpServerTests.ts +0 -75
  149. package/tests/notFoundErrorTests.ts +0 -24
  150. package/tests/postConditionErrorTests.ts +0 -24
  151. package/tests/preConditionErrorTests.ts +0 -24
  152. package/tests/promiseAsyncResultTests.ts +0 -688
  153. package/tests/propertyTests.ts +0 -63
  154. package/tests/queueTests.ts +0 -29
  155. package/tests/recreationDotGovClientTests.ts +0 -191
  156. package/tests/setTests.ts +0 -140
  157. package/tests/skippedTest.ts +0 -39
  158. package/tests/stackTests.ts +0 -66
  159. package/tests/stringComparerTests.ts +0 -60
  160. package/tests/stringIteratorTests.ts +0 -156
  161. package/tests/stringsTests.ts +0 -516
  162. package/tests/syncResultTests.ts +0 -1251
  163. package/tests/test.ts +0 -228
  164. package/tests/testAction.ts +0 -75
  165. package/tests/testActionTests.ts +0 -93
  166. package/tests/testFailureTests.ts +0 -12
  167. package/tests/testRunner.ts +0 -267
  168. package/tests/testRunnerTests.ts +0 -895
  169. package/tests/testSkip.ts +0 -34
  170. package/tests/tests.ts +0 -103
  171. package/tests/toStringFunctionsTests.ts +0 -55
  172. package/tests/typesTests.ts +0 -257
  173. package/tests/whereIteratorTests.ts +0 -77
  174. package/tests/wonderlandTrailClientTests.ts +0 -452
  175. package/tsconfig.json +0 -20
  176. package/tsup.config.ts +0 -13
package/tests/test.ts DELETED
@@ -1,228 +0,0 @@
1
- import { PromiseAsyncResult } from "../sources/promiseAsyncResult";
2
- import { PreCondition } from "../sources/preCondition";
3
- import { SyncResult } from "../sources/syncResult";
4
- import { isUndefinedOrNull, Type } from "../sources/types";
5
-
6
- /**
7
- * A type that can be used to make assertions during a test.
8
- */
9
- export abstract class Test
10
- {
11
- /**
12
- * Fail the current test with the provided message.
13
- * @param message The message that explains why this test failed.
14
- */
15
- public abstract fail(message: string): never;
16
-
17
- /**
18
- * Assert that the provided value is undefined;
19
- * @param value The value to check.
20
- */
21
- public assertUndefined(value: unknown): asserts value is undefined
22
- {
23
- Test.assertUndefined(this, value);
24
- }
25
-
26
- /**
27
- * Assert that the provided value is undefined.
28
- * @param test The current {@link Test}.
29
- * @param value The value to check.
30
- */
31
- public static assertUndefined(test: Test, value: unknown): asserts value is undefined
32
- {
33
- test.assertSame(value, undefined);
34
- }
35
-
36
- /**
37
- * Assert that the provided value is not undefined;
38
- * @param value The value to check.
39
- */
40
- public assertNotUndefined<T>(value: T): asserts value is NonNullable<T>
41
- {
42
- Test.assertNotUndefined(this, value);
43
- }
44
-
45
- /**
46
- * Assert that the provided value is not undefined.
47
- * @param test The current {@link Test}.
48
- * @param value The value to check.
49
- */
50
- public static assertNotUndefined<T>(test: Test, value: unknown): asserts value is NonNullable<T>
51
- {
52
- test.assertNotSame(value, undefined);
53
- }
54
-
55
- /**
56
- * Assert that the provided value is null.
57
- * @param value The value to check.
58
- */
59
- public assertNull(value: unknown): asserts value is null
60
- {
61
- Test.assertNull(this, value);
62
- }
63
-
64
- /**
65
- * Assert that the provided value is null.
66
- * @param value The value to check.
67
- */
68
- public static assertNull(test: Test, value: unknown): asserts value is null
69
- {
70
- test.assertSame(value, null);
71
- }
72
-
73
- /**
74
- * Assert that the provided value is not null.
75
- * @param value The value to check.
76
- */
77
- public assertNotNull<T>(value: T): asserts value is NonNullable<T>
78
- {
79
- Test.assertNull(this, value);
80
- }
81
-
82
- /**
83
- * Assert that the provided value is not null.
84
- * @param value The value to check.
85
- */
86
- public static assertNotNull<T>(test: Test, value: T): asserts value is NonNullable<T>
87
- {
88
- test.assertNotSame(value, null);
89
- }
90
-
91
- /**
92
- * Assert that the provided value is not undefined and not null.
93
- * @param value The value to check.
94
- */
95
- public assertNotUndefinedAndNotNull<T>(value: T): asserts value is NonNullable<T>
96
- {
97
- Test.assertNotUndefinedAndNotNull(this, value);
98
- }
99
-
100
- /**
101
- * Assert that the provided value is not undefined and not null.
102
- * @param value The value to check.
103
- */
104
- public static assertNotUndefinedAndNotNull<T>(test: Test, value: T): asserts value is NonNullable<T>
105
- {
106
- test.assertNotSame(value, null);
107
- test.assertNotSame(value, undefined);
108
- }
109
-
110
- /**
111
- * Assert that the provided values point to the same object.
112
- * @param left The first value.
113
- * @param right The second value.
114
- */
115
- public abstract assertSame<T>(left: T, right: T): void;
116
-
117
- /**
118
- * Assert that the provided values don't point to the same object.
119
- * @param left The first value.
120
- * @param right The second value.
121
- */
122
- public abstract assertNotSame<T>(left: T, right: T): void;
123
-
124
- /**
125
- * Assert that the provided values are equal.
126
- * @param left The first value.
127
- * @param right The second value.
128
- * @param message A message that will be shown when the values are not equal.
129
- */
130
- public abstract assertEqual<T>(left: T, right: T, message?: string): void;
131
-
132
- /**
133
- * Assert that the provided values are not equal.
134
- * @param left The first value.
135
- * @param right The second value.
136
- */
137
- public abstract assertNotEqual<T>(left: T, right: T): void;
138
-
139
- /**
140
- * Assert that the provided value is false.
141
- * @param value The value to check.
142
- */
143
- public assertFalse(value: boolean): asserts value is false
144
- {
145
- Test.assertFalse(this, value);
146
- }
147
-
148
- /**
149
- * Assert that the provided value is false.
150
- * @param value The value to check.
151
- */
152
- public static assertFalse(test: Test, value: boolean): asserts value is false
153
- {
154
- PreCondition.assertNotUndefinedAndNotNull(test, "test");
155
-
156
- test.assertSame(value, false);
157
- }
158
-
159
- /**
160
- * Assert that the provided value is true.
161
- * @param value The value to check.
162
- */
163
- public assertTrue(value: boolean): asserts value is true
164
- {
165
- Test.assertTrue(this, value);
166
- }
167
-
168
- /**
169
- * Assert that the provided value is true.
170
- * @param value The value to check.
171
- */
172
- public static assertTrue(test: Test, value: boolean): asserts value is true
173
- {
174
- PreCondition.assertNotUndefinedAndNotNull(test, "test");
175
-
176
- test.assertSame(value, true);
177
- }
178
-
179
- /**
180
- * Assert that the provided action throws the provided {@link Error} when it is run.
181
- * @param action The action to run.
182
- * @param expectedError The optional expected {@link Error} to compare against the thrown
183
- * {@link Error}. If the expected {@link Error} is not provided, then any {@link Error} will
184
- * satisfy this assertion.
185
- */
186
- public abstract assertThrows(action: SyncResult<unknown> | (() => void), expectedError?: Error): void;
187
-
188
- /**
189
- * Assert that the provided action throws the provided {@link Error} when it is run.
190
- * @param action The action to run.
191
- * @param expectedError The expected {@link Error}.
192
- */
193
- public abstract assertThrowsAsync(action: PromiseLike<unknown> | (() => PromiseLike<unknown>), expectedError: Error): PromiseAsyncResult<void>;
194
-
195
- /**
196
- * Assert that the provided value is an instance of the provided {@link Type}.
197
- * @param value The value to check.
198
- * @param type The {@link Type} to check.
199
- * @param expression The expression that produced the value.
200
- * @param message An optional error message.
201
- */
202
- public assertInstanceOf<T>(value: unknown, type: Type<T>, typeCheck?: (value: unknown) => value is T): asserts value is T
203
- {
204
- return Test.assertInstanceOf(this, value, type, typeCheck);
205
- }
206
-
207
- /**
208
- * Assert that the provided value is an instance of the provided {@link Type}.
209
- * @param value The value to check.
210
- * @param type The {@link Type} to check.
211
- * @param expression The expression that produced the value.
212
- * @param message An optional error message.
213
- */
214
- public static assertInstanceOf<T>(test: Test, value: unknown, type: Type<T>, typeCheck?: (value: unknown) => value is T): asserts value is T
215
- {
216
- PreCondition.assertNotUndefinedAndNotNull(type, "type");
217
-
218
- if (isUndefinedOrNull(typeCheck))
219
- {
220
- typeCheck = ((value: unknown) => value instanceof type) as (value: unknown) => value is T;
221
- }
222
-
223
- if (!typeCheck(value))
224
- {
225
- test.fail(`Expected value to be of type ${type.name} but found ${value} instead.`);
226
- }
227
- }
228
- }
@@ -1,75 +0,0 @@
1
- import { JavascriptIterable } from "../sources/javascript";
2
- import { List } from "../sources/list";
3
- import { PreCondition } from "../sources/preCondition";
4
- import { join } from "../sources/strings";
5
- import { TestSkip } from "./testSkip";
6
-
7
- export class TestAction
8
- {
9
- private readonly parent: TestAction | undefined;
10
- private readonly name: string;
11
- private readonly skip: TestSkip | undefined;
12
- private readonly action: () => (void | Promise<void>);
13
-
14
- private constructor(parent: TestAction | undefined, name: string, skip: TestSkip | undefined, action: () => (void | Promise<void>))
15
- {
16
- PreCondition.assertNotUndefinedAndNotNull(name, "name");
17
- PreCondition.assertNotUndefinedAndNotNull(action, "action");
18
-
19
- this.parent = parent;
20
- this.name = name;
21
- this.skip = skip;
22
- this.action = action;
23
- }
24
-
25
- public static create(parent: TestAction | undefined, name: string, skip: TestSkip | undefined, action: () => (void | Promise<void>)): TestAction
26
- {
27
- return new TestAction(parent, name, skip, action);
28
- }
29
-
30
- public getParent(): TestAction | undefined
31
- {
32
- return this.parent;
33
- }
34
-
35
- public getName(): string
36
- {
37
- return this.name;
38
- }
39
-
40
- public getFullNameParts(): JavascriptIterable<string>
41
- {
42
- const result: List<string> = List.create();
43
- if (this.parent)
44
- {
45
- result.addAll(this.parent.getFullNameParts());
46
- }
47
- result.add(this.getName());
48
- return result;
49
- }
50
-
51
- public getFullName(): string
52
- {
53
- return join(" ", this.getFullNameParts());
54
- }
55
-
56
- public getSkip(): TestSkip | undefined
57
- {
58
- return this.skip || this.parent?.getSkip();
59
- }
60
-
61
- public shouldSkip(): boolean
62
- {
63
- return !!this.getSkip()?.getShouldSkip();
64
- }
65
-
66
- public getAction(): () => (void | Promise<void>)
67
- {
68
- return this.action;
69
- }
70
-
71
- public runAsync(): void | Promise<void>
72
- {
73
- return this.action();
74
- }
75
- }
@@ -1,93 +0,0 @@
1
- import { PreConditionError } from "../sources/preConditionError";
2
- import { join } from "../sources/strings";
3
- import { Test } from "./test";
4
- import { TestAction } from "./testAction";
5
- import { TestRunner } from "./testRunner";
6
-
7
- export function test(runner: TestRunner): void
8
- {
9
- runner.testFile("testAction.ts", () =>
10
- {
11
- runner.testType("TestAction", () =>
12
- {
13
- runner.testFunction("create()", () =>
14
- {
15
- function createErrorTest(parent: TestAction | undefined, name: string, action: () => (void | Promise<void>), expected: Error): void
16
- {
17
- runner.test(`with ${!parent ? runner.toString(parent) : "defined parent"}, ${runner.toString(name)}, and ${!action ? runner.toString(action) : "defined action"}`, (test: Test) =>
18
- {
19
- test.assertThrows(() => TestAction.create(parent, name, undefined, action), expected);
20
- });
21
- }
22
-
23
- createErrorTest(
24
- undefined,
25
- undefined!,
26
- () => {},
27
- new PreConditionError(join("\n", [
28
- "Expression: name",
29
- "Expected: not undefined and not null",
30
- "Actual: undefined",
31
- ])),
32
- );
33
- createErrorTest(
34
- undefined,
35
- null!,
36
- () => {},
37
- new PreConditionError(join("\n", [
38
- "Expression: name",
39
- "Expected: not undefined and not null",
40
- "Actual: null",
41
- ])),
42
- );
43
- createErrorTest(
44
- undefined,
45
- "a",
46
- undefined!,
47
- new PreConditionError(join("\n", [
48
- "Expression: action",
49
- "Expected: not undefined and not null",
50
- "Actual: undefined",
51
- ])),
52
- );
53
- createErrorTest(
54
- undefined,
55
- "a",
56
- null!,
57
- new PreConditionError(join("\n", [
58
- "Expression: action",
59
- "Expected: not undefined and not null",
60
- "Actual: null",
61
- ])),
62
- );
63
-
64
- function createTest(parent: TestAction | undefined, name: string, action: () => (void | Promise<void>)): void
65
- {
66
- runner.test(`with ${!parent ? runner.toString(parent) : "defined parent"}, ${runner.toString(name)}, and ${!action ? runner.toString(action) : "defined action"}`, (test: Test) =>
67
- {
68
- const testAction: TestAction = TestAction.create(parent, name, undefined, action);
69
- test.assertNotUndefinedAndNotNull(testAction);
70
- test.assertSame(parent, testAction.getParent());
71
- test.assertSame(name, testAction.getName());
72
- test.assertSame(action, testAction.getAction());
73
- });
74
- }
75
-
76
- createTest(undefined, "b", () => {});
77
- });
78
-
79
- runner.testFunction("run()", (test: Test) =>
80
- {
81
- let counter: number = 0;
82
- const action: TestAction = TestAction.create(undefined, "c", undefined, () => { counter++; });
83
- test.assertEqual(0, counter);
84
-
85
- for (let i = 1; i <= 3; i++)
86
- {
87
- action.runAsync();
88
- test.assertEqual(i, counter);
89
- }
90
- });
91
- });
92
- });
93
- }
@@ -1,12 +0,0 @@
1
- import { TestRunner } from "./testRunner";
2
-
3
- export function test(runner: TestRunner): void
4
- {
5
- runner.testFile("testFailure.ts", () =>
6
- {
7
- runner.testType("TestFailure", () =>
8
- {
9
-
10
- });
11
- });
12
- }
@@ -1,267 +0,0 @@
1
- import { andList } from "../sources/english";
2
- import { Iterable } from "../sources/iterable";
3
- import { PreCondition } from "../sources/preCondition";
4
- import { ToStringFunctions } from "../sources/toStringFunctions";
5
- import {
6
- getName, getParameterCount, isBoolean, isFunction, isString, Type
7
- } from "../sources/types";
8
- import { Test } from "./test";
9
- import { TestSkip } from "./testSkip";
10
-
11
- /**
12
- * A type that can be used to run tests.
13
- */
14
- export abstract class TestRunner
15
- {
16
- /**
17
- * Get a {@link string} that concatenates the {@link string} representation of each
18
- * of the provided values into an "and-list".
19
- * @param values The values to concatenate.
20
- */
21
- public andList(values: unknown[] | Iterable<unknown>): string
22
- {
23
- return TestRunner.andList(this, values);
24
- }
25
-
26
- /**
27
- * Get a {@link string} that concatenates the {@link string} representation of each
28
- * of the provided values into an "and-list".
29
- * @param values The values to concatenate.
30
- */
31
- public static andList(runner: TestRunner, values: unknown[] | Iterable<unknown>): string
32
- {
33
- PreCondition.assertNotUndefinedAndNotNull(runner, "runner");
34
- PreCondition.assertNotUndefinedAndNotNull(values, "values");
35
-
36
- return andList(values.map((value: unknown) => runner.toString(value)));
37
- }
38
-
39
- /**
40
- * Get the {@link string} representation of the provided value.
41
- * @param value The value to get the {@link string} representation of.
42
- */
43
- public toString(value: unknown): string
44
- {
45
- return TestRunner.toString(this, value);
46
- }
47
-
48
- /**
49
- * Get the {@link string} representation of the provided value.
50
- * @param value The value to get the {@link string} representation of.
51
- */
52
- public static toString(_runner: TestRunner, value: unknown): string
53
- {
54
- const toStringFunctions: ToStringFunctions = ToStringFunctions.create();
55
- return toStringFunctions.toString(value);
56
- }
57
-
58
- public skip(message?: string): TestSkip;
59
- /**
60
- * Create a {@link TestSkip} object that will prevent tests from being run.
61
- * @param shouldSkip Whether these tests should be skipped.
62
- * @param message The message that explains why the tests are being skipped.
63
- */
64
- public skip(shouldSkip: boolean, message?: string): TestSkip;
65
- skip(messageOrShouldSkip?: string | boolean | undefined, message?: string): TestSkip
66
- {
67
- let shouldSkip: boolean;
68
- if (!isBoolean(messageOrShouldSkip))
69
- {
70
- shouldSkip = true;
71
- message = messageOrShouldSkip;
72
- }
73
- else
74
- {
75
- shouldSkip = messageOrShouldSkip;
76
- }
77
- return TestRunner.skip(this, shouldSkip, message);
78
- }
79
-
80
- /**
81
- * Create a {@link TestSkip} object that will prevent tests from being run.
82
- * @param shouldSkip Whether these tests should be skipped.
83
- * @param message The message that explains why the tests are being skipped.
84
- */
85
- public static skip(_runner: TestRunner, shouldSkip?: boolean, message?: string): TestSkip
86
- {
87
- return TestSkip.create(shouldSkip, message);
88
- }
89
-
90
- public static runTestAction(runner: TestRunner, name: string, skip: TestSkip | undefined, testAction: (() => void) | ((test: Test) => void)): void
91
- {
92
- if (getParameterCount(testAction) === 0)
93
- {
94
- runner.testGroup(name, skip, <() => void>testAction);
95
- }
96
- else
97
- {
98
- runner.test(name, skip, <(test: Test) => void>testAction);
99
- }
100
- }
101
-
102
- /**
103
- * Create a test group that will test the provided file.
104
- * @param fileName The name of the file that is being tested.
105
- * @param testAction The action that will run the tests.
106
- */
107
- public testFile(fileName: string, testAction: (() => void) | ((test: Test) => void)): void;
108
- /**
109
- * Create a test group that will test the provided file.
110
- * @param fileName The name of the file that is being tested.
111
- * @param skip A value that indicates whether these tests should be skipped.
112
- * @param testAction The action that will run the tests.
113
- */
114
- public testFile(fileName: string, skip: TestSkip | undefined, testAction: (() => void) | ((test: Test) => void)): void;
115
- testFile(fileName: string, skipOrTestAction: TestSkip | ((() => void) | ((test: Test) => void)) | undefined, testAction?: (() => void) | ((test: Test) => void)): void
116
- {
117
- TestRunner.testFile(this, fileName, skipOrTestAction, testAction);
118
- }
119
-
120
- /**
121
- * Create a test group that will test the provided file.
122
- * @param runner The {@link TestRunner} that will run the tests.
123
- * @param fileName The name of the file that is being tested.
124
- * @param testAction The action that will run the tests.
125
- */
126
- public static testFile(runner: TestRunner, fileName: string, skipOrTestAction: TestSkip | ((() => void) | ((test: Test) => void)) | undefined, testAction?: (() => void) | ((test: Test) => void)): void
127
- {
128
- PreCondition.assertNotUndefinedAndNotNull(runner, "runner");
129
- PreCondition.assertNotUndefinedAndNotNull(fileName, "fileName");
130
- PreCondition.assertNotEmpty(fileName, "fileName");
131
- let skip: TestSkip | undefined;
132
- if (isFunction(skipOrTestAction))
133
- {
134
- PreCondition.assertUndefined(testAction, "testAction");
135
-
136
- skip = undefined;
137
- testAction = skipOrTestAction;
138
- }
139
- else
140
- {
141
- skip = skipOrTestAction;
142
- }
143
- PreCondition.assertNotUndefinedAndNotNull(testAction, "testAction");
144
-
145
- TestRunner.runTestAction(runner, fileName, skip, testAction);
146
- }
147
-
148
- /**
149
- * Create a test group that will test the provided type.
150
- * @param type The {@link Type} or name of the type that is being tested.
151
- * @param testAction The action that will run the tests.
152
- */
153
- public testType(typeNameOrType: string | Type<unknown>, testAction: (() => void) | ((test: Test) => void)): void;
154
- /**
155
- * Create a test group that will test the provided type.
156
- * @param type The {@link Type} or name of the type that is being tested.
157
- * @param skip A value that indicates whether these tests should be skipped.
158
- * @param testAction The action that will run the tests.
159
- */
160
- public testType(typeNameOrType: string | Type<unknown>, skip: TestSkip | undefined, testAction: (() => void) | ((test: Test) => void)): void;
161
- testType(typeNameOrType: string | Type<unknown>, skipOrTestAction: TestSkip | undefined | ((() => void) | ((test: Test) => void)), testAction?: (() => void) | ((test: Test) => void)): void
162
- {
163
- TestRunner.testType(this, typeNameOrType, skipOrTestAction, testAction);
164
- }
165
-
166
- /**
167
- * Create a test group that will test the provided type.
168
- * @param runner The {@link TestRunner} that will run the tests.
169
- * @param type The {@link Type} or name of the type that is being tested.
170
- * @param testAction The action that will run the tests.
171
- */
172
- public static testType(runner: TestRunner, typeNameOrType: string | Type<unknown>, skipOrTestAction: TestSkip | undefined | ((() => void) | ((test: Test) => void)), testAction: ((() => void) | ((test: Test) => void)) | undefined): void
173
- {
174
- PreCondition.assertNotUndefinedAndNotNull(runner, "runner");
175
- PreCondition.assertNotUndefinedAndNotNull(typeNameOrType, "typeNameOrType");
176
- let typeName: string;
177
- if (isString(typeNameOrType))
178
- {
179
- typeName = typeNameOrType;
180
- }
181
- else
182
- {
183
- typeName = getName(typeNameOrType);
184
- }
185
- PreCondition.assertNotEmpty(typeName, "typeName");
186
- let skip: TestSkip | undefined;
187
- if (isFunction(skipOrTestAction))
188
- {
189
- PreCondition.assertUndefined(testAction, "testAction");
190
-
191
- skip = undefined;
192
- testAction = skipOrTestAction;
193
- }
194
- else
195
- {
196
- skip = skipOrTestAction;
197
- }
198
- PreCondition.assertNotUndefinedAndNotNull(testAction, "testAction");
199
-
200
- TestRunner.runTestAction(runner, typeName, skip, testAction);
201
- }
202
-
203
- /**
204
- * Create a test group that will test the provided function.
205
- * @param functionSignature The signature of the function that is being tested.
206
- * @param testAction The action that will run the tests.
207
- */
208
- public testFunction(functionSignature: string, testAction: (() => void) | ((test: Test) => void)): void;
209
- public testFunction(functionSignature: string, skip: TestSkip | undefined, testAction: (() => void) | ((test: Test) => void)): void;
210
- testFunction(functionSignature: string, skipOrTestAction: TestSkip | undefined | ((() => void) | ((test: Test) => void)), testAction?: (() => void) | ((test: Test) => void)): void
211
- {
212
- TestRunner.testFunction(this, functionSignature, skipOrTestAction, testAction);
213
- }
214
-
215
- /**
216
- * Create a test group that will test the provided function.
217
- * @param runner The {@link TestRunner} that will run the tests.
218
- * @param functionSignature The signature of the function that is being tested.
219
- * @param testAction The action that will run the tests.
220
- */
221
- public static testFunction(runner: TestRunner, functionSignature: string, skipOrTestAction: TestSkip | undefined | ((() => void) | ((test: Test) => void)), testAction: ((() => void) | ((test: Test) => void)) | undefined): void
222
- {
223
- PreCondition.assertNotUndefinedAndNotNull(runner, "runner");
224
- PreCondition.assertNotEmpty(functionSignature, "functionSignature");
225
- let skip: TestSkip | undefined;
226
- if (isFunction(skipOrTestAction))
227
- {
228
- PreCondition.assertUndefined(testAction, "testAction");
229
-
230
- skip = undefined;
231
- testAction = skipOrTestAction;
232
- }
233
- else
234
- {
235
- skip = skipOrTestAction;
236
- }
237
- PreCondition.assertNotUndefinedAndNotNull(testAction, "testAction");
238
-
239
- TestRunner.runTestAction(runner, functionSignature, skip, testAction);
240
- }
241
-
242
- /**
243
- * Create and run a test group with the provided name.
244
- * @param testGroupName The name of the test group to run.
245
- * @param testAction The action that runs the test group.
246
- */
247
- public abstract testGroup(testGroupName: string, testAction: () => void): void;
248
- /**
249
- * Create and run a test group with the provided name.
250
- * @param testGroupName The name of the test group to run.
251
- * @param testAction The action that runs the test group.
252
- */
253
- public abstract testGroup(testGroupName: string, skip: TestSkip | undefined, testAction: () => void): void;
254
-
255
- /**
256
- * Create and run a test with the provided name.
257
- * @param testName The name of the test to run.
258
- * @param testAction The action that runs the test.
259
- */
260
- public abstract test(testName: string, testAction: (test: Test) => void): void;
261
- /**
262
- * Create and run a test with the provided name.
263
- * @param testName The name of the test to run.
264
- * @param testAction The action that runs the test.
265
- */
266
- public abstract test(testName: string, skip: TestSkip | undefined, testAction: (test: Test) => void): void;
267
- }