@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,106 +0,0 @@
|
|
|
1
|
-
import { depthFirstSearch } from "../sources/depthFirstSearch";
|
|
2
|
-
import { Node } from "../sources/node";
|
|
3
|
-
import { Iterator } from "../sources/iterator";
|
|
4
|
-
import { PreConditionError } from "../sources/preConditionError";
|
|
5
|
-
import { Test } from "./test";
|
|
6
|
-
import { TestRunner } from "./testRunner";
|
|
7
|
-
import { List } from "../sources/list";
|
|
8
|
-
import { SearchControl } from "../sources/searchControl";
|
|
9
|
-
|
|
10
|
-
export function test(runner: TestRunner): void
|
|
11
|
-
{
|
|
12
|
-
runner.testFile("depthFirstSearch.ts", () =>
|
|
13
|
-
{
|
|
14
|
-
runner.testFunction("depthFirstSearch()", () =>
|
|
15
|
-
{
|
|
16
|
-
runner.test("with undefined initialToVisit", (test: Test) =>
|
|
17
|
-
{
|
|
18
|
-
test.assertThrows(() => depthFirstSearch(undefined!, () => {}), new PreConditionError(
|
|
19
|
-
"Expression: parameters",
|
|
20
|
-
"Expected: not undefined and not null",
|
|
21
|
-
"Actual: undefined",
|
|
22
|
-
));
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
runner.test("with null initialToVisit", (test: Test) =>
|
|
26
|
-
{
|
|
27
|
-
test.assertThrows(() => depthFirstSearch(null!, () => {}), new PreConditionError(
|
|
28
|
-
"Expression: parameters",
|
|
29
|
-
"Expected: not undefined and not null",
|
|
30
|
-
"Actual: null",
|
|
31
|
-
));
|
|
32
|
-
});
|
|
33
|
-
|
|
34
|
-
runner.test("with undefined searchAction", (test: Test) =>
|
|
35
|
-
{
|
|
36
|
-
test.assertThrows(() => depthFirstSearch([], undefined!), new PreConditionError(
|
|
37
|
-
"Expression: searchAction",
|
|
38
|
-
"Expected: not undefined and not null",
|
|
39
|
-
"Actual: undefined",
|
|
40
|
-
));
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
runner.test("with null searchAction", (test: Test) =>
|
|
44
|
-
{
|
|
45
|
-
test.assertThrows(() => depthFirstSearch([], null!), new PreConditionError(
|
|
46
|
-
"Expression: searchAction",
|
|
47
|
-
"Expected: not undefined and not null",
|
|
48
|
-
"Actual: null",
|
|
49
|
-
));
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
runner.test("with empty initialToVisit", (test: Test) =>
|
|
53
|
-
{
|
|
54
|
-
const iterator: Iterator<number> = depthFirstSearch([], (searchControl: SearchControl<Node<number>,number>, current: Node<number>) =>
|
|
55
|
-
{
|
|
56
|
-
searchControl.addAllToVisit(current.iterateConnectedNodes());
|
|
57
|
-
|
|
58
|
-
const currentValue: number = current.getValue();
|
|
59
|
-
if (currentValue >= 7)
|
|
60
|
-
{
|
|
61
|
-
searchControl.addResult(currentValue);
|
|
62
|
-
}
|
|
63
|
-
});
|
|
64
|
-
test.assertEqual([], iterator.toArray().await());
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
runner.test("with non-empty initialToVisit with return values", (test: Test) =>
|
|
68
|
-
{
|
|
69
|
-
const nodes: List<Node<number>> = List.create();
|
|
70
|
-
for (let i = 0; i < 10; i++)
|
|
71
|
-
{
|
|
72
|
-
nodes.add(Node.create(i));
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
function connectNodes(index1: number, index2: number): void
|
|
76
|
-
{
|
|
77
|
-
nodes.get(index1).await().addConnectedNode(nodes.get(index2).await());
|
|
78
|
-
}
|
|
79
|
-
connectNodes(0, 1);
|
|
80
|
-
connectNodes(0, 2);
|
|
81
|
-
connectNodes(1, 5);
|
|
82
|
-
connectNodes(2, 4);
|
|
83
|
-
connectNodes(3, 6);
|
|
84
|
-
connectNodes(4, 5);
|
|
85
|
-
connectNodes(4, 6);
|
|
86
|
-
connectNodes(5, 9);
|
|
87
|
-
connectNodes(6, 7);
|
|
88
|
-
connectNodes(7, 3);
|
|
89
|
-
connectNodes(8, 9);
|
|
90
|
-
|
|
91
|
-
const iterator: Iterator<number> = depthFirstSearch([nodes.get(0).await()], (searchControl: SearchControl<Node<number>,number>, current: Node<number>) =>
|
|
92
|
-
{
|
|
93
|
-
searchControl.addAllToVisit(current.iterateConnectedNodes());
|
|
94
|
-
|
|
95
|
-
const currentValue: number = current.getValue();
|
|
96
|
-
if (currentValue >= 7)
|
|
97
|
-
{
|
|
98
|
-
searchControl.addResult(currentValue);
|
|
99
|
-
}
|
|
100
|
-
});
|
|
101
|
-
|
|
102
|
-
test.assertEqual([7, 9], iterator.toArray().await());
|
|
103
|
-
});
|
|
104
|
-
});
|
|
105
|
-
});
|
|
106
|
-
}
|
package/tests/disposableTests.ts
DELETED
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
import { SyncDisposable } from "../sources/basicDisposable";
|
|
2
|
-
import { Disposable } from "../sources/disposable";
|
|
3
|
-
import { PreConditionError } from "../sources/preConditionError";
|
|
4
|
-
import { SyncResult } from "../sources/syncResult";
|
|
5
|
-
import { Test } from "./test";
|
|
6
|
-
import { TestRunner } from "./testRunner";
|
|
7
|
-
|
|
8
|
-
export function test(runner: TestRunner): void
|
|
9
|
-
{
|
|
10
|
-
runner.testFile("disposable.ts", () =>
|
|
11
|
-
{
|
|
12
|
-
runner.testType("Disposable", () =>
|
|
13
|
-
{
|
|
14
|
-
runner.testFunction("create()", () =>
|
|
15
|
-
{
|
|
16
|
-
function createErrorTest(testName: string, disposedFunction: () => void, expectedError: Error): void
|
|
17
|
-
{
|
|
18
|
-
runner.test(testName, (test: Test) =>
|
|
19
|
-
{
|
|
20
|
-
test.assertThrows(() => Disposable.create(disposedFunction), expectedError);
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
createErrorTest("with undefined", undefined!, new PreConditionError(
|
|
25
|
-
"Expression: disposedFunction",
|
|
26
|
-
"Expected: not undefined and not null",
|
|
27
|
-
"Actual: undefined",
|
|
28
|
-
));
|
|
29
|
-
createErrorTest("with null", null!, new PreConditionError(
|
|
30
|
-
"Expression: disposedFunction",
|
|
31
|
-
"Expected: not undefined and not null",
|
|
32
|
-
"Actual: null",
|
|
33
|
-
));
|
|
34
|
-
|
|
35
|
-
runner.test("with function", (test: Test) =>
|
|
36
|
-
{
|
|
37
|
-
let value: number = 0;
|
|
38
|
-
const disposable: Disposable = Disposable.create(() => value += 1);
|
|
39
|
-
test.assertNotUndefinedAndNotNull(disposable);
|
|
40
|
-
test.assertFalse(disposable.isDisposed());
|
|
41
|
-
test.assertEqual(value, 0);
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
|
|
45
|
-
runner.testFunction("dispose()", () =>
|
|
46
|
-
{
|
|
47
|
-
runner.test("with function that doesn't throw", (test: Test) =>
|
|
48
|
-
{
|
|
49
|
-
let value: number = 0;
|
|
50
|
-
const disposable: SyncDisposable = Disposable.create(() =>
|
|
51
|
-
{
|
|
52
|
-
test.assertEqual(disposable.isDisposed(), value !== 0);
|
|
53
|
-
value += 1;
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
const result1: SyncResult<boolean> = disposable.dispose();
|
|
57
|
-
test.assertNotUndefinedAndNotNull(result1);
|
|
58
|
-
test.assertTrue(disposable.isDisposed());
|
|
59
|
-
test.assertEqual(value, 1);
|
|
60
|
-
|
|
61
|
-
for (let i = 0; i < 3; i++)
|
|
62
|
-
{
|
|
63
|
-
const resultValue: boolean = result1.await();
|
|
64
|
-
test.assertTrue(resultValue);
|
|
65
|
-
test.assertTrue(disposable.isDisposed());
|
|
66
|
-
test.assertEqual(value, 1);
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
const result2: SyncResult<boolean> = disposable.dispose();
|
|
70
|
-
test.assertNotUndefinedAndNotNull(result2);
|
|
71
|
-
test.assertTrue(disposable.isDisposed());
|
|
72
|
-
test.assertEqual(value, 1);
|
|
73
|
-
|
|
74
|
-
for (let i = 0; i < 3; i++)
|
|
75
|
-
{
|
|
76
|
-
const resultValue: boolean = result2.await();
|
|
77
|
-
test.assertFalse(resultValue);
|
|
78
|
-
test.assertTrue(disposable.isDisposed());
|
|
79
|
-
test.assertEqual(value, 1);
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
runner.test("with function that throws", (test: Test) =>
|
|
84
|
-
{
|
|
85
|
-
let value: number = 0;
|
|
86
|
-
const disposable: SyncDisposable = Disposable.create(() =>
|
|
87
|
-
{
|
|
88
|
-
test.assertEqual(disposable.isDisposed(), value !== 0);
|
|
89
|
-
value += 1;
|
|
90
|
-
throw new Error("oops!");
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
const result1: SyncResult<boolean> = disposable.dispose();
|
|
94
|
-
test.assertNotUndefinedAndNotNull(result1);
|
|
95
|
-
test.assertTrue(disposable.isDisposed());
|
|
96
|
-
test.assertEqual(value, 1);
|
|
97
|
-
|
|
98
|
-
for (let i = 0; i < 3; i++)
|
|
99
|
-
{
|
|
100
|
-
test.assertThrows(() => result1.await(), new Error("oops!"));
|
|
101
|
-
test.assertTrue(disposable.isDisposed());
|
|
102
|
-
test.assertEqual(value, 1);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
const result2: SyncResult<boolean> = disposable.dispose();
|
|
106
|
-
test.assertNotUndefinedAndNotNull(result2);
|
|
107
|
-
test.assertTrue(disposable.isDisposed());
|
|
108
|
-
test.assertEqual(value, 1);
|
|
109
|
-
|
|
110
|
-
for (let i = 0; i < 3; i++)
|
|
111
|
-
{
|
|
112
|
-
const resultValue: boolean = result2.await();
|
|
113
|
-
test.assertFalse(resultValue);
|
|
114
|
-
test.assertTrue(disposable.isDisposed());
|
|
115
|
-
test.assertEqual(value, 1);
|
|
116
|
-
}
|
|
117
|
-
});
|
|
118
|
-
});
|
|
119
|
-
});
|
|
120
|
-
});
|
|
121
|
-
}
|
package/tests/englishTests.ts
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import { andList, orList } from "../sources/english";
|
|
2
|
-
import { PreConditionError } from "../sources/preConditionError";
|
|
3
|
-
import { join } from "../sources/strings";
|
|
4
|
-
import { Test } from "./test";
|
|
5
|
-
import { TestRunner } from "./testRunner";
|
|
6
|
-
|
|
7
|
-
export function test(runner: TestRunner): void
|
|
8
|
-
{
|
|
9
|
-
runner.testFile("english.ts", () =>
|
|
10
|
-
{
|
|
11
|
-
runner.testFunction("andList(string[])", () =>
|
|
12
|
-
{
|
|
13
|
-
function andListErrorTest(values: string[] | undefined | null, expectedError: Error): void
|
|
14
|
-
{
|
|
15
|
-
runner.test(`with ${runner.toString(values)}`, (test: Test) =>
|
|
16
|
-
{
|
|
17
|
-
test.assertThrows(() => andList(values!), expectedError);
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
andListErrorTest(
|
|
22
|
-
undefined,
|
|
23
|
-
new PreConditionError(
|
|
24
|
-
join("\n", [
|
|
25
|
-
"Expression: values",
|
|
26
|
-
"Expected: not undefined and not null",
|
|
27
|
-
"Actual: undefined",
|
|
28
|
-
])));
|
|
29
|
-
andListErrorTest(
|
|
30
|
-
null,
|
|
31
|
-
new PreConditionError(
|
|
32
|
-
join("\n", [
|
|
33
|
-
"Expression: values",
|
|
34
|
-
"Expected: not undefined and not null",
|
|
35
|
-
"Actual: null",
|
|
36
|
-
])));
|
|
37
|
-
|
|
38
|
-
function andListTest(values: string[], expected: string): void
|
|
39
|
-
{
|
|
40
|
-
runner.test(`with ${runner.toString(values)}`, (test: Test) =>
|
|
41
|
-
{
|
|
42
|
-
test.assertEqual(andList(values), expected);
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
andListTest([], "");
|
|
47
|
-
andListTest([""], "");
|
|
48
|
-
andListTest(["", ""], " and ");
|
|
49
|
-
andListTest(["", "", ""], ", , and ");
|
|
50
|
-
|
|
51
|
-
andListTest(["a"], "a");
|
|
52
|
-
andListTest(["a", "b"], "a and b");
|
|
53
|
-
andListTest(["a", "b", "c"], "a, b, and c");
|
|
54
|
-
andListTest(["a", "b", "c", "d"], "a, b, c, and d");
|
|
55
|
-
});
|
|
56
|
-
|
|
57
|
-
runner.testFunction("orList(string[])", () =>
|
|
58
|
-
{
|
|
59
|
-
function orListErrorTest(values: string[] | undefined | null, expectedError: Error): void
|
|
60
|
-
{
|
|
61
|
-
runner.test(`with ${runner.toString(values)}`, (test: Test) =>
|
|
62
|
-
{
|
|
63
|
-
test.assertThrows(() => orList(values!), expectedError);
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
orListErrorTest(
|
|
68
|
-
undefined,
|
|
69
|
-
new PreConditionError(
|
|
70
|
-
join("\n", [
|
|
71
|
-
"Expression: values",
|
|
72
|
-
"Expected: not undefined and not null",
|
|
73
|
-
"Actual: undefined",
|
|
74
|
-
])));
|
|
75
|
-
orListErrorTest(
|
|
76
|
-
null,
|
|
77
|
-
new PreConditionError(
|
|
78
|
-
join("\n", [
|
|
79
|
-
"Expression: values",
|
|
80
|
-
"Expected: not undefined and not null",
|
|
81
|
-
"Actual: null",
|
|
82
|
-
])));
|
|
83
|
-
|
|
84
|
-
function orListTest(values: string[], expected: string): void
|
|
85
|
-
{
|
|
86
|
-
runner.test(`with ${runner.toString(values)}`, (test: Test) =>
|
|
87
|
-
{
|
|
88
|
-
test.assertEqual(orList(values), expected);
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
orListTest([], "");
|
|
93
|
-
orListTest([""], "");
|
|
94
|
-
orListTest(["", ""], " or ");
|
|
95
|
-
orListTest(["", "", ""], ", , or ");
|
|
96
|
-
|
|
97
|
-
orListTest(["a"], "a");
|
|
98
|
-
orListTest(["a", "b"], "a or b");
|
|
99
|
-
orListTest(["a", "b", "c"], "a, b, or c");
|
|
100
|
-
orListTest(["a", "b", "c", "d"], "a, b, c, or d");
|
|
101
|
-
});
|
|
102
|
-
});
|
|
103
|
-
}
|
|
@@ -1,223 +0,0 @@
|
|
|
1
|
-
import { andList } from "../sources/english";
|
|
2
|
-
import { EqualFunctions } from "../sources/equalFunctions";
|
|
3
|
-
import { List } from "../sources/list";
|
|
4
|
-
import { Map } from "../sources/map";
|
|
5
|
-
import { PreConditionError } from "../sources/preConditionError";
|
|
6
|
-
import { isNumber } from "../sources/types";
|
|
7
|
-
import { Test } from "./test";
|
|
8
|
-
import { TestRunner } from "./testRunner";
|
|
9
|
-
|
|
10
|
-
export function test(runner: TestRunner): void
|
|
11
|
-
{
|
|
12
|
-
runner.testFile("equalFunctions.ts", () =>
|
|
13
|
-
{
|
|
14
|
-
runner.testType("EqualFunctions", () =>
|
|
15
|
-
{
|
|
16
|
-
runner.test("create()", (test: Test) =>
|
|
17
|
-
{
|
|
18
|
-
const functions: EqualFunctions = EqualFunctions.create();
|
|
19
|
-
test.assertNotUndefinedAndNotNull(functions);
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
runner.testFunction("areEqual()", () =>
|
|
23
|
-
{
|
|
24
|
-
function areEqualTest(left: unknown, right: unknown, expected: boolean): void
|
|
25
|
-
{
|
|
26
|
-
runner.test(`with ${runner.andList([left, right])}`, (test: Test) =>
|
|
27
|
-
{
|
|
28
|
-
const functions: EqualFunctions = EqualFunctions.create();
|
|
29
|
-
test.assertEqual(functions.areEqual(left, right).await(), expected);
|
|
30
|
-
});
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
areEqualTest(undefined, undefined, true);
|
|
34
|
-
areEqualTest(undefined, null, false);
|
|
35
|
-
areEqualTest(undefined, false, false);
|
|
36
|
-
areEqualTest(undefined, true, false);
|
|
37
|
-
areEqualTest(undefined, "hello", false);
|
|
38
|
-
areEqualTest(undefined, 20, false);
|
|
39
|
-
areEqualTest(undefined, {}, false);
|
|
40
|
-
areEqualTest(undefined, [], false);
|
|
41
|
-
areEqualTest(undefined, Map.create(), false);
|
|
42
|
-
|
|
43
|
-
areEqualTest(null, undefined, false);
|
|
44
|
-
areEqualTest(null, null, true);
|
|
45
|
-
areEqualTest(null, false, false);
|
|
46
|
-
areEqualTest(null, true, false);
|
|
47
|
-
areEqualTest(null, "hello", false);
|
|
48
|
-
areEqualTest(null, 20, false);
|
|
49
|
-
areEqualTest(null, {}, false);
|
|
50
|
-
areEqualTest(null, [], false);
|
|
51
|
-
areEqualTest(null, Map.create(), false);
|
|
52
|
-
|
|
53
|
-
areEqualTest(false, undefined, false);
|
|
54
|
-
areEqualTest(false, null, false);
|
|
55
|
-
areEqualTest(false, false, true);
|
|
56
|
-
areEqualTest(false, true, false);
|
|
57
|
-
areEqualTest(false, "hello", false);
|
|
58
|
-
areEqualTest(false, 20, false);
|
|
59
|
-
areEqualTest(false, {}, false);
|
|
60
|
-
areEqualTest(false, [], false);
|
|
61
|
-
areEqualTest(false, Map.create(), false);
|
|
62
|
-
|
|
63
|
-
areEqualTest(true, undefined, false);
|
|
64
|
-
areEqualTest(true, null, false);
|
|
65
|
-
areEqualTest(true, false, false);
|
|
66
|
-
areEqualTest(true, true, true);
|
|
67
|
-
areEqualTest(true, "hello", false);
|
|
68
|
-
areEqualTest(true, 20, false);
|
|
69
|
-
areEqualTest(true, {}, false);
|
|
70
|
-
areEqualTest(true, [], false);
|
|
71
|
-
areEqualTest(true, Map.create(), false);
|
|
72
|
-
|
|
73
|
-
areEqualTest("hello", undefined, false);
|
|
74
|
-
areEqualTest("hello", null, false);
|
|
75
|
-
areEqualTest("hello", false, false);
|
|
76
|
-
areEqualTest("hello", true, false);
|
|
77
|
-
areEqualTest("hello", "hello", true);
|
|
78
|
-
areEqualTest("hello", "hello there", false);
|
|
79
|
-
areEqualTest("hello", "HELLO", false);
|
|
80
|
-
areEqualTest("hello", 20, false);
|
|
81
|
-
areEqualTest("hello", {}, false);
|
|
82
|
-
areEqualTest("hello", [], false);
|
|
83
|
-
areEqualTest("", [], false);
|
|
84
|
-
areEqualTest("abc", ["a", "b", "c"], false);
|
|
85
|
-
areEqualTest("hello", Map.create(), false);
|
|
86
|
-
|
|
87
|
-
areEqualTest(10, undefined, false);
|
|
88
|
-
areEqualTest(10, null, false);
|
|
89
|
-
areEqualTest(10, false, false);
|
|
90
|
-
areEqualTest(10, true, false);
|
|
91
|
-
areEqualTest(10, "hello", false);
|
|
92
|
-
areEqualTest(10, 10, true);
|
|
93
|
-
areEqualTest(10, 10.0, true);
|
|
94
|
-
areEqualTest(10, -10, false);
|
|
95
|
-
areEqualTest(10, 10.0000001, false);
|
|
96
|
-
areEqualTest(10, 20, false);
|
|
97
|
-
areEqualTest(10, {}, false);
|
|
98
|
-
areEqualTest(10, [], false);
|
|
99
|
-
areEqualTest(10, Map.create(), false);
|
|
100
|
-
|
|
101
|
-
areEqualTest({}, undefined, false);
|
|
102
|
-
areEqualTest({}, null, false);
|
|
103
|
-
areEqualTest({}, false, false);
|
|
104
|
-
areEqualTest({}, true, false);
|
|
105
|
-
areEqualTest({}, "hello", false);
|
|
106
|
-
areEqualTest({}, 20, false);
|
|
107
|
-
areEqualTest({}, {}, true);
|
|
108
|
-
areEqualTest({}, {a:5}, false);
|
|
109
|
-
areEqualTest({a:5}, {a:5}, true);
|
|
110
|
-
areEqualTest({a:{b:5}}, {a:{b:5}}, true);
|
|
111
|
-
areEqualTest({a:6}, {a:5}, false);
|
|
112
|
-
areEqualTest({A:5}, {a:5}, false);
|
|
113
|
-
areEqualTest({}, [], false);
|
|
114
|
-
areEqualTest({}, Map.create(), false);
|
|
115
|
-
areEqualTest({a:5}, Map.create<string,number>().set("a", 5), false);
|
|
116
|
-
|
|
117
|
-
areEqualTest([], undefined, false);
|
|
118
|
-
areEqualTest([], null, false);
|
|
119
|
-
areEqualTest([], false, false);
|
|
120
|
-
areEqualTest([], true, false);
|
|
121
|
-
areEqualTest([], "hello", false);
|
|
122
|
-
areEqualTest(["a", "b", "c"], "abc", false);
|
|
123
|
-
areEqualTest([], 20, false);
|
|
124
|
-
areEqualTest([], {}, false);
|
|
125
|
-
areEqualTest([], List.create(), true);
|
|
126
|
-
areEqualTest([], [], true);
|
|
127
|
-
areEqualTest([], [1], false);
|
|
128
|
-
areEqualTest([1], [1], true);
|
|
129
|
-
areEqualTest([1,2,3], [1,2,3], true);
|
|
130
|
-
areEqualTest([1,2], [1,2,3], false);
|
|
131
|
-
areEqualTest([1,2], [1,3], false);
|
|
132
|
-
areEqualTest([], Map.create(), false);
|
|
133
|
-
|
|
134
|
-
areEqualTest(List.create(), undefined, false);
|
|
135
|
-
areEqualTest(List.create(), null, false);
|
|
136
|
-
areEqualTest(List.create(), false, false);
|
|
137
|
-
areEqualTest(List.create(), true, false);
|
|
138
|
-
areEqualTest(List.create(), "hello", false);
|
|
139
|
-
areEqualTest(List.create(), 20, false);
|
|
140
|
-
areEqualTest(List.create(), {}, false);
|
|
141
|
-
areEqualTest(List.create(), [], true);
|
|
142
|
-
areEqualTest(List.create(), [1], false);
|
|
143
|
-
areEqualTest(List.create([1]), [1], true);
|
|
144
|
-
areEqualTest(List.create([1,2,3]), [1,2,3], true);
|
|
145
|
-
areEqualTest(List.create([1,2]), [1,2,3], false);
|
|
146
|
-
areEqualTest(List.create([1,2]), [1,3], false);
|
|
147
|
-
areEqualTest(List.create(), Map.create(), false);
|
|
148
|
-
|
|
149
|
-
areEqualTest(Map.create(), undefined, false);
|
|
150
|
-
areEqualTest(Map.create(), null, false);
|
|
151
|
-
areEqualTest(Map.create(), false, false);
|
|
152
|
-
areEqualTest(Map.create(), true, false);
|
|
153
|
-
areEqualTest(Map.create(), "hello", false);
|
|
154
|
-
areEqualTest(Map.create(), 20, false);
|
|
155
|
-
areEqualTest(Map.create(), {}, false);
|
|
156
|
-
areEqualTest(Map.create().set("d", 4), {d:4}, false);
|
|
157
|
-
areEqualTest(Map.create().set("d", 4), {d:5}, false);
|
|
158
|
-
areEqualTest(Map.create().set("d", 4), {e:4}, false);
|
|
159
|
-
areEqualTest(Map.create(), [], false);
|
|
160
|
-
areEqualTest(Map.create(), Map.create(), true);
|
|
161
|
-
areEqualTest(Map.create(), Map.create().set("e", 5), false);
|
|
162
|
-
areEqualTest(Map.create().set("e", 5), Map.create().set("e", 5), true);
|
|
163
|
-
areEqualTest(Map.create().set("e", 5), Map.create().set("f", 5), false);
|
|
164
|
-
areEqualTest(Map.create().set("e", 5), Map.create().set("e", 6), false);
|
|
165
|
-
areEqualTest(Map.create().set("e", 5).set("f", 6), Map.create().set("f", 6).set("e", 5), true);
|
|
166
|
-
});
|
|
167
|
-
|
|
168
|
-
runner.testFunction("add()", () =>
|
|
169
|
-
{
|
|
170
|
-
runner.test("with undefined equalFunction", (test: Test) =>
|
|
171
|
-
{
|
|
172
|
-
const functions: EqualFunctions = EqualFunctions.create();
|
|
173
|
-
test.assertThrows(
|
|
174
|
-
() => functions.add(undefined!),
|
|
175
|
-
new PreConditionError([
|
|
176
|
-
"Expression: equalFunction",
|
|
177
|
-
"Expected: not undefined and not null",
|
|
178
|
-
"Actual: undefined"
|
|
179
|
-
].join("\n")),
|
|
180
|
-
);
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
runner.test("with null equalFunction", (test: Test) =>
|
|
184
|
-
{
|
|
185
|
-
const functions: EqualFunctions = EqualFunctions.create();
|
|
186
|
-
test.assertThrows(
|
|
187
|
-
() => functions.add(null!),
|
|
188
|
-
new PreConditionError([
|
|
189
|
-
"Expression: equalFunction",
|
|
190
|
-
"Expected: not undefined and not null",
|
|
191
|
-
"Actual: null"
|
|
192
|
-
].join("\n")),
|
|
193
|
-
);
|
|
194
|
-
});
|
|
195
|
-
|
|
196
|
-
runner.test("with equalFunction that compares numbers based on their mod 2 result", (test: Test) =>
|
|
197
|
-
{
|
|
198
|
-
const functions: EqualFunctions = EqualFunctions.create();
|
|
199
|
-
const result: EqualFunctions = functions.add((left: unknown, right: unknown) =>
|
|
200
|
-
{
|
|
201
|
-
let result: boolean | undefined;
|
|
202
|
-
if (isNumber(left) && isNumber(right))
|
|
203
|
-
{
|
|
204
|
-
const leftMod2: number = left % 2;
|
|
205
|
-
const rightMod2: number = right % 2;
|
|
206
|
-
result = leftMod2 === rightMod2;
|
|
207
|
-
}
|
|
208
|
-
return result;
|
|
209
|
-
});
|
|
210
|
-
test.assertSame(functions, result);
|
|
211
|
-
test.assertTrue(functions.areEqual(0, 0).await());
|
|
212
|
-
test.assertTrue(functions.areEqual(1, 1).await());
|
|
213
|
-
test.assertTrue(functions.areEqual(0, 2).await());
|
|
214
|
-
test.assertTrue(functions.areEqual(1, 3).await());
|
|
215
|
-
test.assertFalse(functions.areEqual(-1, 5).await());
|
|
216
|
-
test.assertFalse(functions.areEqual(0, 1).await());
|
|
217
|
-
test.assertTrue(functions.areEqual(false, false).await());
|
|
218
|
-
test.assertFalse(functions.areEqual(false, true).await());
|
|
219
|
-
});
|
|
220
|
-
});
|
|
221
|
-
});
|
|
222
|
-
});
|
|
223
|
-
}
|
package/tests/failedTest.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { JavascriptIterable } from "../sources/javascript";
|
|
2
|
-
import { PreCondition } from "../sources/preCondition";
|
|
3
|
-
import { join } from "../sources/strings";
|
|
4
|
-
|
|
5
|
-
export class FailedTest
|
|
6
|
-
{
|
|
7
|
-
private readonly fullTestNameParts: JavascriptIterable<string>;
|
|
8
|
-
private readonly error: unknown;
|
|
9
|
-
|
|
10
|
-
private constructor(fullTestNameParts: JavascriptIterable<string>, error: unknown)
|
|
11
|
-
{
|
|
12
|
-
PreCondition.assertNotEmpty(fullTestNameParts, "fullTestName");
|
|
13
|
-
PreCondition.assertNotUndefinedAndNotNull(error, "error");
|
|
14
|
-
|
|
15
|
-
this.fullTestNameParts = fullTestNameParts;
|
|
16
|
-
this.error = error;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
public static create(fullTestNameParts: JavascriptIterable<string>, error: unknown): FailedTest
|
|
20
|
-
{
|
|
21
|
-
return new FailedTest(fullTestNameParts, error);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
public getFullTestNameParts(): JavascriptIterable<string>
|
|
25
|
-
{
|
|
26
|
-
return this.fullTestNameParts;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
public getFullTestName(): string
|
|
30
|
-
{
|
|
31
|
-
return join(" ", this.fullTestNameParts);
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
public getError(): unknown
|
|
35
|
-
{
|
|
36
|
-
return this.error;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
public getErrorMessage(): string
|
|
40
|
-
{
|
|
41
|
-
return this.error instanceof Error && this.error.stack ? this.error.stack : `${this.error}`;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { FetchHttpClient } from "../sources/fetchHttpClient";
|
|
2
|
-
import { FetchHttpIncomingResponse } from "../sources/fetchHttpResponse";
|
|
3
|
-
import { HttpOutgoingRequest } from "../sources/httpOutgoingRequest";
|
|
4
|
-
import { Test } from "./test";
|
|
5
|
-
import { TestRunner } from "./testRunner";
|
|
6
|
-
import { hasNetworkAccess } from "./tests";
|
|
7
|
-
|
|
8
|
-
export function test(runner: TestRunner): void
|
|
9
|
-
{
|
|
10
|
-
runner.testFile("fetchHttpClient.ts", () =>
|
|
11
|
-
{
|
|
12
|
-
runner.testType("FetchHttpClient", () =>
|
|
13
|
-
{
|
|
14
|
-
runner.test("create()", (test: Test) =>
|
|
15
|
-
{
|
|
16
|
-
const client: FetchHttpClient = FetchHttpClient.create();
|
|
17
|
-
test.assertNotUndefinedAndNotNull(client);
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
runner.testFunction("sendRequest()", () =>
|
|
21
|
-
{
|
|
22
|
-
runner.test("to URL that exists", runner.skip(!hasNetworkAccess), async (test: Test) =>
|
|
23
|
-
{
|
|
24
|
-
const client: FetchHttpClient = FetchHttpClient.create();
|
|
25
|
-
|
|
26
|
-
const response: FetchHttpIncomingResponse = await client.sendRequest(HttpOutgoingRequest.get("https://www.example.com"));
|
|
27
|
-
test.assertNotUndefinedAndNotNull(response);
|
|
28
|
-
test.assertEqual(200, response.getStatusCode());
|
|
29
|
-
});
|
|
30
|
-
});
|
|
31
|
-
});
|
|
32
|
-
});
|
|
33
|
-
}
|