@everyonesoftware/common 3.0.0 → 5.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
package/tests/generatorTests.ts
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
import { Generator } from "../sources/generator";
|
|
2
|
-
import { PreConditionError } from "../sources/preConditionError";
|
|
3
|
-
import { Test } from "./test";
|
|
4
|
-
import { TestRunner } from "./testRunner";
|
|
5
|
-
import { iteratorTests } from "./iteratorTests";
|
|
6
|
-
|
|
7
|
-
export function test(runner: TestRunner): void
|
|
8
|
-
{
|
|
9
|
-
runner.testFile("generator.ts", () =>
|
|
10
|
-
{
|
|
11
|
-
runner.testType("Generator<T>", () =>
|
|
12
|
-
{
|
|
13
|
-
iteratorTests(runner, () => Generator.create(() => {}));
|
|
14
|
-
|
|
15
|
-
runner.testFunction("create()", () =>
|
|
16
|
-
{
|
|
17
|
-
runner.test("with undefined", (test: Test) =>
|
|
18
|
-
{
|
|
19
|
-
test.assertThrows(() => Generator.create(undefined!), new PreConditionError(
|
|
20
|
-
"Expression: generatorAction",
|
|
21
|
-
"Expected: not undefined and not null",
|
|
22
|
-
"Actual: undefined",
|
|
23
|
-
));
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
runner.test("with null", (test: Test) =>
|
|
27
|
-
{
|
|
28
|
-
test.assertThrows(() => Generator.create(null!), new PreConditionError(
|
|
29
|
-
"Expression: generatorAction",
|
|
30
|
-
"Expected: not undefined and not null",
|
|
31
|
-
"Actual: null",
|
|
32
|
-
));
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
runner.test("with function that doesn't add any return values or return a value", (test: Test) =>
|
|
36
|
-
{
|
|
37
|
-
const generator: Generator<void> = Generator.create(() => {});
|
|
38
|
-
test.assertNotUndefinedAndNotNull(generator);
|
|
39
|
-
test.assertEqual([], generator.toArray().await());
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
runner.test("with function that returns a constant value", (test: Test) =>
|
|
43
|
-
{
|
|
44
|
-
const generator: Generator<number> = Generator.create(() => 20);
|
|
45
|
-
test.assertNotUndefinedAndNotNull(generator);
|
|
46
|
-
test.assertEqual([20, 20, 20, 20], generator.take(4).toArray().await());
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
runner.test("with function that returns an incrementing value", (test: Test) =>
|
|
50
|
-
{
|
|
51
|
-
let value: number = 20;
|
|
52
|
-
const generator: Generator<number> = Generator.create(() => value++);
|
|
53
|
-
test.assertNotUndefinedAndNotNull(generator);
|
|
54
|
-
test.assertEqual([20, 21, 22, 23, 24], generator.take(5).toArray().await());
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
runner.test("with function that always adds a return value", (test: Test) =>
|
|
58
|
-
{
|
|
59
|
-
const generator: Generator<number> = Generator.create(control => control.addValue(20));
|
|
60
|
-
test.assertNotUndefinedAndNotNull(generator);
|
|
61
|
-
test.assertEqual([20, 20, 20, 20], generator.take(4).toArray().await());
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
runner.test("with function that always adds multiple return values", (test: Test) =>
|
|
65
|
-
{
|
|
66
|
-
const generator: Generator<number> = Generator.create(control => { control.addValues([20, 21, 22]); });
|
|
67
|
-
test.assertNotUndefinedAndNotNull(generator);
|
|
68
|
-
test.assertEqual([20, 21, 22, 20, 21], generator.take(5).toArray().await());
|
|
69
|
-
});
|
|
70
|
-
|
|
71
|
-
runner.test("with function that always adds a return value and returns a value", (test: Test) =>
|
|
72
|
-
{
|
|
73
|
-
const generator: Generator<number> = Generator.create(control =>
|
|
74
|
-
{
|
|
75
|
-
control.addValue(20);
|
|
76
|
-
test.assertTrue(control.hasCurrent());
|
|
77
|
-
test.assertEqual(20, control.getCurrent());
|
|
78
|
-
return 21;
|
|
79
|
-
});
|
|
80
|
-
test.assertNotUndefinedAndNotNull(generator);
|
|
81
|
-
test.assertEqual([20, 21, 20, 21, 20], generator.take(5).toArray().await());
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
});
|
|
85
|
-
});
|
|
86
|
-
}
|
package/tests/httpClientTests.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { HttpClient } from "../sources/httpClient";
|
|
2
|
-
import { Test } from "./test";
|
|
3
|
-
import { TestRunner } from "./testRunner";
|
|
4
|
-
|
|
5
|
-
export function test(runner: TestRunner): void
|
|
6
|
-
{
|
|
7
|
-
runner.testFile("httpClient.ts", () =>
|
|
8
|
-
{
|
|
9
|
-
runner.testType("HttpClient", () =>
|
|
10
|
-
{
|
|
11
|
-
runner.test("create()", (test: Test) =>
|
|
12
|
-
{
|
|
13
|
-
const client: HttpClient = HttpClient.create();
|
|
14
|
-
test.assertNotUndefinedAndNotNull(client);
|
|
15
|
-
});
|
|
16
|
-
});
|
|
17
|
-
});
|
|
18
|
-
}
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
import { InMemoryCharacterWriteStream } from "../sources/inMemoryCharacterWriteStream";
|
|
2
|
-
import { SyncResult } from "../sources/syncResult";
|
|
3
|
-
import { isUndefined } from "../sources/types";
|
|
4
|
-
import * as characterWriteStreamTests from "./characterWriteStreamTests";
|
|
5
|
-
import { Test } from "./test";
|
|
6
|
-
import { TestRunner } from "./testRunner";
|
|
7
|
-
|
|
8
|
-
export function test(runner: TestRunner): void
|
|
9
|
-
{
|
|
10
|
-
runner.testFile("inMemoryCharacterWriteStream.ts", () =>
|
|
11
|
-
{
|
|
12
|
-
runner.testType("InMemoryCharacterWriteStream", () =>
|
|
13
|
-
{
|
|
14
|
-
characterWriteStreamTests.test(runner, InMemoryCharacterWriteStream.create);
|
|
15
|
-
|
|
16
|
-
runner.testFunction("create()", (test: Test) =>
|
|
17
|
-
{
|
|
18
|
-
const writeStream: InMemoryCharacterWriteStream = InMemoryCharacterWriteStream.create();
|
|
19
|
-
test.assertNotUndefinedAndNotNull(writeStream);
|
|
20
|
-
test.assertEqual("", writeStream.getWrittenText());
|
|
21
|
-
test.assertEqual("\n", writeStream.getNewlineSequence());
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
runner.testFunction("clearWrittenText()", (test: Test) =>
|
|
25
|
-
{
|
|
26
|
-
const writeStream = InMemoryCharacterWriteStream.create();
|
|
27
|
-
|
|
28
|
-
const result1: InMemoryCharacterWriteStream = writeStream.clearWrittenText();
|
|
29
|
-
test.assertSame(writeStream, result1);
|
|
30
|
-
test.assertEqual("", writeStream.getWrittenText());
|
|
31
|
-
|
|
32
|
-
writeStream.writeString("hello world!").await();
|
|
33
|
-
test.assertEqual("hello world!", writeStream.getWrittenText());
|
|
34
|
-
|
|
35
|
-
const result2: InMemoryCharacterWriteStream = writeStream.clearWrittenText();
|
|
36
|
-
test.assertSame(writeStream, result2);
|
|
37
|
-
test.assertEqual("", writeStream.getWrittenText());
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
runner.testFunction("setNewlineSequence()", (test: Test) =>
|
|
41
|
-
{
|
|
42
|
-
const writeStream = InMemoryCharacterWriteStream.create();
|
|
43
|
-
|
|
44
|
-
const result1: InMemoryCharacterWriteStream = writeStream.setNewlineSequence("e");
|
|
45
|
-
test.assertSame(writeStream, result1);
|
|
46
|
-
test.assertEqual("e", writeStream.getNewlineSequence());
|
|
47
|
-
test.assertEqual("", writeStream.getWrittenText());
|
|
48
|
-
|
|
49
|
-
const result2: SyncResult<number> = writeStream.writeString("ab");
|
|
50
|
-
test.assertEqual("ab", writeStream.getWrittenText());
|
|
51
|
-
for (let i = 0; i < 3; i++)
|
|
52
|
-
{
|
|
53
|
-
test.assertEqual(2, result2.await());
|
|
54
|
-
test.assertEqual("ab", writeStream.getWrittenText());
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
const result3: SyncResult<number> = writeStream.writeLine("cd");
|
|
58
|
-
test.assertEqual("abcde", writeStream.getWrittenText());
|
|
59
|
-
for (let i = 0; i < 3; i++)
|
|
60
|
-
{
|
|
61
|
-
test.assertEqual(3, result3.await());
|
|
62
|
-
test.assertEqual("abcde", writeStream.getWrittenText());
|
|
63
|
-
}
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
runner.testFunction("writeString()", () =>
|
|
67
|
-
{
|
|
68
|
-
function writeStringTest(text: string): void
|
|
69
|
-
{
|
|
70
|
-
runner.test(`with ${runner.toString(text)}`, (test: Test) =>
|
|
71
|
-
{
|
|
72
|
-
const expectedWrittenText: string = text || "";
|
|
73
|
-
const writeStream = InMemoryCharacterWriteStream.create();
|
|
74
|
-
const result: number = writeStream.writeString(text).await();
|
|
75
|
-
test.assertEqual(expectedWrittenText.length, result);
|
|
76
|
-
test.assertEqual(expectedWrittenText, writeStream.getWrittenText());
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
writeStringTest(undefined!);
|
|
81
|
-
writeStringTest(null!);
|
|
82
|
-
writeStringTest("");
|
|
83
|
-
writeStringTest("a");
|
|
84
|
-
writeStringTest("abc");
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
runner.testFunction("writeLine()", () =>
|
|
88
|
-
{
|
|
89
|
-
function writeLineTest(text: string, newlineSequence?: string): void
|
|
90
|
-
{
|
|
91
|
-
runner.test(`with ${runner.toString(text)}${isUndefined(newlineSequence) ? "" : ` and ${runner.toString(newlineSequence)}`}`, (test: Test) =>
|
|
92
|
-
{
|
|
93
|
-
|
|
94
|
-
const writeStream = InMemoryCharacterWriteStream.create();
|
|
95
|
-
if (!isUndefined(newlineSequence))
|
|
96
|
-
{
|
|
97
|
-
writeStream.setNewlineSequence(newlineSequence);
|
|
98
|
-
}
|
|
99
|
-
const expectedWrittenText: string = (text || "") + writeStream.getNewlineSequence();
|
|
100
|
-
|
|
101
|
-
const result: number = writeStream.writeLine(text).await();
|
|
102
|
-
test.assertEqual(expectedWrittenText.length, result);
|
|
103
|
-
test.assertEqual(expectedWrittenText, writeStream.getWrittenText());
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
writeLineTest(undefined!);
|
|
108
|
-
writeLineTest(null!);
|
|
109
|
-
writeLineTest("");
|
|
110
|
-
writeLineTest("a");
|
|
111
|
-
writeLineTest("abc");
|
|
112
|
-
writeLineTest("abc", "\r\n");
|
|
113
|
-
writeLineTest("abc", "");
|
|
114
|
-
});
|
|
115
|
-
});
|
|
116
|
-
});
|
|
117
|
-
}
|
package/tests/iterableTests.ts
DELETED
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
import { Iterable } from "../sources/iterable";
|
|
2
|
-
import { Test } from "./test";
|
|
3
|
-
import { TestRunner } from "./testRunner";
|
|
4
|
-
|
|
5
|
-
export function test(runner: TestRunner): void
|
|
6
|
-
{
|
|
7
|
-
runner.testFile("iterable.ts", () =>
|
|
8
|
-
{
|
|
9
|
-
runner.testType("Iterable<T>", () =>
|
|
10
|
-
{
|
|
11
|
-
runner.testFunction("create(JavascriptIterable<T>|undefined)", () =>
|
|
12
|
-
{
|
|
13
|
-
runner.test("with no arguments", async (test: Test) =>
|
|
14
|
-
{
|
|
15
|
-
const iterable: Iterable<number> = Iterable.create();
|
|
16
|
-
test.assertNotUndefinedAndNotNull(iterable);
|
|
17
|
-
test.assertEqual(await iterable.toArray(), []);
|
|
18
|
-
test.assertEqual(await iterable.getCount(), 0);
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
runner.test("with empty array", async (test: Test) =>
|
|
22
|
-
{
|
|
23
|
-
const iterable: Iterable<number> = Iterable.create<number>([]);
|
|
24
|
-
test.assertNotUndefinedAndNotNull(iterable);
|
|
25
|
-
test.assertEqual(await iterable.toArray(), []);
|
|
26
|
-
test.assertEqual(await iterable.getCount(), 0);
|
|
27
|
-
});
|
|
28
|
-
|
|
29
|
-
runner.test("with non-empty array", async (test: Test) =>
|
|
30
|
-
{
|
|
31
|
-
const iterable: Iterable<number> = Iterable.create([1, 2, 3]);
|
|
32
|
-
test.assertNotUndefinedAndNotNull(iterable);
|
|
33
|
-
test.assertEqual(await iterable.toArray(), [1, 2, 3]);
|
|
34
|
-
test.assertEqual(await iterable.getCount(), 3);
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
runner.testGroup("concatenate()", () =>
|
|
39
|
-
{
|
|
40
|
-
runner.testGroup("empty and", () =>
|
|
41
|
-
{
|
|
42
|
-
runner.test("empty", (test: Test) =>
|
|
43
|
-
{
|
|
44
|
-
const iterable: Iterable<number> = Iterable.create([]);
|
|
45
|
-
const concatenateIterable: Iterable<number> = iterable.concatenate([]);
|
|
46
|
-
test.assertEqual(concatenateIterable.toArray().await(), []);
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
runner.test("non-empty", (test: Test) =>
|
|
50
|
-
{
|
|
51
|
-
const iterable: Iterable<number> = Iterable.create([]);
|
|
52
|
-
const concatenateIterable: Iterable<number> = iterable.concatenate([5]);
|
|
53
|
-
test.assertEqual(concatenateIterable.toArray().await(), [5]);
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
runner.test("two non-emptys", (test: Test) =>
|
|
57
|
-
{
|
|
58
|
-
const iterable: Iterable<number> = Iterable.create([]);
|
|
59
|
-
const concatenateIterable: Iterable<number> = iterable.concatenate([5], [6, 7]);
|
|
60
|
-
test.assertEqual(concatenateIterable.toArray().await(), [5, 6, 7]);
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
|
|
64
|
-
runner.testGroup("non-empty and", () =>
|
|
65
|
-
{
|
|
66
|
-
runner.test("empty", (test: Test) =>
|
|
67
|
-
{
|
|
68
|
-
const iterable: Iterable<number> = Iterable.create([1, 2]);
|
|
69
|
-
const concatenateIterable: Iterable<number> = iterable.concatenate([]);
|
|
70
|
-
test.assertEqual(concatenateIterable.toArray().await(), [1, 2]);
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
runner.test("non-empty", (test: Test) =>
|
|
74
|
-
{
|
|
75
|
-
const iterable: Iterable<number> = Iterable.create([3]);
|
|
76
|
-
const concatenateIterable: Iterable<number> = iterable.concatenate([4, 5, 6]);
|
|
77
|
-
test.assertEqual(concatenateIterable.toArray().await(), [3, 4, 5, 6]);
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
runner.test("two non-emptys", (test: Test) =>
|
|
81
|
-
{
|
|
82
|
-
const iterable: Iterable<number> = Iterable.create([7, 8, 9]);
|
|
83
|
-
const concatenateIterable: Iterable<number> = iterable.concatenate([10, 11, 12], [13]);
|
|
84
|
-
test.assertEqual(concatenateIterable.toArray().await(), [7, 8, 9, 10, 11, 12, 13]);
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
runner.testFunction("flatMap()", () =>
|
|
90
|
-
{
|
|
91
|
-
runner.test("with empty iterable", (test: Test) =>
|
|
92
|
-
{
|
|
93
|
-
const iterable: Iterable<number> = Iterable.create([]);
|
|
94
|
-
const flatMapIterable: Iterable<string> = iterable.flatMap((value: number) =>
|
|
95
|
-
{
|
|
96
|
-
const result: string[] = [];
|
|
97
|
-
for (let i = 0; i < value; i++)
|
|
98
|
-
{
|
|
99
|
-
result.push(value.toString());
|
|
100
|
-
}
|
|
101
|
-
return result;
|
|
102
|
-
});
|
|
103
|
-
test.assertEqual(flatMapIterable.toArray().await(), []);
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
runner.test("with non-empty iterable", (test: Test) =>
|
|
107
|
-
{
|
|
108
|
-
const iterable: Iterable<number> = Iterable.create([1, 2, 3]);
|
|
109
|
-
const flatMapIterable: Iterable<string> = iterable.flatMap((value: number) =>
|
|
110
|
-
{
|
|
111
|
-
const result: string[] = [];
|
|
112
|
-
for (let i = 0; i < value; i++)
|
|
113
|
-
{
|
|
114
|
-
result.push(value.toString());
|
|
115
|
-
}
|
|
116
|
-
return result;
|
|
117
|
-
});
|
|
118
|
-
test.assertEqual(flatMapIterable.toArray().await(), ["1", "2", "2", "3", "3", "3"]);
|
|
119
|
-
});
|
|
120
|
-
|
|
121
|
-
runner.test("with mapping that sometimes returns an empty iterable", (test: Test) =>
|
|
122
|
-
{
|
|
123
|
-
const iterable: Iterable<number> = Iterable.create([1, 2, 3, 4]);
|
|
124
|
-
const flatMapIterable: Iterable<string> = iterable.flatMap((value: number) =>
|
|
125
|
-
{
|
|
126
|
-
const result: string[] = [];
|
|
127
|
-
if (value % 2 === 1)
|
|
128
|
-
{
|
|
129
|
-
for (let i = 0; i < value; i++)
|
|
130
|
-
{
|
|
131
|
-
result.push(value.toString());
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
return result;
|
|
135
|
-
});
|
|
136
|
-
test.assertEqual(flatMapIterable.toArray().await(), ["1", "3", "3", "3"]);
|
|
137
|
-
});
|
|
138
|
-
});
|
|
139
|
-
});
|
|
140
|
-
});
|
|
141
|
-
}
|