risei 1.1.1 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/README.md +3 -1
  2. package/index.js +1 -1
  3. package/package.json +4 -4
  4. package/tests/other-tests/ASpoofingFixture.tests.js +0 -242
  5. package/tests/other-tests/SpoofClassesFixture.tests.js +0 -130
  6. package/tests/other-tests/SpoofObjectsFixture.tests.js +0 -95
  7. package/tests/other-tests/SpoofTuple.tests.js +0 -93
  8. package/tests/other-tests/TotalComparer.tests.js +0 -920
  9. package/tests/other-tests/package.json +0 -7
  10. package/tests/risei-tests/ASpoofingFixtureTests.rt.js +0 -51
  11. package/tests/risei-tests/MomentTests.rt.js +0 -103
  12. package/tests/risei-tests/SpoofTupleTests.rt.js +0 -274
  13. package/tests/risei-tests/TestFrameChooserTests.rt.js +0 -74
  14. package/tests/risei-tests/TestFrameTests.rt.js +0 -84
  15. package/tests/risei-tests/TestStagesTests.rt.js +0 -99
  16. package/tests/risei-tests/TestTupleTests.rt.js +0 -140
  17. package/tests/risei-tests/TotalComparerTests.rt.js +0 -184
  18. package/tests/risei-tests/TotalCopierTests.rt.js +0 -74
  19. package/tests/risei-tests/TotalDisplayerTests.rt.js +0 -186
  20. package/tests/risei-tests/TypeAnalyzerTests.rt.js +0 -29
  21. package/tests/risei-tests/TypeIdentifierTests.rt.js +0 -44
  22. package/tests/self-tests/SelfTests.outward-rt.js +0 -583
  23. package/tests/target-objects/CompositionModel.js +0 -38
  24. package/tests/target-objects/ConditionalThrowModel.js +0 -11
  25. package/tests/target-objects/CountModel.js +0 -46
  26. package/tests/target-objects/DomModel.js +0 -37
  27. package/tests/target-objects/MixedContents.js +0 -33
  28. package/tests/target-objects/MutationModel.js +0 -27
  29. package/tests/target-objects/ObjectCompositionModel.js +0 -34
  30. package/tests/target-objects/PolySpoofableInner.js +0 -30
  31. package/tests/target-objects/PolySpoofableOuter.js +0 -52
  32. package/tests/target-objects/PropertiesModel.js +0 -47
  33. package/tests/target-objects/Returner.js +0 -9
  34. package/tests/target-objects/SearchModel.js +0 -25
  35. package/tests/target-objects/SortModel.js +0 -91
  36. package/tests/target-objects/SpoofCaller.js +0 -24
  37. package/tests/target-objects/Spoofable.js +0 -36
  38. package/tests/target-objects/SpoofableArgsCaller.js +0 -33
  39. package/tests/target-objects/StateModel.js +0 -34
  40. package/tests/target-objects/StaticModel.js +0 -17
  41. package/tests/target-objects/TestableModel.js +0 -47
  42. package/tests/topic-tests/TopicTests.outward-rt.js +0 -354
@@ -1,99 +0,0 @@
1
- /**/
2
-
3
- import { ATestSource } from "../../node_modules/risei/public/javascript/ATestSource.js";
4
- import { TestStages } from "../../system/TestStages.js";
5
- import { TestTuple } from "../../system/TestTuple.js";
6
- import { TotalComparer } from "../../system/TotalComparer.js";
7
-
8
-
9
- class TestTopic {
10
- static staticProperty = "s-prop";
11
- instanceProperty = "i-prop";
12
- static staticMethod() { return "s-method"; }
13
- instanceMethod() { return "i-method"; }
14
- }
15
-
16
- /* &cruft, drop if never used */
17
- /* Loose variables are clearer for names of members of tested class. */
18
- let instanceMethod = TestTopic.prototype.instanceMethod.name;
19
-
20
- let supplyTestTuple = (actual, thrown, and, from) => {
21
- let output = new TestTuple("", TestTopic, "", "", "", "", "", "", from, and);
22
- output.actual = actual;
23
- output.thrown = thrown;
24
-
25
- return output;
26
- }
27
-
28
- export class TestStagesTests extends ATestSource {
29
- namedSetLocalTarget = TestStages.prototype.setLocalTarget.name;
30
-
31
- tests = [
32
- { on: TestStages, with: [ ] },
33
-
34
- { of: "setLocalTarget", and: "nospoof" },
35
- { for: "When test names a method, sets .localTarget to a new instance of the topic class.", /* good */
36
- in: [ new TestTuple("", TestTopic, "", "", "", "instanceMethod", "", "", "", "") ],
37
- out: new TestTopic(), from: (target, test) => { return test.in[0].localTarget; } },
38
- { for: "When test names a property, sets .localTarget to a nonce getting a topic-class instance's property.", /* good */
39
- in: [ new TestTuple("", TestTopic, "", "", "", "instanceProperty:", "", "", "", "") ],
40
- out: { localCallable: () => { return instance[callable]; } }, from: (target, test) => { return test.in[0].localTarget; } },
41
- { for: "When test names a method with \"static\", sets .localTarget to the topic class itself.", /* good */
42
- in: [ new TestTuple("", TestTopic, "", "", "", "staticMethod", "", "", "", "static") ],
43
- out: TestTopic, from: (target, test) => { return test.in[0].localTarget; } },
44
- { for: "When test names a property with \"static\", sets .localTarget to a nonce getting the topic-class' property.", /* good */
45
- in: [ new TestTuple("", TestTopic, "", "", "", ".staticProperty", "", "", "", "static") ],
46
- out: { localCallable: () => { return type[callable]; } }, from: (target, test) => { return test.in[0].localTarget; } },
47
- { for: "When test names \"constructor\", sets .localTarget to the topic class' prototype.", /* good */
48
- in: [ new TestTuple("", TestTopic, "", "", "", "constructor", "", "", "") ],
49
- out: TestTopic.prototype, from: (target, test) => { return test.in[0].localTarget; } },
50
-
51
- { of: "setLocalCallable", and: "nospoof" },
52
- { for: "When test names a method, sets .localCallable to the method's plain name.", /* good */
53
- in: [ new TestTuple("", TestTopic, "", "", "", "instanceMethod()", "", "", "", "") ],
54
- out: "instanceMethod", from: (target, test) => { return test.in[0].localCallable; } },
55
- { for: "When test names a property, sets .localCallable to \"localCallable\", for the nonce's method.", /* good */
56
- in: [ new TestTuple("", TestTopic, "", "", "", "instanceProperty:", "", "", "", "") ],
57
- out: "localCallable", from: (target, test) => { return test.in[0].localCallable; } },
58
- { for: "When test names \"constructor()\", sets .localCallable to \"constructor\".", /* good */
59
- in: [ new TestTuple("", TestTopic, "", "", "", "constructor()", "", "", "") ],
60
- out: "constructor", from: (target, test) => { return test.in[0].localCallable; } },
61
-
62
- /* &cruft, possibly rework these to use property-setting or arbitrary ops, when those are supported */
63
- { of: "anyModifyActual", and: "nospoof" },
64
- { for: "When .and doesn't include \"throw\" and .from is not set, test.actual remains its original value.", /* good */
65
- in: [ supplyTestTuple(168) ],
66
- out: 168, from: (target, test) => { return test.in[0].actual; } },
67
- { for: "When .and includes \"throw\", test.actual is set to test.thrown.", /* good */
68
- in: [ supplyTestTuple(210, 112, "throws") ],
69
- out: 112, from: (target, test) => { return test.in[0].actual; } },
70
- { for: "When .from is set, test.actual is set to the return value of a call to supplyNonReturnActual().", /* good */
71
- plus: [ { of: "supplyNonReturnActual", as: 87 } ],
72
- in: [ supplyTestTuple(210, "", "", "from") ],
73
- out: 87, from: (target, test) => { return test.in[0].actual; } },
74
-
75
- { of: "setLocalInitorsAndInputs", and: "nospoof" },
76
- { for: "Simple objects in .with are copied to .localInitors.", /* good */
77
- in: [ new TestTuple("", "", "", [ { a: "1" }, { b: 2 } ], "", "", "", "", "", "") ],
78
- out: [ { a: "1" }, { b: 2 } ],
79
- from: (target, test) => { return test.in[0].localInitors; } },
80
- { for: "Simple objects in .in are copied to .localInputs.", /* good */
81
- in: [ new TestTuple("", "", "", "", "", "", [ { c: 3 }, { d: "4" } ], "", "", "") ],
82
- out: [ { c: 3 }, { d: "4" } ],
83
- from: (target, test) => { return test.in[0].localInputs; } },
84
- { for: "Complex objects in .with are copied to .localInitors.", /* good */
85
- in: [ new TestTuple("", "", "", [ [ 4, 5, 6 ], { a: "1", b: new Map([ [ "c", 8 ], [ "d", 9 ] ]) } ], "", "", "", "", "", "") ],
86
- out: [ [ 4, 5, 6 ], { a: "1", b: new Map([ [ "c", 8 ], ["d", 9 ] ]) } ],
87
- from: (target, test) => { return test.in[0].localInitors; } },
88
- { for: "Complex objects in .in are copied to .localInputs.", /* good */
89
- in: [ new TestTuple("", "", "", "", "", "", [ { "a": 1 }, { b: new Map([ [ "c", 6 ], [ "d", 7 ] ]) } ], "", "", "") ],
90
- out: [ { "a": 1 }, { b: new Map([ [ "c", 6 ], [ "d", 7 ] ]) } ],
91
- from: (target, test) => { return test.in[0].localInputs; } },
92
-
93
- { of: "compareResults", and: "nospoof" },
94
- { for: "Returns the result of calling TotalComparer . compare().", /* good */
95
- plus: [ { on: TotalComparer, of: "compare", as: "spoofed" } ],
96
- in: [ "A", "A" ], out: "spoofed" },
97
-
98
- ];
99
- }
@@ -1,140 +0,0 @@
1
- /**/
2
-
3
- import { ATestSource } from "../../node_modules/risei/public/javascript/ATestSource.js";
4
- import { TestTuple } from "../../system/TestTuple.js";
5
- import { PropertiesModel } from "../target-objects/PropertiesModel.js";
6
-
7
- /* Fixture values are more readily understood out here. */
8
- let nineEmpties = [ "", "", "", "", "", "", "", "", "" ];
9
-
10
- export class TestTupleTests extends ATestSource {
11
- tests = [
12
- { on: TestTuple, with: [ ] },
13
-
14
- /* &cruft, replace "constructor" with property under test, once that syntax is available */
15
-
16
- { of: "constructor", for: "When .and is \"static\", .isStaticTest returns true.", /* good */
17
- in: [ ...nineEmpties, "static" ], out: true, from: "isStaticTest" },
18
- { of: "constructor", for: "When .and contains \"static\", .isStaticTest returns true.", /* good */
19
- in: [ ...nineEmpties, "throws static" ], out: true, from: "isStaticTest" },
20
- { of: "constructor", for: "When .and doesn't contain \"static\", .isStaticTest returns false.", /* good */
21
- in: [ ...nineEmpties, "throw nospoof" ], out: false, from: "isStaticTest" },
22
- { of: "constructor", for: "When .and isn't a string, .isStaticTest returns false.", /* good */
23
- in: [ ...nineEmpties, [] ], out: false, from: "isStaticTest" },
24
-
25
- { of: "constructor", for: "When .and is \"static\", .isInstanceTest returns false.", /* good */
26
- in: [ ...nineEmpties, "static" ], out: false, from: "isInstanceTest" },
27
- { of: "constructor", for: "When .and contains \"static\", .isInstanceTest returns false.", /* good */
28
- in: [ ...nineEmpties, "throws static" ], out: false, from: "isInstanceTest" },
29
- { of: "constructor", for: "When .and doesn't contain \"static\", .isInstanceTest returns true.", /* good */
30
- in: [ ...nineEmpties, "throw nospoof" ], out: true, from: "isInstanceTest" },
31
- { of: "constructor", for: "When .and isn't a string, .isInstanceTest returns true.", /* good */
32
- in: [ ...nineEmpties, [] ], out: true, from: "isInstanceTest" },
33
- { of: "constructor", for: "When .of is \"constructor\", .isInstanceTest returns true even if .and contains \"static\".", /* good */
34
- in: [ "", "", "", "", "", "constructor", "", "", "", "static" ], out: true, from: "isInstanceTest" },
35
-
36
- { of: "constructor", for: "When .and is \"throw\", .isThrowTest returns true.", /* good */
37
- in: [ ...nineEmpties, "throw" ], out: true, from: "isThrowTest" },
38
- { of: "constructor", for: "When .and is \"throws\", .isThrowTest returns true.", /* good */
39
- in: [ ...nineEmpties, "throws" ], out: true, from: "isThrowTest" },
40
- { of: "constructor", for: "When .and contains \"throw\", .isThrowTest returns true.", /* good */
41
- in: [ ...nineEmpties, "throw static" ], out: true, from: "isThrowTest" },
42
- { of: "constructor", for: "When .and contains \"throws\", .isThrowTest returns true.", /* good */
43
- in: [ ...nineEmpties, "static throws" ], out: true, from: "isThrowTest" },
44
- { of: "constructor", for: "When .and doesn't contain \"throw\", .isThrowTest returns false.", /* good */
45
- in: [ ...nineEmpties, "static nospoof" ], out: false, from: "isThrowTest" },
46
- { of: "constructor", for: "When .and isn't a string, .isThrowTest returns false.", /* good */
47
- in: [ ...nineEmpties, { } ], out: false, from: "isThrowTest" },
48
-
49
- { on: TestTuple },
50
- { of: "andStringContains", for: "When .and isn't a string, returns false for a given arg.", /* good */
51
- with: [ ...nineEmpties, { } ], in: [ ], out: false, from: false },
52
- { of: "andStringContains", for: "When .and is a string but doesn't contain the arg, returns false.", /* good */
53
- with: [ ...nineEmpties, "no arg" ], in: [ "sought" ], out: false },
54
- { of: "andStringContains", for: "When .and is a string containing the arg, returns true.", /* good */
55
- with: [ ...nineEmpties, "contains sought" ], in: [ "sought" ], out: true },
56
-
57
- { on: TestTuple, with: [ ] },
58
- { of: "constructor", for: "When .of is not \"constructor\", .isConstructorTest returns false.", /* good */
59
- in: [ "", "", "", "", "", "someMethod", "", "", "", "" ], out: false, from: "isConstructorTest" },
60
- { of: "constructor", for: "When .of is \"constructor\", .isConstructorTest returns true.", /* good */
61
- in: [ "", "", "", "", "", "constructor", "", "", "", "" ], out: true, from: "isConstructorTest" },
62
- { of: "constructor", for: "When .of is \"constructor()\", .isConstructorTest returns true.", /* good */
63
- in: [ "", "", "", "", "", "constructor()", "", "", "", "" ], out: true, from: "isConstructorTest" },
64
-
65
- { of: "isRetrievalTest", plus: [ ] },
66
-
67
- /* Most of the false-like conditions as ninth arg (second to last). */
68
- { of: "constructor", for: "When .from is `false`, .isRetrievalTest returns false.", /* good */
69
- in: [ "", "", "", "", "", "", "", "", false, "" ], out: false, from: "isRetrievalTest" },
70
- { of: "constructor", for: "When .from is an empty string, .isRetrievalTest returns false.", /* good */
71
- in: [ "", "", "", "", "", "", "", "", "", "" ], out: false, from: "isRetrievalTest" },
72
- { of: "constructor", for: "When .from is an empty array, .isRetrievalTest returns false.", /* good */
73
- in: [ "", "", "", "", "", "", "", "", [], "" ], out: false, from: "isRetrievalTest" },
74
- { of: "constructor", for: "When .from is null, .isRetrievalTest returns false.", /* good */
75
- in: [ "", "", "", "", "", "", "", "", null, "" ], out: false, from: "isRetrievalTest" },
76
- { of: "constructor", for: "When .from is undefined, .isRetrievalTest returns false.", /* good */
77
- in: [ "", "", "", "", "", "", "", "", undefined, "" ], out: false, from: "isRetrievalTest" },
78
- { of: "constructor", for: "When .from is 0, .isRetrievalTest returns false.", /* good */
79
- in: [ "", "", "", "", "", "", "", "", 0, "" ], out: false, from: "isRetrievalTest" },
80
-
81
- /* Other conditions as ninth arg (second to last). */
82
- { of: "constructor", for: "When .from is a string, .isRetrievalTest returns true.", /* good */
83
- in: [ "", "", "", "", "", "", "", "", "property", "" ], out: true, from: "isRetrievalTest" },
84
- { of: "constructor", for: "When .from is a function, .isRetrievalTest returns true.", /* good */
85
- in: [ "", "", "", "", "", "", "", "", () => { return 9; }, "" ], out: true, from: "isRetrievalTest" },
86
-
87
-
88
- /* .isPropertyTest */
89
- { of: "constructor", for: "When .of starts with a dot (.), .isPropertyTest returns true regardless of type analysis.", /* good */
90
- in: [ "", PropertiesModel, "", "", "", ".staticMethod", "", "", "", "" ], out: true, from: "isPropertyTest" },
91
- { of: "constructor", for: "When .of ends with a colon (:), .isPropertyTest returns true regardless of type analysis.", /* good */
92
- in: [ "", PropertiesModel, "", "", "", "staticMethod:", "", "", "", "" ], out: true, from: "isPropertyTest" },
93
-
94
- { of: "constructor", for: "When .of is the plain name of an instance value property, .isPropertyTest returns true.", /* good */
95
- in: [ "", PropertiesModel, "", "", "", "valueProp", "", "", "", "" ], out: true, from: "isPropertyTest" },
96
- { of: "constructor", for: "When .of is the plain name of an instance accessor property, .isPropertyTest returns true.", /* good */
97
- in: [ "", PropertiesModel, "", "", "", "accessorProp", "", "", "", "" ], out: true, from: "isPropertyTest" },
98
- { of: "constructor", for: "When .of is the plain name of an instance method, .isPropertyTest returns false.", /* good */
99
- in: [ "", PropertiesModel, "", "", "", "instanceMethod", "", "", "", "" ], out: false, from: "isPropertyTest" },
100
-
101
- { of: "constructor", for: "When .of is the plain name of a static value property, .isPropertyTest returns true.", /* good */
102
- in: [ "", PropertiesModel, "", "", "", "staticValueProp", "", "", "", "" ], out: true, from: "isPropertyTest" },
103
- { of: "constructor", for: "When .of is the plain name of a static accessor property, .isPropertyTest returns true.", /* good */
104
- in: [ "", PropertiesModel, "", "", "", "staticAccessorProp", "", "", "", "" ], out: true, from: "isPropertyTest" },
105
- { of: "constructor", for: "When .of is the plain name of a static method, .isPropertyTest returns false.", /* good */
106
- in: [ "", PropertiesModel, "", "", "", "staticMethod", "", "", "", "" ], out: false, from: "isPropertyTest" },
107
-
108
- /* .isMethodTest */
109
- { of: "constructor", for: "When .of starts with a dot (.), .isMethodTest returns false regardless of type analysis.", /* good */
110
- in: [ "", PropertiesModel, "", "", "", ".instanceMethod", "", "", "", "" ], out: false, from: "isMethodTest" },
111
- { of: "constructor", for: "When .of ends with a colon (:), .isMethodTest returns false regardless of type analysis.", /* good */
112
- in: [ "", PropertiesModel, "", "", "", "instanceMethod:", "", "", "", "" ], out: false, from: "isMethodTest" },
113
-
114
- { of: "constructor", for: "When .of is the plain name of an instance value property, .isMethodTest returns false.", /* good */
115
- in: [ "", PropertiesModel, "", "", "", "valueProp", "", "", "", "" ], out: false, from: "isMethodTest" },
116
- { of: "constructor", for: "When .of is the plain name of an instance accessor property, .isMethodTest returns false.", /* good */
117
- in: [ "", PropertiesModel, "", "", "", "accessorProp", "", "", "", "" ], out: false, from: "isMethodTest" },
118
- { of: "constructor", for: "When .of is the plain name of an instance method, .isMethodTest returns true.", /* good */
119
- in: [ "", PropertiesModel, "", "", "", "instanceMethod", "", "", "", "" ], out: true, from: "isMethodTest" },
120
-
121
- { of: "constructor", for: "When .of is the plain name of a static value property, .isMethodTest returns false.", /* good */
122
- in: [ "", PropertiesModel, "", "", "", "staticValueProp", "", "", "", "" ], out: false, from: "isMethodTest" },
123
- { of: "constructor", for: "When .of is the plain name of a static accessor property, .isMethodTest returns false.", /* good */
124
- in: [ "", PropertiesModel, "", "", "", "staticAccessorProp", "", "", "", "" ], out: false, from: "isMethodTest" },
125
- { of: "constructor", for: "When .of is the plain name of a static method, .isMethodTest returns true.", /* good */
126
- in: [ "", PropertiesModel, "", "", "", "staticMethod", "", "", "", "" ], out: true, from: "isMethodTest" },
127
-
128
- { of: "plainNameOf", and: "static" },
129
- { for: "When arg contains a dot, returns the name without it.", /* good */
130
- in: [ ".plain" ], out: "plain" },
131
- { for: "When arg contains a colon, returns the name without it.", /* good */
132
- in: [ "plain:" ], out: "plain" },
133
- { for: "When arg contains parens, returns the name without them.", /* good */
134
- in: [ "plain()" ], out: "plain" },
135
- { for: "When arg contains a dot and colon, returns the name without them.", /* good */
136
- in: [ ".plain:" ], out: "plain" },
137
- { for: "When arg doesn't contain dot, colon, or parens, returns the name unchanged.", /* good */
138
- in: [ "plain" ], out: "plain" },
139
- ];
140
- }
@@ -1,184 +0,0 @@
1
- /**/
2
-
3
- import { ATestSource } from "../../node_modules/risei/public/javascript/ATestSource.js";
4
- import { TotalComparer } from "../../system/TotalComparer.js";
5
-
6
- export class TotalComparerTests extends ATestSource {
7
- // Used for tests of comparing objects.
8
- sameObject = { a: "b" };
9
-
10
- tests = [
11
- { on: TotalComparer, with: [ ] },
12
- { of: "compare" },
13
-
14
- // Comparing booleans. //
15
-
16
- { for: "Returns true when both args are true.", /* good */
17
- in: [ true, true ], out: true },
18
- { for: "Returns true when both args are false.", /* good */
19
- in: [ false, false ], out: true },
20
- { for: "Returns false when first arg is true and second is false.", /* good */
21
- in: [ true, false ], out: false },
22
- { for: "Returns false when first arg is false and second is true.", /* good */
23
- in: [ false, true ], out: false },
24
-
25
- // Comparing values. //
26
-
27
- { for: "Returns true when args are the same value.", /* good */
28
- in: [ 3, 3 ], out: true },
29
- { for: "Returns false when args are different values.", /* good */
30
- in: [ 3, 10 ], out: false },
31
- { for: "Returns false when args are the same value, but different types.", /* good */
32
- in: [ 18, "18" ], out: false },
33
-
34
- // Comparing dates. //
35
-
36
- { for: "Returns false when given a date and something else.", /* good */
37
- in: [ new Date("November 10, 2024"), "November 10, 2024" ],
38
- out: false },
39
- { for: "Returns false when dates are different values.", /* good */
40
- in: [ new Date("November 10, 2024"), new Date("November 12, 2024") ],
41
- out: false },
42
- { for: "Returns false when dates are the same, but times are different.", /* good */
43
- in: [ new Date("November 10, 2024 3:45 AM"), new Date("November 10, 2024 6:15 PM") ],
44
- out: false },
45
- { for: "Returns true when dates are the same value.", /* good */
46
- in: [ new Date("November 10, 2024"), new Date("November 10, 2024") ],
47
- out: true },
48
- { for: "Returns true when dates and times are the same value.", /* good */
49
- in: [ new Date("November 10, 2024 8:22 PM"), new Date("November 10, 2024 8:22 PM") ],
50
- out: true },
51
-
52
- // Comparing arrays. //
53
-
54
- /* &cruft, tests of arrays of different JS-defined objects, like Maps */
55
-
56
- { for: "Returns false when given an array and something else.", /* good */
57
- in: [ [ 2, 4, 9 ], "text" ],
58
- out: false },
59
- { for: "Returns false when given different arrays.", /* good */
60
- in: [ [ 2, 4, 7 ], [ 2, 5, 6 ] ],
61
- out: false },
62
- { for: "Returns false when `expected` array has more elements.", /* good */
63
- in: [ [ 2, 4, 7, 18 ], [ 2, 4, 7 ] ],
64
- out: false },
65
- { for: "Returns false when `actual` array has more elements.", /* good */
66
- in: [ [ 2, 4, 7 ], [ 2, 4, 7, 9 ] ],
67
- out: false },
68
- { for: "Returns true when given arrays with equal contents.", /* good */
69
- in: [ [ 2, 4, "7", 9 ], [ 2, 4, "7", 9 ] ],
70
- out: true },
71
- { for: "Returns true when given arrays with identical objects.", /* good */
72
- in: [ [ { a: 1, b: "2" }, { c: true, d: 3 } ],
73
- [ { a: 1, b: "2" }, { c: true, d: 3 } ] ],
74
- out: true },
75
- { for: "Returns false when given arrays with different objects.", /* good */
76
- in: [ [ { a: 1, b: "2" }, { c: true, d: 3 } ],
77
- [ { a: 1, b: "2" }, { c: true, notD: 3 } ] ],
78
- out: false },
79
-
80
- // Comparing Maps. //
81
-
82
- /* &cruft, tests of Maps of different JS-defined objects, like arrays */
83
-
84
- { for: "Returns false when given a (tree'd) Map and something else.", /* good */
85
- in: [ new Map( [ [ "One", new Map( [ [ "TypeA", "a" ], [ "TypeC", "c" ] ] ) ],
86
- [ "Two", new Map( [ [ "TypeB", "b" ], [ "TypeD", "d" ] ] ) ] ] ),
87
- "text" ],
88
- out: false },
89
- { for: "Returns false when given flat Maps with different contents.", /* good */
90
- in: [ new Map( [ [ "A", 1 ], [ "B", 2 ], [ "C", 3 ] ] ),
91
- new Map( [ [ "A", 3 ], [ "B", 2 ], [ "C", 1 ] ] ) ],
92
- out: false },
93
- { for: "Returns false when `actual` flat Map has fewer elements.", /* good */
94
- in: [ new Map( [ [ "A", 1 ], [ "B", 2 ], [ "C", 3 ] ] ),
95
- new Map( [ [ "A", 1 ], [ "C", 3 ] ] ) ],
96
- out: false },
97
- { for: "Returns false when `actual` flat Map has more elements.", /* good */
98
- in: [ new Map( [ [ "A", 1 ], [ "C", 3 ] ] ),
99
- new Map( [ [ "A", 1 ], [ "B", 2 ], [ "C", 3 ] ] ) ],
100
- out: false },
101
- { for: "Returns true when given flat Maps with equal contents.", /* good */
102
- in: [ new Map([ [ "A", 1 ], [ "B", 2 ], [ "C", 3 ] ]),
103
- new Map([ [ "A", 1 ], [ "B", 2 ], [ "C", 3 ] ]) ],
104
- out: true },
105
- { for: "Returns false when given two tree'd Maps with different contents.", /* good */
106
- in: [
107
- new Map( [ [ "One", new Map( [ [ "TypeA", "a" ], [ "TypeC", "c" ] ] ) ],
108
- [ "Two", new Map( [ [ "TypeB", "b" ], [ "TypeD", "d" ] ] ) ] ] ),
109
- new Map( [ [ "One", new Map( [ [ "TypeA", "a" ], [ "TypeC", "d" ] ] ) ],
110
- [ "Two", new Map( [ [ "TypeB", "b" ], [ "TypeD", "c" ] ] ) ] ] )
111
- ],
112
- out: false },
113
- { for: "Returns false when given two tree'd Maps, if the `actual` is missing a leaf.", /* good */
114
- in: [ new Map( [ [ "One", new Map( [ [ "TypeA", "a" ], [ "TypeC", "c" ] ] ) ],
115
- [ "Two", new Map( [ [ "TypeB", "b" ], [ "TypeD", "d" ] ] ) ] ] ),
116
- new Map([ [ "One", new Map( [ [ "TypeA", "a" ] ]) ],
117
- [ "Two", new Map( [ [ "TypeB", "b" ], [ "TypeD", "d" ] ] ) ] ] ) ],
118
- out: false },
119
- { for: "Returns false when given two tree'd Maps, if the `actual` has an extra leaf.", /* good */
120
- in: [ new Map( [ [ "One", new Map( [ [ "TypeA", "a" ] ] ) ],
121
- [ "Two", new Map( [ [ "TypeB", "b" ], [ "TypeD", "d" ] ] ) ] ] ),
122
- new Map( [ [ "One", new Map( [ [ "TypeA", "a" ], [ "TypeC", "c" ] ] ) ],
123
- [ "Two", new Map( [ [ "TypeB", "b" ], [ "TypeD", "d" ] ] ) ] ] ) ],
124
- out: false },
125
- { for: "Returns true when given two Maps of Maps, if their contents are equivalent.", /* good */
126
- in: [ new Map( [ [ "One", new Map( [ [ "TypeA", "a" ], [ "TypeC", "c" ] ] ) ],
127
- [ "Two", new Map([ [ "TypeB", "b" ], [ "TypeD", "d" ] ] ) ] ] ),
128
- new Map( [ [ "One", new Map( [ [ "TypeA", "a" ], [ "TypeC", "c" ] ] ) ],
129
- [ "Two", new Map( [ [ "TypeB", "b" ], [ "TypeD", "d" ] ] ) ] ] ) ],
130
- out: true },
131
-
132
- // Comparing objects. //
133
-
134
- // { on: TotalComparer, with: [ ] },
135
- // { of: "compare" },
136
- // { plus: [ { of: "compare", as: "fails" } ] },
137
-
138
- /* &cruft, probably tests here with other JS-defined types, like Maps, as object members */
139
-
140
- { for: "Returns false when given an object and a value.", /* good */
141
- in: [ { seven: 7 }, 7 ],
142
- out: false },
143
- { for: "Returns true when given the same object for both args.", /* good */
144
- in: [ this.sameObject, this.sameObject ],
145
- out: true },
146
- { for: "Returns false when given two flat objects, if different member values.", /* good */
147
- in: [ { a: "b", d: "e" }, { a: "c", d: "e" } ],
148
- out: false },
149
- { for: "Returns false when given two flat objects, if `actual` missing a member.", /* good */
150
- in: [ { a: "b", d: "e" }, { a: "b" } ],
151
- out: false },
152
- { for: "Returns false when given two flat objects, if extra `actual` member.", /* good */
153
- in: [ { a: "b" }, { a: "b", d: "e" } ],
154
- out: false },
155
- { for: "Returns false when given two flat objects, if different members.", /* good */
156
- in: [ { a: "b" }, { c: "b" } ],
157
- out: false },
158
- { for: "Returns true when given two flat objects, if same member values.", /* good */
159
- in: [ { a: "b", d: "e" }, { a: "b", d: "e" } ],
160
- out: true },
161
- { for: "Returns false when given two deep objects with different object members.", /* good */
162
- in: [ { a: "b", c: { d: "e" } }, { a: "b", c: { f: "g" } } ],
163
- out: false },
164
- { for: "Returns false when given two deep objects, if the `actual` is missing a leaf value.", /* good */
165
- in: [ { a: "b", c: { d: "e", f: "g" } }, { a: "b", c: { f: "g" } } ],
166
- out: false },
167
- { for: "Returns false when given two deep objects, if the `actual` has an extra leaf value.", /* good */
168
- in: [ { a: "b", c: { d: "e" } }, { a: "b", c: { d: "e", f: "g" } } ],
169
- out: false },
170
- { for: "Returns true when given two deep objects with equivalent members.", /* good */
171
- in: [ { a: "b", c: { d: "e" } }, { a: "b", c: { d: "e" } } ],
172
- out: true },
173
- { for: "Returns false when given two flat objects with different method members.", /* good */
174
- in: [ { a: "a", b: function () { return true; } },
175
- { a: "a", b: function () { return false; } } ],
176
- out: false },
177
- { for: "Returns true when given two flat objects with equivalent method members.", /* good */
178
- in: [ { a: "a", b: function () { return true; } },
179
- { a: "a", b: function () { return true; } } ],
180
- out: true },
181
-
182
-
183
- ];
184
- }
@@ -1,74 +0,0 @@
1
- /**/
2
-
3
- import { ATestSource } from "../../node_modules/risei/public/javascript/ATestSource.js";
4
- import { TotalCopier } from "../../system/TotalCopier.js";
5
-
6
- export class TotalCopierTests extends ATestSource {
7
- tests = [
8
- /* &cruft, when .from that addresses .actual is possible, ensure that copied objects,
9
- including Date instances, are separate copies, using Object.is() in .from */
10
-
11
- { on: TotalCopier, with: [ ] },
12
- { of: "copy", and: "nospoof" },
13
-
14
- { for: "When given a number, returns the same number.", /* good */
15
- in: [ 21 ], out: 21 },
16
- { for: "When given a string, returns the same string.", /* good */
17
- in: [ "text" ], out: "text" },
18
- { for: "When given a boolean, returns the same boolean.", /* good */
19
- in: [ true ], out: true },
20
-
21
- /* &cruft, re-verify this test once Date comparisons are working where needed */
22
- { for: "When given a Date, returns the same Date.", /* good */
23
- in: [ new Date(674831567923) ], out: new Date(674831567923) },
24
-
25
- { for: "When given a flat object of values, returns the equivalent.", /* good */
26
- in: [ { first: "a", second: 1, third: "3rd" } ], out: { first: "a", second: 1, third: "3rd" } },
27
- { for: "When given a flat array of values, returns the equivalent.", /* good */
28
- in: [ [ "a", 1, "c", 3 ] ], out: [ "a", 1, "c", 3 ] },
29
- { for: "When given a flat Map of values, returns the equivalent.", /* good */
30
- in: [ new Map( [ [ "a", 1 ], [ "c", 3 ] ] ) ], out: new Map( [ [ "a", 1 ], [ "c", 3 ] ] ) },
31
- { for: "When given a flat Map of values, returns the equivalent.", /* good */
32
- in: [ new Set( [ "a", 2, "E", 3.0 ] ) ], out: new Set( [ "a", 2, "E", 3.0 ] ) },
33
-
34
- { for: "When given an array of mixed values and arrays, returns the equivalent.", /* good */
35
- in: [ [ "a", /* Inner arrays: */ [ 1 ], [ "c", 3 ] ] ], out: [ "a", [ 1 ], [ "c", 3 ] ] },
36
-
37
- { for: "When given an object of mixed values and objects, returns the equivalent.", /* good */
38
- in: [ { a: "a", /* Inner objects: */ b: { one: 1 }, c: { c: "c", three: 3 } } ],
39
- out: { a: "a", b: { one: 1 }, c: { c: "c", three: 3 } } },
40
-
41
- { for: "When given a tree of mixed arrays, objects, Maps, Sets, Dates, and values, returns the equivalent.", /* good */
42
- in: [
43
- { a: "a",
44
- b: [ 1, 2 ],
45
- c: { c: "c",
46
- three: new Map( [
47
- [ "d", 6 ],
48
- [ "g", new Date("October 14, 1999 10:05 PM") ],
49
- [ "h",
50
- new Set( [
51
- 7, 8, 9, { ten: 10, eleven: [ 11, "11" ] }
52
- ] )
53
- ]
54
- ] ) }
55
- } ],
56
- out:
57
- { a: "a",
58
- b: [ 1, 2 ],
59
- c: { c: "c",
60
- three: new Map( [
61
- [ "d", 6 ],
62
- [ "g", new Date("October 14, 1999 10:05 PM") ],
63
- [ "h",
64
- new Set( [
65
- 7, 8, 9,
66
- { ten: 10, eleven: [ 11, "11" ] }
67
- ] )
68
- ]
69
- ] ) } }
70
- },
71
-
72
- ];
73
- }
74
-