@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,21 +0,0 @@
|
|
|
1
|
-
import { JavascriptMapMap } from "../sources/javascriptMapMap";
|
|
2
|
-
import { mapTests } from "./mapTests";
|
|
3
|
-
import { Test } from "./test";
|
|
4
|
-
import { TestRunner } from "./testRunner";
|
|
5
|
-
|
|
6
|
-
export function test(runner: TestRunner): void
|
|
7
|
-
{
|
|
8
|
-
runner.testFile("javascriptMapMap.ts", () =>
|
|
9
|
-
{
|
|
10
|
-
runner.testType("JavascriptMapMap<TKey,TValue>", () =>
|
|
11
|
-
{
|
|
12
|
-
runner.testFunction("create()", (test: Test) =>
|
|
13
|
-
{
|
|
14
|
-
const map: JavascriptMapMap<number,string> = JavascriptMapMap.create();
|
|
15
|
-
test.assertEqual(map.getCount().await(), 0);
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
mapTests(runner, JavascriptMapMap.create);
|
|
19
|
-
});
|
|
20
|
-
});
|
|
21
|
-
}
|
package/tests/listTests.ts
DELETED
|
@@ -1,338 +0,0 @@
|
|
|
1
|
-
import { JavascriptIterable } from "../sources/javascript";
|
|
2
|
-
import { List } from "../sources/list";
|
|
3
|
-
import { PreConditionError } from "../sources/preConditionError";
|
|
4
|
-
import { isIterable } from "../sources/types";
|
|
5
|
-
import { Test } from "./test";
|
|
6
|
-
import { TestRunner } from "./testRunner";
|
|
7
|
-
|
|
8
|
-
export function test(runner: TestRunner): void
|
|
9
|
-
{
|
|
10
|
-
runner.testFile("list.ts", () =>
|
|
11
|
-
{
|
|
12
|
-
runner.testType("List<T>", () =>
|
|
13
|
-
{
|
|
14
|
-
runner.testFunction("create(T[]|Iterable<T>|undefined)", () =>
|
|
15
|
-
{
|
|
16
|
-
runner.test("with no arguments", (test: Test) =>
|
|
17
|
-
{
|
|
18
|
-
const list: List<number> = List.create();
|
|
19
|
-
test.assertNotUndefinedAndNotNull(list);
|
|
20
|
-
test.assertEqual(list.toArray().await(), []);
|
|
21
|
-
test.assertEqual(list.toString(), "[]");
|
|
22
|
-
test.assertEqual(list.getCount().await(), 0);
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
runner.test("with undefined", (test: Test) =>
|
|
26
|
-
{
|
|
27
|
-
const list: List<number> = List.create(undefined);
|
|
28
|
-
test.assertNotUndefinedAndNotNull(list);
|
|
29
|
-
test.assertEqual(list.toArray().await(), []);
|
|
30
|
-
test.assertEqual(list.toString(), "[]");
|
|
31
|
-
test.assertEqual(list.getCount().await(), 0);
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
runner.test("with empty array", (test: Test) =>
|
|
35
|
-
{
|
|
36
|
-
const list: List<number> = List.create<number>([]);
|
|
37
|
-
test.assertNotUndefinedAndNotNull(list);
|
|
38
|
-
test.assertEqual(list.toArray().await(), []);
|
|
39
|
-
test.assertSame(list.toString(), "[]");
|
|
40
|
-
test.assertSame(list.getCount().await(), 0);
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
runner.test("with non-empty array", (test: Test) =>
|
|
44
|
-
{
|
|
45
|
-
const list: List<number> = List.create([1, 2, 3]);
|
|
46
|
-
test.assertNotUndefinedAndNotNull(list);
|
|
47
|
-
test.assertEqual(list.toArray().await(), [1, 2, 3]);
|
|
48
|
-
test.assertSame(list.toString(), "[1,2,3]");
|
|
49
|
-
test.assertSame(list.getCount().await(), 3);
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
runner.test("with empty Iterable<T>", (test: Test) =>
|
|
53
|
-
{
|
|
54
|
-
const list: List<number> = List.create(List.create());
|
|
55
|
-
test.assertNotUndefinedAndNotNull(list);
|
|
56
|
-
test.assertEqual(list.toArray().await(), []);
|
|
57
|
-
test.assertSame(list.toString(), "[]");
|
|
58
|
-
test.assertSame(list.getCount().await(), 0);
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
runner.test("with non-empty Iterable<T>", (test: Test) =>
|
|
62
|
-
{
|
|
63
|
-
const list: List<number> = List.create(List.create([1, 2, 3]));
|
|
64
|
-
test.assertNotUndefinedAndNotNull(list);
|
|
65
|
-
test.assertEqual(list.toArray().await(), [1, 2, 3]);
|
|
66
|
-
test.assertTrue(isIterable(list));
|
|
67
|
-
test.assertSame(list.toString(), "[1,2,3]");
|
|
68
|
-
test.assertSame(list.getCount().await(), 3);
|
|
69
|
-
});
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
runner.testFunction("set(number,T)", () =>
|
|
73
|
-
{
|
|
74
|
-
function setErrorTest(list: List<number>, index: number, value: number, expectedError: Error): void
|
|
75
|
-
{
|
|
76
|
-
runner.test(`with ${runner.andList([list, index, value])}`, (test: Test) =>
|
|
77
|
-
{
|
|
78
|
-
const backupList: List<number> = List.create(list);
|
|
79
|
-
test.assertThrows(() => list.set(index, value), expectedError);
|
|
80
|
-
test.assertEqual(list, backupList);
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
setErrorTest(List.create(), -1, 5, new PreConditionError(
|
|
85
|
-
"Expression: count",
|
|
86
|
-
"Expected: greater than or equal to 1",
|
|
87
|
-
"Actual: 0",
|
|
88
|
-
));
|
|
89
|
-
setErrorTest(List.create(), 0, 5, new PreConditionError(
|
|
90
|
-
"Expression: count",
|
|
91
|
-
"Expected: greater than or equal to 1",
|
|
92
|
-
"Actual: 0",
|
|
93
|
-
));
|
|
94
|
-
setErrorTest(List.create(), 1, 5, new PreConditionError(
|
|
95
|
-
"Expression: count",
|
|
96
|
-
"Expected: greater than or equal to 1",
|
|
97
|
-
"Actual: 0"
|
|
98
|
-
));
|
|
99
|
-
setErrorTest(List.create([1]), -1, 5, new PreConditionError(
|
|
100
|
-
"Expression: index",
|
|
101
|
-
"Expected: 0",
|
|
102
|
-
"Actual: -1"
|
|
103
|
-
));
|
|
104
|
-
setErrorTest(List.create([1]), 1, 5, new PreConditionError(
|
|
105
|
-
"Expression: index",
|
|
106
|
-
"Expected: 0",
|
|
107
|
-
"Actual: 1"
|
|
108
|
-
));
|
|
109
|
-
|
|
110
|
-
function setTest(list: List<number>, index: number, value: number, expected: number[]): void
|
|
111
|
-
{
|
|
112
|
-
runner.test(`with ${runner.andList([list, index, value])}`, (test: Test) =>
|
|
113
|
-
{
|
|
114
|
-
const setResult: List<number> = list.set(index, value);
|
|
115
|
-
test.assertSame(list, setResult);
|
|
116
|
-
test.assertEqual(list.toArray().await(), expected);
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
|
|
120
|
-
setTest(List.create([1]), 0, 5, [5]);
|
|
121
|
-
setTest(List.create([1, 2]), 0, 5, [5, 2]);
|
|
122
|
-
setTest(List.create([1, 2]), 1, 5, [1, 5]);
|
|
123
|
-
});
|
|
124
|
-
|
|
125
|
-
runner.testFunction("get(number)", () =>
|
|
126
|
-
{
|
|
127
|
-
function getErrorTest(list: List<number>, index: number, expectedError: Error): void
|
|
128
|
-
{
|
|
129
|
-
runner.test(`with ${runner.andList([list, index])}`, (test: Test) =>
|
|
130
|
-
{
|
|
131
|
-
const backupList: List<number> = List.create(list);
|
|
132
|
-
test.assertThrows(() => list.get(index), expectedError);
|
|
133
|
-
test.assertEqual(list, backupList);
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
getErrorTest(List.create(), -1, new PreConditionError(
|
|
138
|
-
"Expression: count",
|
|
139
|
-
"Expected: greater than or equal to 1",
|
|
140
|
-
"Actual: 0"
|
|
141
|
-
));
|
|
142
|
-
getErrorTest(List.create(), 0, new PreConditionError(
|
|
143
|
-
"Expression: count",
|
|
144
|
-
"Expected: greater than or equal to 1",
|
|
145
|
-
"Actual: 0"
|
|
146
|
-
));
|
|
147
|
-
getErrorTest(List.create(), 1, new PreConditionError(
|
|
148
|
-
"Expression: count",
|
|
149
|
-
"Expected: greater than or equal to 1",
|
|
150
|
-
"Actual: 0"
|
|
151
|
-
));
|
|
152
|
-
getErrorTest(List.create([1]), -1, new PreConditionError(
|
|
153
|
-
"Expression: index",
|
|
154
|
-
"Expected: 0",
|
|
155
|
-
"Actual: -1"
|
|
156
|
-
));
|
|
157
|
-
getErrorTest(List.create([1]), 1, new PreConditionError(
|
|
158
|
-
"Expression: index",
|
|
159
|
-
"Expected: 0",
|
|
160
|
-
"Actual: 1"
|
|
161
|
-
));
|
|
162
|
-
|
|
163
|
-
function getTest(list: List<number>, index: number, expected: number): void
|
|
164
|
-
{
|
|
165
|
-
runner.test(`with ${runner.andList([list, index])}`, (test: Test) =>
|
|
166
|
-
{
|
|
167
|
-
test.assertSame(list.get(index).await(), expected);
|
|
168
|
-
});
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
getTest(List.create([1]), 0, 1);
|
|
172
|
-
getTest(List.create([1, 2]), 0, 1);
|
|
173
|
-
getTest(List.create([1, 2]), 1, 2);
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
runner.testFunction("add(T)", () =>
|
|
177
|
-
{
|
|
178
|
-
function addTest(list: List<number>, value: number, expected: number[]): void
|
|
179
|
-
{
|
|
180
|
-
runner.test(`with ${runner.andList([list, value])}`, (test: Test) =>
|
|
181
|
-
{
|
|
182
|
-
const addResult: List<number> = list.add(value);
|
|
183
|
-
test.assertSame(addResult, list);
|
|
184
|
-
test.assertEqual(list.toArray().await(), expected);
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
|
-
|
|
188
|
-
addTest(List.create(), 1, [1]);
|
|
189
|
-
addTest(List.create([1]), 2, [1, 2]);
|
|
190
|
-
addTest(List.create([1, 2]), 3, [1, 2, 3]);
|
|
191
|
-
});
|
|
192
|
-
|
|
193
|
-
runner.testFunction("addAll(T)", () =>
|
|
194
|
-
{
|
|
195
|
-
function addAllTest(list: List<number>, values: JavascriptIterable<number>, expected: number[]): void
|
|
196
|
-
{
|
|
197
|
-
runner.test(`with ${runner.andList([list, values])}`, (test: Test) =>
|
|
198
|
-
{
|
|
199
|
-
const addResult: List<number> = list.addAll(values);
|
|
200
|
-
test.assertSame(addResult, list);
|
|
201
|
-
test.assertEqual(list.toArray().await(), expected);
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
addAllTest(List.create(), [1], [1]);
|
|
206
|
-
addAllTest(List.create([1]), [2], [1, 2]);
|
|
207
|
-
addAllTest(List.create([1, 2]), [3], [1, 2, 3]);
|
|
208
|
-
addAllTest(List.create(), [1, 2], [1, 2]);
|
|
209
|
-
addAllTest(List.create([1]), [2, 3], [1, 2, 3]);
|
|
210
|
-
addAllTest(List.create([1, 2]), [3, 4], [1, 2, 3, 4]);
|
|
211
|
-
|
|
212
|
-
addAllTest(List.create(), List.create([1]), [1]);
|
|
213
|
-
addAllTest(List.create([1]), List.create([2]), [1, 2]);
|
|
214
|
-
addAllTest(List.create([1, 2]), List.create([3]), [1, 2, 3]);
|
|
215
|
-
addAllTest(List.create(), List.create([1, 2]), [1, 2]);
|
|
216
|
-
addAllTest(List.create([1]), List.create([2, 3]), [1, 2, 3]);
|
|
217
|
-
addAllTest(List.create([1, 2]), List.create([3, 4]), [1, 2, 3, 4]);
|
|
218
|
-
});
|
|
219
|
-
|
|
220
|
-
runner.testFunction("insert(number,T)", () =>
|
|
221
|
-
{
|
|
222
|
-
function insertErrorTest(list: List<number>, index: number, value: number, expected: Error): void
|
|
223
|
-
{
|
|
224
|
-
runner.test(`with ${runner.andList([list, index, value])}`, (test: Test) =>
|
|
225
|
-
{
|
|
226
|
-
const backupList: List<number> = List.create(list);
|
|
227
|
-
test.assertThrows(() => list.insert(index, value), expected);
|
|
228
|
-
test.assertEqual(list, backupList);
|
|
229
|
-
});
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
insertErrorTest(List.create(), -1, 1, new PreConditionError(
|
|
233
|
-
"Expression: index",
|
|
234
|
-
"Expected: 0",
|
|
235
|
-
"Actual: -1"
|
|
236
|
-
));
|
|
237
|
-
insertErrorTest(List.create(), 1, 1, new PreConditionError(
|
|
238
|
-
"Expression: index",
|
|
239
|
-
"Expected: 0",
|
|
240
|
-
"Actual: 1"
|
|
241
|
-
));
|
|
242
|
-
insertErrorTest(List.create([1]), -1, 1, new PreConditionError(
|
|
243
|
-
"Expression: index",
|
|
244
|
-
"Expected: between 0 and 1",
|
|
245
|
-
"Actual: -1"
|
|
246
|
-
));
|
|
247
|
-
insertErrorTest(List.create([1]), 2, 1, new PreConditionError(
|
|
248
|
-
"Expression: index",
|
|
249
|
-
"Expected: between 0 and 1",
|
|
250
|
-
"Actual: 2"
|
|
251
|
-
));
|
|
252
|
-
|
|
253
|
-
function insertTest(list: List<number>, index: number, value: number, expected: number[]): void
|
|
254
|
-
{
|
|
255
|
-
runner.test(`with ${runner.andList([list, index, value])}`, (test: Test) =>
|
|
256
|
-
{
|
|
257
|
-
const insertResult: List<number> = list.insert(index, value);
|
|
258
|
-
test.assertSame(insertResult, list);
|
|
259
|
-
test.assertEqual(list.toArray().await(), expected);
|
|
260
|
-
});
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
insertTest(List.create(), 0, 1, [1]);
|
|
264
|
-
insertTest(List.create([2]), 0, 1, [1, 2]);
|
|
265
|
-
insertTest(List.create([1]), 1, 2, [1, 2]);
|
|
266
|
-
insertTest(List.create([2, 3]), 0, 1, [1, 2, 3]);
|
|
267
|
-
insertTest(List.create([1, 3]), 1, 2, [1, 2, 3]);
|
|
268
|
-
insertTest(List.create([1, 2]), 2, 3, [1, 2, 3]);
|
|
269
|
-
});
|
|
270
|
-
|
|
271
|
-
runner.testFunction("insertAll(number,T)", () =>
|
|
272
|
-
{
|
|
273
|
-
function insertAllErrorTest(list: List<number>, index: number, values: number[] | Iterable<number>, expected: Error): void
|
|
274
|
-
{
|
|
275
|
-
runner.test(`with ${runner.andList([list, index, values])}`, (test: Test) =>
|
|
276
|
-
{
|
|
277
|
-
const backupList: List<number> = List.create(list);
|
|
278
|
-
test.assertThrows(() => list.insertAll(index, values), expected);
|
|
279
|
-
test.assertEqual(list, backupList);
|
|
280
|
-
});
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
insertAllErrorTest(List.create(), -1, [1], new PreConditionError(
|
|
284
|
-
"Expression: index",
|
|
285
|
-
"Expected: 0",
|
|
286
|
-
"Actual: -1"
|
|
287
|
-
));
|
|
288
|
-
insertAllErrorTest(List.create(), 1, [1], new PreConditionError(
|
|
289
|
-
"Expression: index",
|
|
290
|
-
"Expected: 0",
|
|
291
|
-
"Actual: 1"
|
|
292
|
-
));
|
|
293
|
-
insertAllErrorTest(List.create([1]), -1, [1], new PreConditionError(
|
|
294
|
-
"Expression: index",
|
|
295
|
-
"Expected: between 0 and 1",
|
|
296
|
-
"Actual: -1"
|
|
297
|
-
));
|
|
298
|
-
insertAllErrorTest(List.create([1]), 2, [1], new PreConditionError(
|
|
299
|
-
"Expression: index",
|
|
300
|
-
"Expected: between 0 and 1",
|
|
301
|
-
"Actual: 2",
|
|
302
|
-
));
|
|
303
|
-
|
|
304
|
-
function insertAllTest(list: List<number>, index: number, values: JavascriptIterable<number>, expected: number[]): void
|
|
305
|
-
{
|
|
306
|
-
runner.test(`with ${runner.andList([list, index, values])}`, (test: Test) =>
|
|
307
|
-
{
|
|
308
|
-
const insertResult: List<number> = list.insertAll(index, values);
|
|
309
|
-
test.assertSame(insertResult, list);
|
|
310
|
-
test.assertEqual(list.toArray().await(), expected);
|
|
311
|
-
});
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
insertAllTest(List.create(), 0, [], []);
|
|
315
|
-
insertAllTest(List.create(), 0, [1], [1]);
|
|
316
|
-
insertAllTest(List.create([2]), 0, [1], [1, 2]);
|
|
317
|
-
insertAllTest(List.create([1]), 1, [2], [1, 2]);
|
|
318
|
-
insertAllTest(List.create([2, 3]), 0, [1], [1, 2, 3]);
|
|
319
|
-
insertAllTest(List.create([1, 3]), 1, [2], [1, 2, 3]);
|
|
320
|
-
insertAllTest(List.create([1, 2]), 2, [3], [1, 2, 3]);
|
|
321
|
-
insertAllTest(List.create([3]), 0, [1, 2], [1, 2, 3]);
|
|
322
|
-
insertAllTest(List.create([1]), 1, [2, 3], [1, 2, 3]);
|
|
323
|
-
insertAllTest(List.create([1, 4]), 1, [2, 3], [1, 2, 3, 4]);
|
|
324
|
-
|
|
325
|
-
insertAllTest(List.create(), 0, List.create(), []);
|
|
326
|
-
insertAllTest(List.create(), 0, List.create([1]), [1]);
|
|
327
|
-
insertAllTest(List.create([2]), 0, List.create([1]), [1, 2]);
|
|
328
|
-
insertAllTest(List.create([1]), 1, List.create([2]), [1, 2]);
|
|
329
|
-
insertAllTest(List.create([2, 3]), 0, List.create([1]), [1, 2, 3]);
|
|
330
|
-
insertAllTest(List.create([1, 3]), 1, List.create([2]), [1, 2, 3]);
|
|
331
|
-
insertAllTest(List.create([1, 2]), 2, List.create([3]), [1, 2, 3]);
|
|
332
|
-
insertAllTest(List.create([3]), 0, List.create([1, 2]), [1, 2, 3]);
|
|
333
|
-
insertAllTest(List.create([1]), 1, List.create([2, 3]), [1, 2, 3]);
|
|
334
|
-
insertAllTest(List.create([1, 4]), 1, List.create([2, 3]), [1, 2, 3, 4]);
|
|
335
|
-
});
|
|
336
|
-
});
|
|
337
|
-
});
|
|
338
|
-
}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { Iterator } from "../sources/iterator";
|
|
2
|
-
import { MapIterator } from "../sources/mapIterator";
|
|
3
|
-
import { PreConditionError } from "../sources/preConditionError";
|
|
4
|
-
import { Test } from "./test";
|
|
5
|
-
import { TestRunner } from "./testRunner";
|
|
6
|
-
|
|
7
|
-
export function test(runner: TestRunner): void
|
|
8
|
-
{
|
|
9
|
-
runner.testFile("mapIterator.ts", () =>
|
|
10
|
-
{
|
|
11
|
-
runner.testType("MapIterator<TInput,TOutput>", () =>
|
|
12
|
-
{
|
|
13
|
-
runner.testFunction("create(Iterator<TInput>,(TInput)=>TOutput)", () =>
|
|
14
|
-
{
|
|
15
|
-
function createErrorTest<TInput,TOutput>(testName: string, innerIterator: Iterator<TInput>, mapping: (value: TInput) => TOutput, expected: Error): void
|
|
16
|
-
{
|
|
17
|
-
runner.test(testName, (test: Test) =>
|
|
18
|
-
{
|
|
19
|
-
test.assertThrows(() => MapIterator.create(innerIterator, mapping), expected);
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
createErrorTest(
|
|
24
|
-
"with undefined inputIterator",
|
|
25
|
-
undefined!,
|
|
26
|
-
(value: number) => value.toString(),
|
|
27
|
-
new PreConditionError(
|
|
28
|
-
"Expression: inputIterator",
|
|
29
|
-
"Expected: not undefined and not null",
|
|
30
|
-
"Actual: undefined",
|
|
31
|
-
));
|
|
32
|
-
createErrorTest(
|
|
33
|
-
"with null inputIterator",
|
|
34
|
-
null!,
|
|
35
|
-
(value: number) => value.toString(),
|
|
36
|
-
new PreConditionError(
|
|
37
|
-
"Expression: inputIterator",
|
|
38
|
-
"Expected: not undefined and not null",
|
|
39
|
-
"Actual: null",
|
|
40
|
-
));
|
|
41
|
-
|
|
42
|
-
runner.test("with valid values", (test: Test) =>
|
|
43
|
-
{
|
|
44
|
-
const inputIterator: Iterator<number> = Iterator.create([1, 2, 3]);
|
|
45
|
-
test.assertFalse(inputIterator.hasStarted());
|
|
46
|
-
test.assertFalse(inputIterator.hasCurrent());
|
|
47
|
-
|
|
48
|
-
const iterator: MapIterator<number,string> = MapIterator.create(inputIterator, (value: number) => value.toString());
|
|
49
|
-
test.assertFalse(iterator.hasStarted());
|
|
50
|
-
test.assertFalse(iterator.hasCurrent());
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
});
|
|
55
|
-
}
|
package/tests/mapTests.ts
DELETED
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
import { Iterator } from "../sources/iterator";
|
|
2
|
-
import { JavascriptIterable } from "../sources/javascript";
|
|
3
|
-
import { isMap, Map } from "../sources/map";
|
|
4
|
-
import { MutableMap } from "../sources/mutableMap";
|
|
5
|
-
import { NotFoundError } from "../sources/notFoundError";
|
|
6
|
-
import { Test } from "./test";
|
|
7
|
-
import { TestRunner } from "./testRunner";
|
|
8
|
-
|
|
9
|
-
export function test(runner: TestRunner): void
|
|
10
|
-
{
|
|
11
|
-
runner.testFile("map.ts", () =>
|
|
12
|
-
{
|
|
13
|
-
runner.testType("Map<TKey,TValue>", () =>
|
|
14
|
-
{
|
|
15
|
-
runner.testFunction("create()", (test: Test) =>
|
|
16
|
-
{
|
|
17
|
-
const map: MutableMap<number,string> = Map.create();
|
|
18
|
-
test.assertSame(map.getCount().await(), 0);
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
mapTests(runner, Map.create);
|
|
22
|
-
});
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export function mapTests(runner: TestRunner, creator: () => Map<number,string>): void
|
|
27
|
-
{
|
|
28
|
-
runner.testType("Map<TKey,TValue>", () =>
|
|
29
|
-
{
|
|
30
|
-
runner.testFunction("creator()", (test: Test) =>
|
|
31
|
-
{
|
|
32
|
-
test.assertNotUndefinedAndNotNull(creator);
|
|
33
|
-
|
|
34
|
-
const map: Map<number,string> = creator();
|
|
35
|
-
test.assertNotUndefinedAndNotNull(map);
|
|
36
|
-
test.assertEqual(map.getCount().await(), 0);
|
|
37
|
-
test.assertTrue(isMap(map));
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
runner.testFunction("containsKey(TKey)", () =>
|
|
41
|
-
{
|
|
42
|
-
runner.test("when it doesn't contain the key", (test: Test) =>
|
|
43
|
-
{
|
|
44
|
-
const map: Map<number,string> = creator();
|
|
45
|
-
|
|
46
|
-
test.assertFalse(map.containsKey(50).await());
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
runner.testFunction("get(TKey)", () =>
|
|
51
|
-
{
|
|
52
|
-
runner.test("when it doesn't contain the key", (test: Test) =>
|
|
53
|
-
{
|
|
54
|
-
const map: Map<number,string> = creator();
|
|
55
|
-
|
|
56
|
-
test.assertThrows(() => map.get(1).await(),
|
|
57
|
-
new NotFoundError(
|
|
58
|
-
"The key 1 was not found in the map."));
|
|
59
|
-
test.assertEqual(map.getCount().await(), 0);
|
|
60
|
-
});
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
runner.testFunction("toString()", () =>
|
|
64
|
-
{
|
|
65
|
-
function toStringTest(map: Map<number,string>, expected: string): void
|
|
66
|
-
{
|
|
67
|
-
runner.test(`with ${runner.toString(map)}`, (test: Test) =>
|
|
68
|
-
{
|
|
69
|
-
test.assertEqual(map.toString(), expected);
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
toStringTest(creator(), "{}");
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
runner.testFunction("iterateKeys()", () =>
|
|
77
|
-
{
|
|
78
|
-
function iterateKeysTests(map: Map<number,string>, expected: JavascriptIterable<number>): void
|
|
79
|
-
{
|
|
80
|
-
runner.test(`with ${runner.toString(map)}`, async (test: Test) =>
|
|
81
|
-
{
|
|
82
|
-
const keyIterator: Iterator<number> = map.iterateKeys();
|
|
83
|
-
test.assertEqual(await keyIterator.toArray(), [...expected]);
|
|
84
|
-
});
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
iterateKeysTests(creator(), []);
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
runner.testFunction("iterateValues()", () =>
|
|
91
|
-
{
|
|
92
|
-
function iterateValuesTests(map: Map<number,string>, expected: JavascriptIterable<string>): void
|
|
93
|
-
{
|
|
94
|
-
runner.test(`with ${runner.toString(map)}`, async (test: Test) =>
|
|
95
|
-
{
|
|
96
|
-
const valueIterator: Iterator<string> = map.iterateValues();
|
|
97
|
-
test.assertEqual(await valueIterator.toArray(), [...expected]);
|
|
98
|
-
});
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
iterateValuesTests(creator(), []);
|
|
102
|
-
});
|
|
103
|
-
});
|
|
104
|
-
}
|