@everyonesoftware/common 3.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.
- package/outputs/chunk-AY3YWKOM.js +7741 -0
- package/outputs/chunk-AY3YWKOM.js.map +1 -0
- package/outputs/sources.cjs +9007 -0
- package/outputs/sources.cjs.map +1 -0
- package/outputs/sources.d.cts +4082 -0
- package/outputs/sources.d.ts +4082 -0
- package/outputs/sources.js +1370 -0
- package/outputs/sources.js.map +1 -0
- package/outputs/tests.cjs +17208 -0
- package/outputs/tests.cjs.map +1 -0
- package/outputs/tests.d.cts +3 -0
- package/outputs/tests.d.ts +3 -0
- package/outputs/tests.js +9798 -0
- package/outputs/tests.js.map +1 -0
- package/package.json +6 -1
- package/.c8rc.json +0 -12
- package/.github/workflows/publish.yml +0 -54
- package/.mocharc.json +0 -9
- package/sources/assertMessageParameters.ts +0 -22
- package/sources/asyncIterator.ts +0 -437
- package/sources/asyncIteratorToJavascriptAsyncIteratorAdapter.ts +0 -48
- package/sources/asyncResult.ts +0 -95
- package/sources/basicDisposable.ts +0 -57
- package/sources/byteList.ts +0 -202
- package/sources/byteListStream.ts +0 -121
- package/sources/byteReadStream.ts +0 -24
- package/sources/byteWriteStream.ts +0 -16
- package/sources/bytes.ts +0 -25
- package/sources/characterList.ts +0 -195
- package/sources/characterListStream.ts +0 -151
- package/sources/characterReadStream.ts +0 -81
- package/sources/characterReadStreamIterator.ts +0 -128
- package/sources/characterWriteStream.ts +0 -45
- package/sources/commandLineParameter.ts +0 -45
- package/sources/commandLineParameters.ts +0 -21
- package/sources/comparable.ts +0 -144
- package/sources/comparer.ts +0 -133
- package/sources/comparison.ts +0 -20
- package/sources/concatenateIterable.ts +0 -119
- package/sources/concatenateIterator.ts +0 -165
- package/sources/condition.ts +0 -329
- package/sources/currentProcess.ts +0 -158
- package/sources/dateTime.ts +0 -130
- package/sources/depthFirstSearch.ts +0 -230
- package/sources/disposable.ts +0 -31
- package/sources/emptyError.ts +0 -10
- package/sources/english.ts +0 -45
- package/sources/equalFunctions.ts +0 -123
- package/sources/fetchHttpClient.ts +0 -89
- package/sources/fetchHttpResponse.ts +0 -106
- package/sources/flatMapIterable.ts +0 -104
- package/sources/flatMapIterator.ts +0 -152
- package/sources/generator.ts +0 -251
- package/sources/httpClient.ts +0 -36
- package/sources/httpHeader.ts +0 -37
- package/sources/httpHeaders.ts +0 -216
- package/sources/httpIncomingRequest.ts +0 -30
- package/sources/httpIncomingResponse.ts +0 -19
- package/sources/httpMethod.ts +0 -164
- package/sources/httpOutgoingRequest.ts +0 -119
- package/sources/httpOutgoingResponse.ts +0 -113
- package/sources/httpServer.ts +0 -34
- package/sources/inMemoryCharacterWriteStream.ts +0 -78
- package/sources/index.ts +0 -101
- package/sources/iterable.ts +0 -345
- package/sources/iterator.ts +0 -481
- package/sources/iteratorToJavascriptIteratorAdapter.ts +0 -48
- package/sources/javascript.ts +0 -59
- package/sources/javascriptArrayList.ts +0 -175
- package/sources/javascriptAsyncIteratorToAsyncIteratorAdapter.ts +0 -124
- package/sources/javascriptIteratorToIteratorAdapter.ts +0 -133
- package/sources/javascriptMapMap.ts +0 -143
- package/sources/javascriptSetSet.ts +0 -134
- package/sources/list.ts +0 -330
- package/sources/listQueue.ts +0 -62
- package/sources/listStack.ts +0 -62
- package/sources/luxonDateTime.ts +0 -109
- package/sources/map.ts +0 -302
- package/sources/mapAsyncIterator.ts +0 -141
- package/sources/mapIterable.ts +0 -105
- package/sources/mapIterator.ts +0 -145
- package/sources/mutableCondition.ts +0 -451
- package/sources/mutableHttpHeaders.ts +0 -204
- package/sources/mutableMap.ts +0 -292
- package/sources/network.ts +0 -18
- package/sources/node.ts +0 -37
- package/sources/nodeJSCharacterWriteStream.ts +0 -42
- package/sources/nodeJSHttpIncomingRequest.ts +0 -132
- package/sources/nodeJSHttpServer.ts +0 -134
- package/sources/notFoundError.ts +0 -12
- package/sources/postCondition.ts +0 -284
- package/sources/postConditionError.ts +0 -12
- package/sources/preCondition.ts +0 -284
- package/sources/preConditionError.ts +0 -12
- package/sources/promiseAsyncResult.ts +0 -174
- package/sources/property.ts +0 -63
- package/sources/queue.ts +0 -49
- package/sources/realNetwork.ts +0 -28
- package/sources/recreationDotGovClient.ts +0 -259
- package/sources/searchControl.ts +0 -42
- package/sources/set.ts +0 -244
- package/sources/skipAsyncIterator.ts +0 -145
- package/sources/skipIterator.ts +0 -155
- package/sources/stack.ts +0 -48
- package/sources/stringComparer.ts +0 -33
- package/sources/stringIterator.ts +0 -149
- package/sources/strings.ts +0 -322
- package/sources/syncResult.ts +0 -300
- package/sources/takeAsyncIterator.ts +0 -141
- package/sources/takeIterator.ts +0 -151
- package/sources/toStringFunctions.ts +0 -185
- package/sources/types.ts +0 -371
- package/sources/whereAsyncIterator.ts +0 -143
- package/sources/whereIterable.ts +0 -108
- package/sources/whereIterator.ts +0 -157
- package/sources/wonderlandTrailClient.ts +0 -1503
- package/tests/assertTest.ts +0 -113
- package/tests/assertTestTests.ts +0 -75
- package/tests/basicTestSkip.ts +0 -51
- package/tests/byteListStreamTests.ts +0 -390
- package/tests/byteListTests.ts +0 -27
- package/tests/bytesTests.ts +0 -43
- package/tests/characterListStreamTests.ts +0 -391
- package/tests/characterListTests.ts +0 -250
- package/tests/characterWriteStreamTests.ts +0 -12
- package/tests/comparerTests.ts +0 -92
- package/tests/conditionTests.ts +0 -877
- package/tests/consoleTestRunner.ts +0 -404
- package/tests/consoleTestRunnerTests.ts +0 -651
- package/tests/dateTimeTests.ts +0 -30
- package/tests/depthFirstSearchTests.ts +0 -106
- package/tests/disposableTests.ts +0 -121
- package/tests/englishTests.ts +0 -103
- package/tests/equalFunctionsTests.ts +0 -223
- package/tests/failedTest.ts +0 -43
- package/tests/fetchHttpClientTests.ts +0 -33
- package/tests/generatorTests.ts +0 -86
- package/tests/httpClientTests.ts +0 -18
- package/tests/inMemoryCharacterWriteStreamTests.ts +0 -117
- package/tests/iterableTests.ts +0 -141
- package/tests/iteratorTests.ts +0 -1086
- package/tests/javascriptMapMapTests.ts +0 -21
- package/tests/listTests.ts +0 -338
- package/tests/mapIteratorTests.ts +0 -55
- package/tests/mapTests.ts +0 -104
- package/tests/mutableConditionTests.ts +0 -273
- package/tests/mutableMapTests.ts +0 -154
- package/tests/nodeJSHttpServerTests.ts +0 -75
- package/tests/notFoundErrorTests.ts +0 -24
- package/tests/postConditionErrorTests.ts +0 -24
- package/tests/preConditionErrorTests.ts +0 -24
- package/tests/promiseAsyncResultTests.ts +0 -688
- package/tests/propertyTests.ts +0 -63
- package/tests/queueTests.ts +0 -29
- package/tests/recreationDotGovClientTests.ts +0 -191
- package/tests/setTests.ts +0 -140
- package/tests/skippedTest.ts +0 -39
- package/tests/stackTests.ts +0 -66
- package/tests/stringComparerTests.ts +0 -60
- package/tests/stringIteratorTests.ts +0 -156
- package/tests/stringsTests.ts +0 -516
- package/tests/syncResultTests.ts +0 -1251
- package/tests/test.ts +0 -228
- package/tests/testAction.ts +0 -75
- package/tests/testActionTests.ts +0 -93
- package/tests/testFailureTests.ts +0 -12
- package/tests/testRunner.ts +0 -267
- package/tests/testRunnerTests.ts +0 -895
- package/tests/testSkip.ts +0 -34
- package/tests/tests.ts +0 -103
- package/tests/toStringFunctionsTests.ts +0 -55
- package/tests/typesTests.ts +0 -257
- package/tests/whereIteratorTests.ts +0 -77
- package/tests/wonderlandTrailClientTests.ts +0 -452
- package/tsconfig.json +0 -20
- package/tsup.config.ts +0 -13
|
@@ -1,273 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import { EqualFunctions } from "../sources/equalFunctions";
|
|
4
|
-
import { MutableCondition } from "../sources/mutableCondition";
|
|
5
|
-
import { PreConditionError } from "../sources/preConditionError";
|
|
6
|
-
import { join } from "../sources/strings";
|
|
7
|
-
import { ToStringFunctions } from "../sources/toStringFunctions";
|
|
8
|
-
import { isNumber, isString } from "../sources/types";
|
|
9
|
-
import { Test } from "./test";
|
|
10
|
-
import { TestRunner } from "./testRunner";
|
|
11
|
-
|
|
12
|
-
export function test(runner: TestRunner): void
|
|
13
|
-
{
|
|
14
|
-
runner.testFile("mutableCondition.ts", () =>
|
|
15
|
-
{
|
|
16
|
-
runner.testType("MutableCondition", () =>
|
|
17
|
-
{
|
|
18
|
-
runner.testFunction("create()", (test: Test) =>
|
|
19
|
-
{
|
|
20
|
-
const mc: MutableCondition = MutableCondition.create();
|
|
21
|
-
test.assertNotUndefinedAndNotNull(mc);
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
runner.testFunction("setToStringFunctions()", () =>
|
|
25
|
-
{
|
|
26
|
-
function setToStringFunctionsErrorTest(testName: string, toStringFunctions: ToStringFunctions, expected: Error): void
|
|
27
|
-
{
|
|
28
|
-
runner.test(testName, (test: Test) =>
|
|
29
|
-
{
|
|
30
|
-
const mc: MutableCondition = MutableCondition.create();
|
|
31
|
-
test.assertThrows(() => mc.setToStringFunctions(toStringFunctions), expected);
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
setToStringFunctionsErrorTest("with undefined", undefined!, new PreConditionError(
|
|
36
|
-
"Expression: toStringFunctions",
|
|
37
|
-
"Expected: not undefined and not null",
|
|
38
|
-
"Actual: undefined",
|
|
39
|
-
));
|
|
40
|
-
setToStringFunctionsErrorTest("with null", null!, new PreConditionError(
|
|
41
|
-
"Expression: toStringFunctions",
|
|
42
|
-
"Expected: not undefined and not null",
|
|
43
|
-
"Actual: null",
|
|
44
|
-
));
|
|
45
|
-
|
|
46
|
-
runner.test("with valid value", (test: Test) =>
|
|
47
|
-
{
|
|
48
|
-
const mc: MutableCondition = MutableCondition.create();
|
|
49
|
-
test.assertEqual(`"hello"`, mc.toValueString("hello"));
|
|
50
|
-
|
|
51
|
-
mc.setToStringFunctions(
|
|
52
|
-
ToStringFunctions.create()
|
|
53
|
-
.add(isString, (value: string) => `---${value}---`),
|
|
54
|
-
);
|
|
55
|
-
test.assertEqual(`---hello---`, mc.toValueString("hello"));
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
runner.testFunction("setEqualFunctions()", () =>
|
|
60
|
-
{
|
|
61
|
-
function setEqualFunctionsErrorTest(testName: string, equalFunctions: EqualFunctions, expected: Error): void
|
|
62
|
-
{
|
|
63
|
-
runner.test(testName, (test: Test) =>
|
|
64
|
-
{
|
|
65
|
-
const mc: MutableCondition = MutableCondition.create();
|
|
66
|
-
test.assertThrows(() => mc.setEqualFunctions(equalFunctions), expected);
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
setEqualFunctionsErrorTest("with undefined", undefined!, new PreConditionError(
|
|
71
|
-
"Expression: equalFunctions",
|
|
72
|
-
"Expected: not undefined and not null",
|
|
73
|
-
"Actual: undefined",
|
|
74
|
-
));
|
|
75
|
-
setEqualFunctionsErrorTest("with null", null!, new PreConditionError(
|
|
76
|
-
"Expression: equalFunctions",
|
|
77
|
-
"Expected: not undefined and not null",
|
|
78
|
-
"Actual: null",
|
|
79
|
-
));
|
|
80
|
-
|
|
81
|
-
runner.test("with valid value", (test: Test) =>
|
|
82
|
-
{
|
|
83
|
-
const mc: MutableCondition = MutableCondition.create();
|
|
84
|
-
test.assertFalse(mc.areEqual(3, 5));
|
|
85
|
-
test.assertFalse(mc.areEqual(3, 4));
|
|
86
|
-
test.assertTrue(mc.areEqual(4, 4));
|
|
87
|
-
|
|
88
|
-
mc.setEqualFunctions(
|
|
89
|
-
EqualFunctions.create()
|
|
90
|
-
.add((left: unknown, right: unknown) =>
|
|
91
|
-
{
|
|
92
|
-
return isNumber(left) && isNumber(right)
|
|
93
|
-
? left % 2 === right % 2
|
|
94
|
-
: undefined;
|
|
95
|
-
})
|
|
96
|
-
)
|
|
97
|
-
|
|
98
|
-
test.assertTrue(mc.areEqual(3, 5));
|
|
99
|
-
test.assertFalse(mc.areEqual(3, 4));
|
|
100
|
-
test.assertTrue(mc.areEqual(4, 4));
|
|
101
|
-
});
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
runner.testFunction("setCreateErrorFunction()", () =>
|
|
105
|
-
{
|
|
106
|
-
function setCreateErrorFunctionErrorTest(testName: string, createErrorFunction: ((message: string) => Error), expected: Error): void
|
|
107
|
-
{
|
|
108
|
-
runner.test(testName, (test: Test) =>
|
|
109
|
-
{
|
|
110
|
-
const mc: MutableCondition = MutableCondition.create();
|
|
111
|
-
test.assertThrows(() => mc.setCreateErrorFunction(createErrorFunction), expected);
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
setCreateErrorFunctionErrorTest("with undefined", undefined!, new PreConditionError(
|
|
116
|
-
"Expression: createErrorFunction",
|
|
117
|
-
"Expected: not undefined and not null",
|
|
118
|
-
"Actual: undefined",
|
|
119
|
-
));
|
|
120
|
-
setCreateErrorFunctionErrorTest("with null", null!, new PreConditionError(
|
|
121
|
-
"Expression: createErrorFunction",
|
|
122
|
-
"Expected: not undefined and not null",
|
|
123
|
-
"Actual: null",
|
|
124
|
-
));
|
|
125
|
-
|
|
126
|
-
runner.test("with valid function", (test: Test) =>
|
|
127
|
-
{
|
|
128
|
-
const mc: MutableCondition = MutableCondition.create();
|
|
129
|
-
test.assertThrows(() => mc.assertEqual(1, 2));
|
|
130
|
-
|
|
131
|
-
mc.setCreateErrorFunction((message: string) =>
|
|
132
|
-
{
|
|
133
|
-
return Error(`fake '${message}' fake`);
|
|
134
|
-
});
|
|
135
|
-
|
|
136
|
-
mc.setEqualFunctions(
|
|
137
|
-
EqualFunctions.create()
|
|
138
|
-
.add((left: unknown, right: unknown) =>
|
|
139
|
-
{
|
|
140
|
-
return isNumber(left) && isNumber(right)
|
|
141
|
-
? left % 2 === right % 2
|
|
142
|
-
: undefined;
|
|
143
|
-
})
|
|
144
|
-
)
|
|
145
|
-
|
|
146
|
-
test.assertTrue(mc.areEqual(3, 5));
|
|
147
|
-
test.assertFalse(mc.areEqual(3, 4));
|
|
148
|
-
test.assertTrue(mc.areEqual(4, 4));
|
|
149
|
-
});
|
|
150
|
-
});
|
|
151
|
-
|
|
152
|
-
runner.testFunction("assertUndefined()", () =>
|
|
153
|
-
{
|
|
154
|
-
runner.test("with undefined", (test: Test) =>
|
|
155
|
-
{
|
|
156
|
-
const mc: MutableCondition = MutableCondition.create();
|
|
157
|
-
mc.assertUndefined(undefined);
|
|
158
|
-
});
|
|
159
|
-
|
|
160
|
-
function assertUndefinedErrorTest(value: unknown, expected: Error): void
|
|
161
|
-
{
|
|
162
|
-
runner.test(`with ${runner.toString(value)}`, (test: Test) =>
|
|
163
|
-
{
|
|
164
|
-
const mc: MutableCondition = MutableCondition.create();
|
|
165
|
-
test.assertThrows(() => mc.assertUndefined(value), expected);
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
|
|
169
|
-
assertUndefinedErrorTest(null, new Error(join("\n", [
|
|
170
|
-
"Expected: undefined",
|
|
171
|
-
"Actual: null",
|
|
172
|
-
])));
|
|
173
|
-
assertUndefinedErrorTest(false, new Error(join("\n", [
|
|
174
|
-
"Expected: undefined",
|
|
175
|
-
"Actual: false",
|
|
176
|
-
])));
|
|
177
|
-
assertUndefinedErrorTest("abc", new Error(join("\n", [
|
|
178
|
-
"Expected: undefined",
|
|
179
|
-
"Actual: \"abc\"",
|
|
180
|
-
])));
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
runner.testFunction("assertNotUndefined()", () =>
|
|
184
|
-
{
|
|
185
|
-
runner.test("with undefined", (test: Test) =>
|
|
186
|
-
{
|
|
187
|
-
const mc: MutableCondition = MutableCondition.create();
|
|
188
|
-
test.assertThrows(
|
|
189
|
-
() => mc.assertNotUndefined(undefined),
|
|
190
|
-
new Error(join("\n", [
|
|
191
|
-
"Expected: not undefined",
|
|
192
|
-
"Actual: undefined",
|
|
193
|
-
])),
|
|
194
|
-
);
|
|
195
|
-
});
|
|
196
|
-
|
|
197
|
-
function assertNotUndefinedTest(value: unknown): void
|
|
198
|
-
{
|
|
199
|
-
runner.test(`with ${runner.toString(value)}`, (test: Test) =>
|
|
200
|
-
{
|
|
201
|
-
const mc: MutableCondition = MutableCondition.create();
|
|
202
|
-
mc.assertNotUndefined(value);
|
|
203
|
-
});
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
assertNotUndefinedTest(null);
|
|
207
|
-
assertNotUndefinedTest("");
|
|
208
|
-
assertNotUndefinedTest(false);
|
|
209
|
-
});
|
|
210
|
-
|
|
211
|
-
runner.testFunction("areEqual()", () =>
|
|
212
|
-
{
|
|
213
|
-
function areEqualTest(left: unknown, right: unknown, expected: boolean): void
|
|
214
|
-
{
|
|
215
|
-
runner.test(`with ${runner.andList([left, right])}`, (test: Test) =>
|
|
216
|
-
{
|
|
217
|
-
const mc: MutableCondition = MutableCondition.create();
|
|
218
|
-
test.assertEqual(mc.areEqual(left, right), expected);
|
|
219
|
-
});
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
areEqualTest(undefined, undefined, true);
|
|
223
|
-
areEqualTest(5, 5, true);
|
|
224
|
-
areEqualTest(true, true, true);
|
|
225
|
-
areEqualTest({}, {}, true);
|
|
226
|
-
|
|
227
|
-
areEqualTest(undefined, "", false);
|
|
228
|
-
areEqualTest(1, 2, false);
|
|
229
|
-
areEqualTest(false, true, false);
|
|
230
|
-
areEqualTest({a:1}, {a:2}, false);
|
|
231
|
-
});
|
|
232
|
-
|
|
233
|
-
runner.testFunction("toValueString()", () =>
|
|
234
|
-
{
|
|
235
|
-
function toValueStringTest(value: unknown, expected: string): void
|
|
236
|
-
{
|
|
237
|
-
runner.test(`with ${runner.toString(value)}`, (test: Test) =>
|
|
238
|
-
{
|
|
239
|
-
const mc: MutableCondition = MutableCondition.create();
|
|
240
|
-
test.assertEqual(expected, mc.toValueString(value));
|
|
241
|
-
});
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
toValueStringTest(undefined, "undefined");
|
|
245
|
-
toValueStringTest(null, "null");
|
|
246
|
-
toValueStringTest(0, "0");
|
|
247
|
-
toValueStringTest("abc", `"abc"`);
|
|
248
|
-
toValueStringTest({}, "{}");
|
|
249
|
-
toValueStringTest({a:"a"}, `{"a":"a"}`);
|
|
250
|
-
});
|
|
251
|
-
|
|
252
|
-
runner.testFunction("createError()", () =>
|
|
253
|
-
{
|
|
254
|
-
runner.test("with all properties", (test: Test) =>
|
|
255
|
-
{
|
|
256
|
-
const mc: MutableCondition = MutableCondition.create();
|
|
257
|
-
const error: Error = mc.createError({
|
|
258
|
-
actual: "fake-actual",
|
|
259
|
-
expected: "fake-expected",
|
|
260
|
-
expression: "fake-expression",
|
|
261
|
-
message: "fake-message",
|
|
262
|
-
});
|
|
263
|
-
test.assertEqual(error, new Error(join("\n", [
|
|
264
|
-
"Message: fake-message",
|
|
265
|
-
"Expression: fake-expression",
|
|
266
|
-
"Expected: fake-expected",
|
|
267
|
-
"Actual: fake-actual",
|
|
268
|
-
])));
|
|
269
|
-
});
|
|
270
|
-
});
|
|
271
|
-
});
|
|
272
|
-
});
|
|
273
|
-
}
|
package/tests/mutableMapTests.ts
DELETED
|
@@ -1,154 +0,0 @@
|
|
|
1
|
-
import { Iterator } from "../sources/iterator";
|
|
2
|
-
import { JavascriptIterable } from "../sources/javascript";
|
|
3
|
-
import { isMap } from "../sources/map";
|
|
4
|
-
import { MutableMap } from "../sources/mutableMap";
|
|
5
|
-
import { NotFoundError } from "../sources/notFoundError";
|
|
6
|
-
import { mapTests } from "./mapTests";
|
|
7
|
-
import { Test } from "./test";
|
|
8
|
-
import { TestRunner } from "./testRunner";
|
|
9
|
-
|
|
10
|
-
export function test(runner: TestRunner): void
|
|
11
|
-
{
|
|
12
|
-
runner.testFile("mutableMap.ts", () =>
|
|
13
|
-
{
|
|
14
|
-
runner.testType("MutableMap<TKey,TValue>", () =>
|
|
15
|
-
{
|
|
16
|
-
runner.testFunction("create()", (test: Test) =>
|
|
17
|
-
{
|
|
18
|
-
const map: MutableMap<number,string> = MutableMap.create();
|
|
19
|
-
test.assertSame(map.getCount().await(), 0);
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
mutableMapTests(runner, MutableMap.create);
|
|
23
|
-
});
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export function mutableMapTests(runner: TestRunner, creator: () => MutableMap<number,string>): void
|
|
28
|
-
{
|
|
29
|
-
runner.testType("MutableMap<TKey,TValue>", () =>
|
|
30
|
-
{
|
|
31
|
-
mapTests(runner, creator);
|
|
32
|
-
|
|
33
|
-
runner.testFunction("creator()", (test: Test) =>
|
|
34
|
-
{
|
|
35
|
-
test.assertNotUndefinedAndNotNull(creator);
|
|
36
|
-
|
|
37
|
-
const map: MutableMap<number,string> = creator();
|
|
38
|
-
test.assertNotUndefinedAndNotNull(map);
|
|
39
|
-
test.assertEqual(map.getCount().await(), 0);
|
|
40
|
-
test.assertTrue(isMap(map));
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
runner.testFunction("containsKey(TKey)", () =>
|
|
44
|
-
{
|
|
45
|
-
runner.test("when it doesn't contain the key", (test: Test) =>
|
|
46
|
-
{
|
|
47
|
-
const map: MutableMap<number,string> = creator();
|
|
48
|
-
|
|
49
|
-
test.assertFalse(map.containsKey(50).await());
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
runner.test("when it contains the key", (test: Test) =>
|
|
53
|
-
{
|
|
54
|
-
const map: MutableMap<number,string> = creator().set(50, "fifty");
|
|
55
|
-
|
|
56
|
-
test.assertTrue(map.containsKey(50).await());
|
|
57
|
-
});
|
|
58
|
-
});
|
|
59
|
-
|
|
60
|
-
runner.testFunction("get(TKey)", () =>
|
|
61
|
-
{
|
|
62
|
-
runner.test("when it contains the key", (test: Test) =>
|
|
63
|
-
{
|
|
64
|
-
const map: MutableMap<number,string> = creator().set(1, "one");
|
|
65
|
-
test.assertEqual(map.getCount().await(), 1);
|
|
66
|
-
test.assertEqual(map.get(1).await(), "one");
|
|
67
|
-
test.assertEqual(map.getCount().await(), 1);
|
|
68
|
-
});
|
|
69
|
-
|
|
70
|
-
runner.test("when it doesn't contain the key", (test: Test) =>
|
|
71
|
-
{
|
|
72
|
-
const map: MutableMap<number,string> = creator();
|
|
73
|
-
|
|
74
|
-
test.assertThrows(() => map.get(1).await(),
|
|
75
|
-
new NotFoundError(
|
|
76
|
-
"The key 1 was not found in the map."));
|
|
77
|
-
test.assertEqual(map.getCount().await(), 0);
|
|
78
|
-
});
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
runner.testFunction("set(TKey,TValue)", () =>
|
|
82
|
-
{
|
|
83
|
-
function setTest(map: MutableMap<number,string>, key: number, value: string): void
|
|
84
|
-
{
|
|
85
|
-
runner.test(`with ${runner.andList([map, key, value])}`, (test: Test) =>
|
|
86
|
-
{
|
|
87
|
-
const setResult: MutableMap<number,string> = map.set(key, value);
|
|
88
|
-
test.assertSame(setResult, map);
|
|
89
|
-
test.assertSame(map.get(key).await(), value);
|
|
90
|
-
});
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
setTest(creator(), 0, "zero");
|
|
94
|
-
setTest(creator(), 1, "1");
|
|
95
|
-
setTest(creator(), -1, "negative one");
|
|
96
|
-
|
|
97
|
-
setTest(creator(), undefined!, "hello");
|
|
98
|
-
setTest(creator(), null!, "oops");
|
|
99
|
-
setTest(creator(), 10, undefined!);
|
|
100
|
-
setTest(creator(), 11, null!);
|
|
101
|
-
|
|
102
|
-
setTest(creator().set(1, "1"), 1, "one");
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
runner.testFunction("toString()", () =>
|
|
106
|
-
{
|
|
107
|
-
function toStringTest(map: MutableMap<number,string>, expected: string): void
|
|
108
|
-
{
|
|
109
|
-
runner.test(`with ${runner.toString(map)}`, (test: Test) =>
|
|
110
|
-
{
|
|
111
|
-
test.assertEqual(map.toString(), expected);
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
toStringTest(creator(), "{}");
|
|
116
|
-
toStringTest(creator().set(1, "one"), `{1:"one"}`);
|
|
117
|
-
toStringTest(creator().set(2, "2").set(1, "one"), `{2:"2",1:"one"}`);
|
|
118
|
-
});
|
|
119
|
-
|
|
120
|
-
runner.testFunction("iterateKeys()", () =>
|
|
121
|
-
{
|
|
122
|
-
function iterateKeysTests(map: MutableMap<number,string>, expected: JavascriptIterable<number>): void
|
|
123
|
-
{
|
|
124
|
-
runner.test(`with ${runner.toString(map)}`, async (test: Test) =>
|
|
125
|
-
{
|
|
126
|
-
const keyIterator: Iterator<number> = map.iterateKeys();
|
|
127
|
-
test.assertEqual(await keyIterator.toArray(), [...expected]);
|
|
128
|
-
});
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
iterateKeysTests(creator(), []);
|
|
132
|
-
iterateKeysTests(creator().set(5, "five"), [5]);
|
|
133
|
-
iterateKeysTests(creator().set(5, "five").set(6, "six"), [5, 6]);
|
|
134
|
-
iterateKeysTests(creator().set(5, "5").set(6, "6").set(7, "7"), [5, 6, 7]);
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
runner.testFunction("iterateValues()", () =>
|
|
138
|
-
{
|
|
139
|
-
function iterateValuesTests(map: MutableMap<number,string>, expected: JavascriptIterable<string>): void
|
|
140
|
-
{
|
|
141
|
-
runner.test(`with ${runner.toString(map)}`, async (test: Test) =>
|
|
142
|
-
{
|
|
143
|
-
const valueIterator: Iterator<string> = map.iterateValues();
|
|
144
|
-
test.assertEqual(await valueIterator.toArray(), [...expected]);
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
iterateValuesTests(creator(), []);
|
|
149
|
-
iterateValuesTests(creator().set(5, "five"), ["five"]);
|
|
150
|
-
iterateValuesTests(creator().set(5, "five").set(6, "six"), ["five", "six"]);
|
|
151
|
-
iterateValuesTests(creator().set(5, "5").set(6, "6").set(7, "7"), ["5", "6", "7"]);
|
|
152
|
-
});
|
|
153
|
-
});
|
|
154
|
-
}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { FetchHttpClient } from "../sources/fetchHttpClient";
|
|
2
|
-
import { FetchHttpIncomingResponse } from "../sources/fetchHttpResponse";
|
|
3
|
-
import { NodeJSHttpServer as NodeJSHttpServer } from "../sources/nodeJSHttpServer";
|
|
4
|
-
import { PreConditionError } from "../sources/preConditionError";
|
|
5
|
-
import { Test } from "./test";
|
|
6
|
-
import { TestRunner } from "./testRunner";
|
|
7
|
-
|
|
8
|
-
export function test(runner: TestRunner): void
|
|
9
|
-
{
|
|
10
|
-
runner.testFile("nodeJSHttpServer.ts", () =>
|
|
11
|
-
{
|
|
12
|
-
runner.testType("NodeJSHttpServer", () =>
|
|
13
|
-
{
|
|
14
|
-
runner.testFunction("create()", (test: Test) =>
|
|
15
|
-
{
|
|
16
|
-
const httpServer: NodeJSHttpServer = NodeJSHttpServer.create();
|
|
17
|
-
test.assertNotUndefinedAndNotNull(httpServer);
|
|
18
|
-
test.assertFalse(httpServer.isDisposed());
|
|
19
|
-
test.assertFalse(httpServer.isStarted());
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
runner.testFunction("dispose()", async (test: Test) =>
|
|
23
|
-
{
|
|
24
|
-
const httpServer: NodeJSHttpServer = NodeJSHttpServer.create();
|
|
25
|
-
|
|
26
|
-
test.assertTrue(await httpServer.dispose());
|
|
27
|
-
test.assertTrue(httpServer.isDisposed());
|
|
28
|
-
test.assertFalse(httpServer.isStarted());
|
|
29
|
-
|
|
30
|
-
for (let i = 0; i < 3; i++)
|
|
31
|
-
{
|
|
32
|
-
test.assertFalse(await httpServer.dispose());
|
|
33
|
-
test.assertTrue(httpServer.isDisposed());
|
|
34
|
-
test.assertFalse(httpServer.isStarted());
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
runner.testFunction("start()", () =>
|
|
39
|
-
{
|
|
40
|
-
runner.test("when disposed", async (test: Test) =>
|
|
41
|
-
{
|
|
42
|
-
const httpServer: NodeJSHttpServer = NodeJSHttpServer.create();
|
|
43
|
-
test.assertTrue(await httpServer.dispose());
|
|
44
|
-
|
|
45
|
-
test.assertThrows(() => httpServer.start(3000), new PreConditionError(
|
|
46
|
-
"Expression: this.isDisposed()",
|
|
47
|
-
"Expected: false",
|
|
48
|
-
"Actual: true",
|
|
49
|
-
));
|
|
50
|
-
test.assertTrue(httpServer.isDisposed());
|
|
51
|
-
test.assertFalse(httpServer.isStarted());
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
runner.test("simple scenario", async (test: Test) =>
|
|
55
|
-
{
|
|
56
|
-
const httpServer: NodeJSHttpServer = NodeJSHttpServer.create();
|
|
57
|
-
|
|
58
|
-
httpServer.start(3000);
|
|
59
|
-
try
|
|
60
|
-
{
|
|
61
|
-
const httpClient: FetchHttpClient = FetchHttpClient.create();
|
|
62
|
-
const response: FetchHttpIncomingResponse = await httpClient.sendGetRequest("http://localhost:3000");
|
|
63
|
-
|
|
64
|
-
test.assertNotUndefinedAndNotNull(response);
|
|
65
|
-
test.assertEqual(200, response.getStatusCode());
|
|
66
|
-
}
|
|
67
|
-
finally
|
|
68
|
-
{
|
|
69
|
-
await httpServer.dispose();
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
});
|
|
73
|
-
});
|
|
74
|
-
});
|
|
75
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { NotFoundError } from "../sources/notFoundError";
|
|
2
|
-
import { Test } from "./test";
|
|
3
|
-
import { TestRunner } from "./testRunner";
|
|
4
|
-
|
|
5
|
-
export function test(runner: TestRunner): void
|
|
6
|
-
{
|
|
7
|
-
runner.testFile("notFoundError.ts", () =>
|
|
8
|
-
{
|
|
9
|
-
runner.testType("NotFoundError", () =>
|
|
10
|
-
{
|
|
11
|
-
runner.testFunction("constructor(...string[])", () =>
|
|
12
|
-
{
|
|
13
|
-
runner.test("with no arguments", (test: Test) =>
|
|
14
|
-
{
|
|
15
|
-
const error: NotFoundError = new NotFoundError();
|
|
16
|
-
test.assertNotUndefinedAndNotNull(error);
|
|
17
|
-
test.assertEqual(error.name, "Error");
|
|
18
|
-
test.assertEqual(error.message, "");
|
|
19
|
-
test.assertNotUndefinedAndNotNull(error.stack);
|
|
20
|
-
});
|
|
21
|
-
});
|
|
22
|
-
});
|
|
23
|
-
});
|
|
24
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { PostConditionError } from "../sources/postConditionError";
|
|
2
|
-
import { Test } from "./test";
|
|
3
|
-
import { TestRunner } from "./testRunner";
|
|
4
|
-
|
|
5
|
-
export function test(runner: TestRunner): void
|
|
6
|
-
{
|
|
7
|
-
runner.testFile("postConditionError.ts", () =>
|
|
8
|
-
{
|
|
9
|
-
runner.testType(PostConditionError.name, () =>
|
|
10
|
-
{
|
|
11
|
-
runner.testFunction("constructor(string|undefined)", () =>
|
|
12
|
-
{
|
|
13
|
-
runner.test("with no arguments", (test: Test) =>
|
|
14
|
-
{
|
|
15
|
-
const error: PostConditionError = new PostConditionError();
|
|
16
|
-
test.assertNotUndefinedAndNotNull(error);
|
|
17
|
-
test.assertEqual(error.name, "Error");
|
|
18
|
-
test.assertEqual(error.message, "");
|
|
19
|
-
test.assertNotUndefinedAndNotNull(error.stack);
|
|
20
|
-
});
|
|
21
|
-
});
|
|
22
|
-
});
|
|
23
|
-
});
|
|
24
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { PreConditionError } from "../sources/preConditionError";
|
|
2
|
-
import { Test } from "./test";
|
|
3
|
-
import { TestRunner } from "./testRunner";
|
|
4
|
-
|
|
5
|
-
export function test(runner: TestRunner): void
|
|
6
|
-
{
|
|
7
|
-
runner.testFile("preConditionError.ts", () =>
|
|
8
|
-
{
|
|
9
|
-
runner.testType("PreConditionError", () =>
|
|
10
|
-
{
|
|
11
|
-
runner.testFunction("constructor(string|undefined)", () =>
|
|
12
|
-
{
|
|
13
|
-
runner.test("with no arguments", (test: Test) =>
|
|
14
|
-
{
|
|
15
|
-
const error: PreConditionError = new PreConditionError();
|
|
16
|
-
test.assertNotUndefinedAndNotNull(error);
|
|
17
|
-
test.assertEqual(error.name, "Error");
|
|
18
|
-
test.assertEqual(error.message, "");
|
|
19
|
-
test.assertNotUndefinedAndNotNull(error.stack);
|
|
20
|
-
});
|
|
21
|
-
});
|
|
22
|
-
});
|
|
23
|
-
});
|
|
24
|
-
}
|