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.
- package/README.md +3 -1
- package/index.js +1 -1
- package/package.json +4 -4
- package/tests/other-tests/ASpoofingFixture.tests.js +0 -242
- package/tests/other-tests/SpoofClassesFixture.tests.js +0 -130
- package/tests/other-tests/SpoofObjectsFixture.tests.js +0 -95
- package/tests/other-tests/SpoofTuple.tests.js +0 -93
- package/tests/other-tests/TotalComparer.tests.js +0 -920
- package/tests/other-tests/package.json +0 -7
- package/tests/risei-tests/ASpoofingFixtureTests.rt.js +0 -51
- package/tests/risei-tests/MomentTests.rt.js +0 -103
- package/tests/risei-tests/SpoofTupleTests.rt.js +0 -274
- package/tests/risei-tests/TestFrameChooserTests.rt.js +0 -74
- package/tests/risei-tests/TestFrameTests.rt.js +0 -84
- package/tests/risei-tests/TestStagesTests.rt.js +0 -99
- package/tests/risei-tests/TestTupleTests.rt.js +0 -140
- package/tests/risei-tests/TotalComparerTests.rt.js +0 -184
- package/tests/risei-tests/TotalCopierTests.rt.js +0 -74
- package/tests/risei-tests/TotalDisplayerTests.rt.js +0 -186
- package/tests/risei-tests/TypeAnalyzerTests.rt.js +0 -29
- package/tests/risei-tests/TypeIdentifierTests.rt.js +0 -44
- package/tests/self-tests/SelfTests.outward-rt.js +0 -583
- package/tests/target-objects/CompositionModel.js +0 -38
- package/tests/target-objects/ConditionalThrowModel.js +0 -11
- package/tests/target-objects/CountModel.js +0 -46
- package/tests/target-objects/DomModel.js +0 -37
- package/tests/target-objects/MixedContents.js +0 -33
- package/tests/target-objects/MutationModel.js +0 -27
- package/tests/target-objects/ObjectCompositionModel.js +0 -34
- package/tests/target-objects/PolySpoofableInner.js +0 -30
- package/tests/target-objects/PolySpoofableOuter.js +0 -52
- package/tests/target-objects/PropertiesModel.js +0 -47
- package/tests/target-objects/Returner.js +0 -9
- package/tests/target-objects/SearchModel.js +0 -25
- package/tests/target-objects/SortModel.js +0 -91
- package/tests/target-objects/SpoofCaller.js +0 -24
- package/tests/target-objects/Spoofable.js +0 -36
- package/tests/target-objects/SpoofableArgsCaller.js +0 -33
- package/tests/target-objects/StateModel.js +0 -34
- package/tests/target-objects/StaticModel.js +0 -17
- package/tests/target-objects/TestableModel.js +0 -47
- package/tests/topic-tests/TopicTests.outward-rt.js +0 -354
|
@@ -1,583 +0,0 @@
|
|
|
1
|
-
/**/
|
|
2
|
-
|
|
3
|
-
import { ATestSource } from "../../node_modules/risei/public/javascript/ATestSource.js";
|
|
4
|
-
import { Moment } from "../../system/Moment.js";
|
|
5
|
-
|
|
6
|
-
import { SpoofCaller } from "../target-objects/SpoofCaller.js";
|
|
7
|
-
import { SpoofTuple } from "../../system/SpoofTuple.js";
|
|
8
|
-
import { Spoofable } from "../target-objects/Spoofable.js";
|
|
9
|
-
import { SpoofableArgsCaller } from "../target-objects/SpoofableArgsCaller.js";
|
|
10
|
-
import { PolySpoofableOuter } from "../target-objects/PolySpoofableOuter.js";
|
|
11
|
-
import { PolySpoofableInner } from "../target-objects/PolySpoofableInner.js";
|
|
12
|
-
import { ConditionalThrowModel } from "../target-objects/ConditionalThrowModel.js";
|
|
13
|
-
import { ObjectCompositionModel } from "../target-objects/ObjectCompositionModel.js";
|
|
14
|
-
import { MixedContents } from "../target-objects/MixedContents.js";
|
|
15
|
-
import { Returner } from "../target-objects/Returner.js";
|
|
16
|
-
import { MutationModel } from "../target-objects/MutationModel.js";
|
|
17
|
-
|
|
18
|
-
export class SelfTests extends ATestSource {
|
|
19
|
-
// region Fields
|
|
20
|
-
|
|
21
|
-
#sameObject = { a: "b" };
|
|
22
|
-
|
|
23
|
-
// endregion Fields
|
|
24
|
-
|
|
25
|
-
// region Tests
|
|
26
|
-
|
|
27
|
-
tests = [
|
|
28
|
-
{ on: Moment, of: "asReadable" },
|
|
29
|
-
/* The date-time input is in the constructor arguments, so .with, and no .in contents are needed. */
|
|
30
|
-
/* Without final `Z`, the long date-time formats used are local times. */
|
|
31
|
-
|
|
32
|
-
{ for: "When given a date with a time before noon, returns less than twelve and AM.", /* good */
|
|
33
|
-
with: [ new Date("2024-10-08T08:45:37.143") ],
|
|
34
|
-
in: [], out: "10/08/2024 at 8:45:37 AM" },
|
|
35
|
-
{ for: "When given a date with a time after noon, returns greater than twelve and PM.", /* good */
|
|
36
|
-
with: [ new Date("2024-10-08T18:45:37.143") ],
|
|
37
|
-
in: [], out: "10/08/2024 at 6:45:37 PM" },
|
|
38
|
-
{ for: "When given a date with noon, returns twelve and PM.", /* good */
|
|
39
|
-
with: [ new Date("2026-08-10T12:00:00.000") ],
|
|
40
|
-
in: [], out: "8/10/2026 at 12:00:00 PM" },
|
|
41
|
-
{ for: "When given a date with midnight, returns twelve and AM.", /* good */
|
|
42
|
-
with: [ new Date("2026-08-10T24:00:00.000") ],
|
|
43
|
-
in: [], out: "8/11/2026 at 12:00:00 AM" }, /* Midnight of day D is treated as day D +1. */
|
|
44
|
-
{ for: "When given a date with a time in the noon hour, returns twelve and PM.", /* good */
|
|
45
|
-
with: [ new Date("2024-10-08T12:21:07.143") ],
|
|
46
|
-
in: [], out: "10/08/2024 at 12:21:07 PM" },
|
|
47
|
-
{ for: "When given a date with a time in the midnight hour, returns twelve and AM.", /* good */
|
|
48
|
-
with: [ new Date("2024-10-08T00:21:07.143") ],
|
|
49
|
-
in: [], out: "10/08/2024 at 12:21:07 AM" },
|
|
50
|
-
|
|
51
|
-
{ for: "When given a date with a one-digit day, returns day with a leading zero.", /* good */
|
|
52
|
-
with: [ new Date("2026-10-07T13:03:02.000") ],
|
|
53
|
-
in: [], out: "10/07/2026 at 1:03:02 PM" },
|
|
54
|
-
{ for: "When given a date with a two-digit day, returns day digits unchanged.", /* good */
|
|
55
|
-
with: [ new Date("2026-08-12T14:06:02.000") ],
|
|
56
|
-
in: [], out: "8/12/2026 at 2:06:02 PM" },
|
|
57
|
-
{ for: "When given a date with a month less than ten, returns month without a leading zero.", /* good */
|
|
58
|
-
with: [ new Date("2024-06-16T10:24:12.000") ],
|
|
59
|
-
in: [], out: "6/16/2024 at 10:24:12 AM" },
|
|
60
|
-
{ for: "When given a date with a month greater than ten, returns month unchanged.", /* good */
|
|
61
|
-
with: [ new Date("2024-11-16T10:32:14.000") ],
|
|
62
|
-
in: [], out: "11/16/2024 at 10:32:14 AM" },
|
|
63
|
-
{ for: "When given a date in January, returns month of 1, not 0.", /* good */
|
|
64
|
-
with: [ new Date("2028-01-14T23:23:43.000") ], /* JS internal month handling (only) is zero-based. */
|
|
65
|
-
in: [], out: "1/14/2028 at 11:23:43 PM" },
|
|
66
|
-
|
|
67
|
-
/* &cruft, remove these indirect tests of SCF when direct tests are finished and all passing */
|
|
68
|
-
{ on: Spoofable, with: [] },
|
|
69
|
-
{ for: "When SCF is used to spoof with no return value, a call to the spoofed method doesn't return anything.", /* good */
|
|
70
|
-
plus: [ { of: "spoofNumber" } ], /* The actual spoofing. */
|
|
71
|
-
/* Calling indirectly so that .out doesn't have to be `undefined`. */
|
|
72
|
-
of: "callSpoofNumber",
|
|
73
|
-
in: [ 8, 17 ],
|
|
74
|
-
/* Can't set .out to `undefined`, since it's not a full test then. */
|
|
75
|
-
out: "spoofNumber() internal call: no return value"
|
|
76
|
-
},
|
|
77
|
-
{ for: "When SCF is used to spoof with a return value, the spoofed method returns that value.", /* good */
|
|
78
|
-
plus: [ { of: "spoofNumber", as: 10 } ], /* The actual spoofing. */
|
|
79
|
-
of: "spoofNumber", in: [ 8, 17 ], out: 10 },
|
|
80
|
-
{ for: "When SCF is used to spoof with a return simple object, the spoofed method returns that object.", /* good */
|
|
81
|
-
plus: [ { of: "spoofNumber", as: { a: 3, b: "4", c: 5, d: "six" } } ], /* The actual spoofing. */
|
|
82
|
-
of: "spoofNumber", in: [ 8, 17 ], out: { a: 3, b: "4", c: 5, d: "six" } },
|
|
83
|
-
{ for: "When SCF is used to spoof with a return specialized object, the spoofed method returns that object.", /* good */
|
|
84
|
-
plus: [ { of: "spoofNumber", as: new Map([[1, "first"], [2, "second"]]) } ], /* The actual spoofing. */
|
|
85
|
-
of: "spoofNumber", in: [ 7, 18 ], out: new Map([[1, "first"], [2, "second"]]) },
|
|
86
|
-
|
|
87
|
-
{ for: "When SCF is used to spoof with code, the spoofed method enacts that code.", /* good */
|
|
88
|
-
plus: [ { of: "spoofNumber", as: function (a, b) { return a - b; } } ],
|
|
89
|
-
of: "spoofNumber", in: [ 12, 8 ], out: 4 },
|
|
90
|
-
{ for: "When SCF is used to spoof with code, the method definition matches the spoof.", /* good */
|
|
91
|
-
plus: [ { of: "spoofNumber", as: (a, b) => { return a * b; } } ],
|
|
92
|
-
of: "spoofNumber", in: [ 12, 12 ], out: (a, b) => { return a * b; },
|
|
93
|
-
from: (target) => {
|
|
94
|
-
let prototype = Object.getPrototypeOf(target);
|
|
95
|
-
return prototype.spoofNumber;
|
|
96
|
-
}
|
|
97
|
-
},
|
|
98
|
-
|
|
99
|
-
{ for: "When SCF is not used to spoof a method, the original method definition still exists.", /* good */
|
|
100
|
-
of: "spoofNumber",
|
|
101
|
-
plus: [ ], /* Nothing is spoofed, but existing spoofing must be cleared. */
|
|
102
|
-
in: [ 12, 12 ], out: function spoofNumber(a, b) { return a + b; },
|
|
103
|
-
from: (target) => {
|
|
104
|
-
let prototype = Object.getPrototypeOf(target);
|
|
105
|
-
return prototype.spoofNumber;
|
|
106
|
-
}
|
|
107
|
-
},
|
|
108
|
-
|
|
109
|
-
{ for: "When SCF is used with a definition provided to .plus by a function call, the spoof is used.", /* good */
|
|
110
|
-
of: "spoofNumber",
|
|
111
|
-
plus: this.supplySingleElementSpoofArray(),
|
|
112
|
-
in: [ 12, 12 ], out: 32
|
|
113
|
-
},
|
|
114
|
-
|
|
115
|
-
{ for: "When SCF is used to spoof a method before a non-spoofing .plus of false, the spoof is used.", /* good */
|
|
116
|
-
of: "spoofNumber",
|
|
117
|
-
plus: [ { of: "spoofNumber", as: 628 } ],
|
|
118
|
-
in: [ 12, 12 ], out: 628
|
|
119
|
-
},
|
|
120
|
-
|
|
121
|
-
{ for: "When a method is called with .plus of false, no spoofing is performed.", /* good */
|
|
122
|
-
of: "spoofNumber",
|
|
123
|
-
plus: false,
|
|
124
|
-
in: [ 12, 12 ], out: 24
|
|
125
|
-
},
|
|
126
|
-
|
|
127
|
-
{ for: "When SCF is used to spoof a method before a non-spoofing .plus of { }, the spoof is used.", /* good */
|
|
128
|
-
of: "spoofNumber",
|
|
129
|
-
plus: [ { of: "spoofNumber", as: 645 } ],
|
|
130
|
-
in: [ 12, 12 ], out: 645
|
|
131
|
-
},
|
|
132
|
-
|
|
133
|
-
{ for: "When a method is called with .plus of { }, no spoofing is performed.", /* good */
|
|
134
|
-
of: "spoofNumber",
|
|
135
|
-
plus: { },
|
|
136
|
-
in: [ 12, 12 ], out: 24
|
|
137
|
-
},
|
|
138
|
-
|
|
139
|
-
{ on: ObjectCompositionModel, with: [] },
|
|
140
|
-
{ for: "When SCF is used to spoof a method to return a deep object " +
|
|
141
|
-
"that is invoked internally, the spoofed deep object is used." /* good */,
|
|
142
|
-
plus: [ { of: "supplySomeObject", as: [ { of: "outer.inner.callable", as: 18 } ] } ],
|
|
143
|
-
of: "enact",
|
|
144
|
-
in: [ ["outer", "inner" ], "callable" ],
|
|
145
|
-
out: 18
|
|
146
|
-
},
|
|
147
|
-
{ for: "When SCF is used to spoof a method to return a branched deep " +
|
|
148
|
-
"object that is invoked internally, both branches are used.", /* good */
|
|
149
|
-
plus: [ { of: "supplySomeObject",
|
|
150
|
-
as: [
|
|
151
|
-
{ of: "outer.inner.callableOne", as: 16 },
|
|
152
|
-
{ of: "outer.inner.callableTwo", as: 20 }
|
|
153
|
-
] }
|
|
154
|
-
],
|
|
155
|
-
of: "doubleEnact",
|
|
156
|
-
in: [ [ "outer", "inner" ], "callableOne", [ "outer", "inner" ], "callableTwo" ],
|
|
157
|
-
out: [ 16, 20 ]
|
|
158
|
-
},
|
|
159
|
-
|
|
160
|
-
{ on: SpoofCaller, with: [] },
|
|
161
|
-
{ for: "When a spoof that returns a value is called, it returns that value.", /* good */
|
|
162
|
-
of: "runSpoof", in: [ "returnFifteen", 15 ], out: 15 },
|
|
163
|
-
{ for: "When a spoof that returns a text is called, it returns that text.", /* good */
|
|
164
|
-
of: "runSpoof", in: [ "returnText", "return-text" ], out: "return-text" },
|
|
165
|
-
{ for: "When a spoof that is a text-returning nonce function is called, it returns that value.", /* good */
|
|
166
|
-
of: "runSpoof", in: [ "nonceText", () => { return "nonce-text"; } ], out: "nonce-text" },
|
|
167
|
-
|
|
168
|
-
{ on: SpoofableArgsCaller },
|
|
169
|
-
{ for: "When .with contains a spoof definition and there is no \"nospoof\" in .and, the spoof is used.", /* good */
|
|
170
|
-
with: [ { of: "number", as: 594 } ],
|
|
171
|
-
of: "callConstructorArg",
|
|
172
|
-
and: "something",
|
|
173
|
-
in: [ ],
|
|
174
|
-
out: 594
|
|
175
|
-
},
|
|
176
|
-
{ for: "When .with contains a spoof definition but there is \"nospoof\" in .and, the spoof is not used.", /* good */
|
|
177
|
-
with: [ { of: "number", as: 594 } ],
|
|
178
|
-
of: "callConstructorArg",
|
|
179
|
-
and: "nospoof something",
|
|
180
|
-
in: [ ],
|
|
181
|
-
out: "this.#cArg.of: number, this.#cArg.as: 594"
|
|
182
|
-
},
|
|
183
|
-
{ for: "When .in contains a spoof definition and there is no \"nospoof\" in .and, the spoof is used.", /* good */
|
|
184
|
-
of: "callMethodArg",
|
|
185
|
-
and: "something",
|
|
186
|
-
in: [ { of: "text", as: "spoofed-text" } ],
|
|
187
|
-
out: "spoofed-text"
|
|
188
|
-
},
|
|
189
|
-
{ for: "When .in contains a spoof definition but there is \"nospoof\" in .and, the spoof is not used.", /* good */
|
|
190
|
-
of: "callMethodArg",
|
|
191
|
-
and: "something nospoof",
|
|
192
|
-
in: [ { of: "text", as: "spoofed" } ],
|
|
193
|
-
out: "mArg.of: text, mArg.as: spoofed"
|
|
194
|
-
},
|
|
195
|
-
|
|
196
|
-
{ on: PolySpoofableOuter, with: [] },
|
|
197
|
-
{ for: "When nothing is spoofed, the original ops and args are used.", /* good */
|
|
198
|
-
of: "combinedNumbers",
|
|
199
|
-
in: [ { supplyA: () => { return 4; }, supplyB: () => { return 2; } } ],
|
|
200
|
-
out: 36 /* (4 + 2) ^^ (4 - 2) = 6 ^^ 2 */
|
|
201
|
-
},
|
|
202
|
-
{ for: "When args only are spoofed, the original ops are used.", /* good */
|
|
203
|
-
of: "combinedNumbers",
|
|
204
|
-
in: [ { as: [ { of: "supplyA", as: 10 }, { of: "supplyB", as: 7 } ] } ],
|
|
205
|
-
out: 4913 /* (10 + 7) ^^ (10 - 7) = 17 ^^ 3 */
|
|
206
|
-
},
|
|
207
|
-
{ for: "When class methods only are spoofed, the spoofed methods are used.", /* good */
|
|
208
|
-
of: "combinedNumbers",
|
|
209
|
-
plus: [ { on: PolySpoofableInner,
|
|
210
|
-
as: [ { of: "addOrTimes", as: (numbers) => { return numbers.supplyA() * numbers.supplyB(); } },
|
|
211
|
-
{ of: "minusOrOver", as: (numbers) => { return numbers.supplyA() / numbers.supplyB(); } }
|
|
212
|
-
]
|
|
213
|
-
}
|
|
214
|
-
],
|
|
215
|
-
in: [ { supplyA: () => { return 6; }, supplyB: () => { return 2; } } ],
|
|
216
|
-
out: 1728 /* (6 * 2) ^^ (6 / 2) */
|
|
217
|
-
},
|
|
218
|
-
{ for: "When methods of two classes are spoofed, the spoofs of both are used.", /* good */
|
|
219
|
-
of: "combinedNumbers",
|
|
220
|
-
plus: [ { on: PolySpoofableOuter,
|
|
221
|
-
of: "combiner",
|
|
222
|
-
as: (first, second) => {
|
|
223
|
-
let netLog = Math.log(second) / Math.log(first);
|
|
224
|
-
return Number(netLog.toString().slice(0, 4));
|
|
225
|
-
}
|
|
226
|
-
},
|
|
227
|
-
{ on: PolySpoofableInner,
|
|
228
|
-
as: [ { of: "addOrTimes", as: (numbers) => { return 2; } },
|
|
229
|
-
{ of: "minusOrOver", as: (numbers) => { return 8; } }
|
|
230
|
-
]
|
|
231
|
-
}
|
|
232
|
-
],
|
|
233
|
-
in: [ { supplyA: () => { return 7; }, supplyB: () => { return 4; } } ],
|
|
234
|
-
out: 3 /* log base 2 of 8 */
|
|
235
|
-
},
|
|
236
|
-
{ for: "When two methods of an object are spoofed, both spoofs are used", /* good */
|
|
237
|
-
of: "combinedArgAAndB",
|
|
238
|
-
in: [ { as: [
|
|
239
|
-
{ of: "supplyA", as: 18 },
|
|
240
|
-
{ of: "supplyB", as: 14 }
|
|
241
|
-
]
|
|
242
|
-
}
|
|
243
|
-
],
|
|
244
|
-
out: 32 /* 18 + 14 */
|
|
245
|
-
},
|
|
246
|
-
{ for: "When two methods of an object hosted on an object are spoofed, both spoofs are used", /* good */
|
|
247
|
-
of: "combinedArgHostedCAndD",
|
|
248
|
-
in: [ { as: [
|
|
249
|
-
{ of: "numberHost.supplyC", as: 14 },
|
|
250
|
-
{ of: "numberHost.supplyD", as: 11 }
|
|
251
|
-
]
|
|
252
|
-
}
|
|
253
|
-
],
|
|
254
|
-
out: 3 /* 14 - 11 */
|
|
255
|
-
},
|
|
256
|
-
|
|
257
|
-
{ on: ConditionalThrowModel, of: "returnArgOrThrow", with: [ ] },
|
|
258
|
-
{ for: "When arg is provided, returns the arg.", /* good */
|
|
259
|
-
in: [ "some-arg" ], out: "some-arg" },
|
|
260
|
-
{ for: "When no arg is provided, but .and contains \"throws\", throws expected message.", /* good */
|
|
261
|
-
and: "throws something",
|
|
262
|
-
in: [ ], out: "No arg provided." },
|
|
263
|
-
{ for: "When no arg is provided, but .and contains \"throw\", throws expected message.", /* good */
|
|
264
|
-
and: "something throw",
|
|
265
|
-
in: [ ], out: "No arg provided." },
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
{ on: SpoofTuple, with: [] },
|
|
269
|
-
|
|
270
|
-
/* SpoofTuple static methods. */
|
|
271
|
-
{ of: "combineValues", and: "static" },
|
|
272
|
-
{ for: "With a property on `other` but not `self`, value on `other` is applied to `self`.", /* good */
|
|
273
|
-
in: [
|
|
274
|
-
{ target: "on-arg", method: "of-arg", not: true },
|
|
275
|
-
{ target: "on-arg", method: "of-arg", output: "other-as", not: true },
|
|
276
|
-
"output"
|
|
277
|
-
],
|
|
278
|
-
out: "other-as",
|
|
279
|
-
from: (target, test) => {
|
|
280
|
-
let self = test.in[0]; // The input arg has been mutated.
|
|
281
|
-
return self.output;
|
|
282
|
-
}
|
|
283
|
-
},
|
|
284
|
-
{ for: "With a property already defined on `self`, value on `other` is not applied to `self`.", /* good */
|
|
285
|
-
in: [
|
|
286
|
-
{ target: "on-arg", method: "of-arg", output: "self-as", not: true },
|
|
287
|
-
{ target: "on-arg", method: "of-arg", output: "other-as", not: true },
|
|
288
|
-
"output"
|
|
289
|
-
],
|
|
290
|
-
out: "self-as",
|
|
291
|
-
from: (target, test) => {
|
|
292
|
-
let self = test.in[0]; // The input arg has been mutated.
|
|
293
|
-
return self.output;
|
|
294
|
-
}
|
|
295
|
-
},
|
|
296
|
-
{ for: "When a property is undefined on `self` and `other`, it remains undefined.", /* good */
|
|
297
|
-
in: [
|
|
298
|
-
{ target: "on-arg", output: "as-arg", not: true },
|
|
299
|
-
{ target: "on-arg", output: "as-arg", not: true },
|
|
300
|
-
"method"
|
|
301
|
-
],
|
|
302
|
-
out: "self.method: undefined",
|
|
303
|
-
from: (target, test) => {
|
|
304
|
-
let self = test.in[0]; // The input arg has been mutated.
|
|
305
|
-
return self.method === undefined ? "self.method: undefined" : self.method;
|
|
306
|
-
}
|
|
307
|
-
},
|
|
308
|
-
|
|
309
|
-
{ of: "maybeRestartFull", and: "static" },
|
|
310
|
-
{ for: "When `latest` doesn't have `target` defined, `full` is returned.", /* good */
|
|
311
|
-
in: [
|
|
312
|
-
{ target: "full-on", method: "full-of", output: "full-as", not: true },
|
|
313
|
-
{ output: "latest-as", method: "latest-of", not: true }
|
|
314
|
-
],
|
|
315
|
-
out: { target: "full-on", method: "full-of", output: "full-as", not: true }
|
|
316
|
-
},
|
|
317
|
-
{ for: "When `latest` does have `target` defined, `latest` is returned.", /* good */
|
|
318
|
-
in: [
|
|
319
|
-
{ target: "full-on", method: "full-of", output: "full-as", not: true },
|
|
320
|
-
{ target: "new-on", method: "new-of", output: "new-as", not: true }
|
|
321
|
-
],
|
|
322
|
-
out: { target: "new-on", method: "new-of", output: "new-as", not: true }
|
|
323
|
-
},
|
|
324
|
-
|
|
325
|
-
{ of: "fromNonceTuple", and: "static" },
|
|
326
|
-
{ for: "When the nonce has all long-named properties, all properties are set.", /* good */
|
|
327
|
-
in: [
|
|
328
|
-
{ target: "target", method: "method", output: "output", not: true }
|
|
329
|
-
],
|
|
330
|
-
out: new SpoofTuple("target", "method", "output")
|
|
331
|
-
},
|
|
332
|
-
{ for: "When the nonce has all short-named properties, all properties are set.", /* good */
|
|
333
|
-
in: [
|
|
334
|
-
{ on: "target", of: "method", as: "output", not: true }
|
|
335
|
-
],
|
|
336
|
-
out: new SpoofTuple("target", "method", "output")
|
|
337
|
-
},
|
|
338
|
-
{ for: "When the nonce has all properties with mixed short and long names, all properties are set.", /* good */
|
|
339
|
-
in: [
|
|
340
|
-
{ on: "target", method: "method", as: "output", not: true }
|
|
341
|
-
],
|
|
342
|
-
out: new SpoofTuple("target", "method", "output")
|
|
343
|
-
},
|
|
344
|
-
{ for: "When the nonce has some properties with mixed short and long names, just those properties are set.", /* good */
|
|
345
|
-
in: [
|
|
346
|
-
{ on: "on-arg", method: "as-arg", notAs: "not-as", not: true }
|
|
347
|
-
],
|
|
348
|
-
out: new SpoofTuple("on-arg", "as-arg")
|
|
349
|
-
},
|
|
350
|
-
{ for: "When the nonce has no SpoofTuple properties, those output properties are not set.", /* good */
|
|
351
|
-
in: [ { notASpoofTuple: true, nonceOfSpoofTuple: false } ],
|
|
352
|
-
out: new SpoofTuple() },
|
|
353
|
-
|
|
354
|
-
/* SpoofTuple instance methods. */
|
|
355
|
-
{ of: "constructor" },
|
|
356
|
-
{ for: "When constructed, .on is the same as the `target` arg.", /* good */
|
|
357
|
-
in: [ "target-arg", "method-arg", "spoof-arg" ],
|
|
358
|
-
out: "target-arg",
|
|
359
|
-
from: "on"
|
|
360
|
-
},
|
|
361
|
-
{ for: "When constructed, .target is the same as the `target` arg.", /* good */
|
|
362
|
-
in: [ "target-arg", "method-arg", "spoof-arg" ],
|
|
363
|
-
out: "target-arg",
|
|
364
|
-
from: "target"
|
|
365
|
-
},
|
|
366
|
-
{ for: "When constructed, .of is the same as the `method` arg.", /* good */
|
|
367
|
-
in: [ "target-arg", "method-arg", "spoof-arg" ],
|
|
368
|
-
out: "method-arg",
|
|
369
|
-
from: "of"
|
|
370
|
-
},
|
|
371
|
-
{ for: "When constructed, .method is the same as the `method` arg.", /* good */
|
|
372
|
-
in: [ "target-arg", "method-arg", "spoof-arg" ],
|
|
373
|
-
out: "method-arg",
|
|
374
|
-
from: "method"
|
|
375
|
-
},
|
|
376
|
-
{ for: "When constructed, .as is the same as the `output` arg.", /* good */
|
|
377
|
-
in: [ "target-arg", "method-arg", "spoof-arg" ],
|
|
378
|
-
out: "spoof-arg",
|
|
379
|
-
from: "as"
|
|
380
|
-
},
|
|
381
|
-
{ for: "When constructed, .output is the same as the `output` arg.", /* good */
|
|
382
|
-
in: [ "target-arg", "method-arg", "spoof-arg" ],
|
|
383
|
-
out: "spoof-arg",
|
|
384
|
-
from: "output"
|
|
385
|
-
},
|
|
386
|
-
|
|
387
|
-
{ of: "toString" },
|
|
388
|
-
{ for: "When any properties are strings, they are written with quotes.", /* good */
|
|
389
|
-
on: SpoofTuple,
|
|
390
|
-
with: [ "on-arg", "of-arg", "as-arg" ],
|
|
391
|
-
in: [ ],
|
|
392
|
-
out: `SpoofTuple:{ target:"on-arg", method:"of-arg", output:"as-arg" }`
|
|
393
|
-
},
|
|
394
|
-
{ for: "When any properties are not strings, they are written without quotes.", /* good */
|
|
395
|
-
on: SpoofTuple,
|
|
396
|
-
with: [ true, false, 27 ],
|
|
397
|
-
in: [ ],
|
|
398
|
-
out: `SpoofTuple:{ target:true, method:false, output:27 }`
|
|
399
|
-
},
|
|
400
|
-
|
|
401
|
-
{ of: "isSpoofable" },
|
|
402
|
-
{ for: "When instance doesn't have .target, .method, or .output, returns false.",
|
|
403
|
-
with: [ undefined, undefined, undefined ],
|
|
404
|
-
in: [ ],
|
|
405
|
-
out: false },
|
|
406
|
-
{ for: "When instance has .target but not .method or .output, returns false.",
|
|
407
|
-
with: [ "target-arg", undefined, undefined ],
|
|
408
|
-
in: [ ],
|
|
409
|
-
out: false },
|
|
410
|
-
{ for: "When instance has .method but not .target or .output, returns true.",
|
|
411
|
-
with: [ undefined, "method-arg", undefined ],
|
|
412
|
-
in: [ ],
|
|
413
|
-
out: true },
|
|
414
|
-
{ for: "When instance has .output but not .target or .method, returns true.",
|
|
415
|
-
with: [ undefined, undefined, "as-arg" ],
|
|
416
|
-
in: [ ],
|
|
417
|
-
out: true },
|
|
418
|
-
{ for: "When instance has .target and .method, returns true.",
|
|
419
|
-
with: [ "on-arg", "of-arg", undefined ],
|
|
420
|
-
in: [ ],
|
|
421
|
-
out: true },
|
|
422
|
-
{ for: "When instance has .target and .output, returns true.",
|
|
423
|
-
with: [ "on-arg", undefined, "as-arg" ],
|
|
424
|
-
in: [ ],
|
|
425
|
-
out: true },
|
|
426
|
-
{ for: "When instance has .method and .output, returns true.",
|
|
427
|
-
with: [ undefined, "of-arg", "as-arg" ],
|
|
428
|
-
in: [ ],
|
|
429
|
-
out: true },
|
|
430
|
-
{ for: "When instance has valid contents plus other args, returns true.", /* good */
|
|
431
|
-
with: [ undefined, "of-arg", "as-arg", "frip", "sliff" ],
|
|
432
|
-
in: [ ],
|
|
433
|
-
out: true },
|
|
434
|
-
|
|
435
|
-
{ of: "isNotASpoof", and: "static" },
|
|
436
|
-
{ for: "When arg contains SpoofTuple properties but also .not, returns true.", /* good */
|
|
437
|
-
in: [ { on: "on-arg", of: "of-arg", as: "as-arg", not: true } ],
|
|
438
|
-
out: true },
|
|
439
|
-
{ for: "When arg contains SpoofTuple properties but also .skip, returns true.", /* good */
|
|
440
|
-
in: [ { on: "on-arg", of: "of-arg", as: "as-arg", skip: true } ],
|
|
441
|
-
out: true },
|
|
442
|
-
{ for: "When arg doesn't contain any SpoofTuple properties, returns true.", /* good */
|
|
443
|
-
in: [ { notOn: true, notOf: "true", notAs: "not-as" } ],
|
|
444
|
-
out: true },
|
|
445
|
-
{ for: "Tests of returns-false cases can't readily be tested within this system itself.", /* good */
|
|
446
|
-
of: null },
|
|
447
|
-
|
|
448
|
-
{ of: "fromNonceTuples", and: "static" },
|
|
449
|
-
{ for: "When nonces are not SpoofTuple equivalents, returns nonces unaltered.", /* good */
|
|
450
|
-
in: [ [ { first: "first", and: true }, { second: "second", and: false } ] ],
|
|
451
|
-
out: [ { first: "first", and: true }, { second: "second", and: false } ] },
|
|
452
|
-
{ for: "Tests of returns-SpoofTuple cases can't readily be tested within this system itself.", /* good */
|
|
453
|
-
of: null },
|
|
454
|
-
|
|
455
|
-
{ on: MixedContents, with: [ ] },
|
|
456
|
-
{ for: "When .amid contains an { of, as }, .as is used for .of on the target.", /* good */
|
|
457
|
-
of: "getInstanceValueOf",
|
|
458
|
-
in: [ "first" ],
|
|
459
|
-
amid: [ { of: "first", as: 25 } ],
|
|
460
|
-
out: 25 },
|
|
461
|
-
{ for: "When .amid is an empty array, original target property values are used.", /* good */
|
|
462
|
-
of: "getInstanceProduct",
|
|
463
|
-
in: [ ],
|
|
464
|
-
amid: [ ],
|
|
465
|
-
out: 6 },
|
|
466
|
-
{ for: "When .amid sets several properties, those property values are used.", /* good */
|
|
467
|
-
of: "getInstanceProduct",
|
|
468
|
-
in: [ ],
|
|
469
|
-
amid: [ { of: "first", as: 12 }, { of: "second", as: 6 }, { of: "third", as: { three: 7 } } ],
|
|
470
|
-
out: 504 },
|
|
471
|
-
{ for: "When .amid contains an { of, as } in a static test, .as is used for .of on the topic class.", /* good */
|
|
472
|
-
of: "getStaticValueOf",
|
|
473
|
-
and: "static",
|
|
474
|
-
in: [ "fourth" ],
|
|
475
|
-
amid: [ { of: "fourth", as: 18 } ],
|
|
476
|
-
out: 18 },
|
|
477
|
-
{ for: "When .amid is an empty array in a static test, original topic-class property values are used.", /* good */
|
|
478
|
-
of: "getStaticProduct",
|
|
479
|
-
and: "static",
|
|
480
|
-
in: [ ],
|
|
481
|
-
amid: [ ],
|
|
482
|
-
out: 20 },
|
|
483
|
-
{ for: "When .amid in a static test sets several properties, those topic-class property values are used.", /* good */
|
|
484
|
-
of: "getStaticProduct",
|
|
485
|
-
and: "static",
|
|
486
|
-
in: [ ],
|
|
487
|
-
amid: [ { of: "fourth", as: 7 }, { of: "fifth", as: "12" } ],
|
|
488
|
-
out: 84 },
|
|
489
|
-
|
|
490
|
-
{ on: Returner, with: [ ] },
|
|
491
|
-
{ for: "When a class is used in args, this test result displays its name only wherever used.", /* good */
|
|
492
|
-
of: "returnArg", in: [ MixedContents ], out: MixedContents },
|
|
493
|
-
{ for: "When a class is used in a Map in args, only its name is used in this test result.", /* good */
|
|
494
|
-
of: "returnArg", in: [ new Map([ [ Spoofable, 2 ], [ MixedContents, 3 ] ]) ],
|
|
495
|
-
out: new Map([ [ Spoofable, 2 ], [ MixedContents, 3 ] ]) },
|
|
496
|
-
{ for: "When a class is used in an object in args, only its name is used in this test result.", /* good */
|
|
497
|
-
of: "returnArg", in: [ { moment: Moment, spoofable: Spoofable } ],
|
|
498
|
-
out: { moment: Moment, spoofable: Spoofable } },
|
|
499
|
-
|
|
500
|
-
/* &cruft, revive these tests when single TestFrame with all test stages is used */
|
|
501
|
-
// { on: MutationModel, with: [ new Map([ [ "1", "A" ], [ "2", "B" ] ]), [ 8, 9, 10 ] ], and: "nospoof" },
|
|
502
|
-
// { for: "When the tested method mutates its args, the args it addresses are mutated.", /* good */
|
|
503
|
-
// of: "mutateArgs",
|
|
504
|
-
// in: [ [ 7, 8, 9 ], { retainable: 12, changes: 30 } ],
|
|
505
|
-
// // Return-value object bundles the mutated args.
|
|
506
|
-
// out: { array: [ 7, 8, 9, 10 ], tuple: { retainable: 12, changes: 40 } },
|
|
507
|
-
// from: [ ] },
|
|
508
|
-
// { for: "When the tested method mutates its args, the args in test.in are not mutated.", /* good */
|
|
509
|
-
// // Test args .of and .in are not redefined here, so they collapse forward.
|
|
510
|
-
// out: [ [ 7, 8, 9 ], { retainable: 12, changes: 30 } ],
|
|
511
|
-
// from: (target, test) => { return test.in; } },
|
|
512
|
-
// { for: "When the args in test.in are used in a collapsed-forward test, the un-mutated values are used.", /* good */
|
|
513
|
-
// // Test args .of and .in are not redefined here, so they collapse forward.
|
|
514
|
-
// // Returned values should reflect only one pass of changes.
|
|
515
|
-
// out: { array: [ 7, 8, 9, 10 ], tuple: { retainable: 12, changes: 40 } },
|
|
516
|
-
// // Test arg .from must be cleared to use return value.
|
|
517
|
-
// from: [ ] },
|
|
518
|
-
// { for: "When the tested method mutates the constructor args, the args it addresses are mutated.", /* good */
|
|
519
|
-
// of: "mutateInitors",
|
|
520
|
-
// // Test arg .with is not redefined, so original args collapse forward.
|
|
521
|
-
// // Test can't be of constructor(), which would ignore test.with.
|
|
522
|
-
// // Return-value object bundles the mutated args.
|
|
523
|
-
// in: [ ],
|
|
524
|
-
// out: { map: new Map([ [ "1", "A" ], [ "2", "B" ], [ "3", "C" ] ]), array: [ 9, 10 ] },
|
|
525
|
-
// from: [ ] },
|
|
526
|
-
// { for: "When the tested method mutates the constructor args, the args in test.with are not mutated.", /* good */
|
|
527
|
-
// of: "mutateInitors",
|
|
528
|
-
// // Test arg .with is not redefined, so original args collapse forward.
|
|
529
|
-
// // Test can't be of constructor(), which would ignore test.with.
|
|
530
|
-
// in: [ ],
|
|
531
|
-
// out: [ new Map([ [ "1", "A" ], [ "2", "B" ] ]), [ 8, 9, 10 ] ],
|
|
532
|
-
// from: (target, test) => { return test.with; } },
|
|
533
|
-
// { for: "When the args in test.with are used in a collapsed-forward test, the un-mutated values are used.", /* good */
|
|
534
|
-
// of: "mutateInitors",
|
|
535
|
-
// // Test arg .with is not redefined, so original args collapse forward.
|
|
536
|
-
// // Test can't be of constructor(), which would ignore test.with.
|
|
537
|
-
// // Returned values should reflect only one pass of changes.
|
|
538
|
-
// in: [ ],
|
|
539
|
-
// out: { map: new Map([ [ "1", "A" ], [ "2", "B" ], [ "3", "C" ] ]), array: [ 9, 10 ] },
|
|
540
|
-
// from: [ ] },
|
|
541
|
-
|
|
542
|
-
];
|
|
543
|
-
|
|
544
|
-
// endregion Tests
|
|
545
|
-
|
|
546
|
-
// region Local test fixtures
|
|
547
|
-
|
|
548
|
-
supplySingleElementSpoofArray() {
|
|
549
|
-
return [ { of: "spoofNumber", as: 32 } ]
|
|
550
|
-
}
|
|
551
|
-
|
|
552
|
-
supplySpoofNumberDefinition(target, test) {
|
|
553
|
-
/* Method members are defined on the prototype,
|
|
554
|
-
not on instances, so they are found this way. */
|
|
555
|
-
|
|
556
|
-
let args = test.in;
|
|
557
|
-
let spoofableClass = args[0];
|
|
558
|
-
return spoofableClass.prototype.spoofNumber;
|
|
559
|
-
}
|
|
560
|
-
|
|
561
|
-
supplySpoofTextDefinition(target, test) {
|
|
562
|
-
/* Method members are defined on the prototype,
|
|
563
|
-
not on instances, so they are found this way. */
|
|
564
|
-
|
|
565
|
-
let args = test.in;
|
|
566
|
-
let spoofableClass = args[0];
|
|
567
|
-
return spoofableClass.prototype.spoofText;
|
|
568
|
-
}
|
|
569
|
-
|
|
570
|
-
supplyArgsForCombineValuesTest() {
|
|
571
|
-
let args = [];
|
|
572
|
-
|
|
573
|
-
let self = { target: "target-arg", method: "method-arg", not: true };
|
|
574
|
-
let other = { target: "target-arg", method: "method-arg", output: "output-arg", not: true };
|
|
575
|
-
|
|
576
|
-
args.push(self, other);
|
|
577
|
-
args.push("output")
|
|
578
|
-
|
|
579
|
-
return args;
|
|
580
|
-
}
|
|
581
|
-
|
|
582
|
-
// endregion Local test fixtures
|
|
583
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
/**/
|
|
2
|
-
|
|
3
|
-
export class CompositionModel {
|
|
4
|
-
#first;
|
|
5
|
-
#second;
|
|
6
|
-
#number;
|
|
7
|
-
|
|
8
|
-
/* For this test-facing class,
|
|
9
|
-
`number` is often omitted. */
|
|
10
|
-
constructor(first, second, number) {
|
|
11
|
-
this.#first = first;
|
|
12
|
-
this.#second = second;
|
|
13
|
-
this.#number = number;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
multiplyValues(third, fourth) {
|
|
17
|
-
let a = this.#first.supplyValue();
|
|
18
|
-
let b = this.#second.supplyValue();
|
|
19
|
-
let c = third.supplyValue();
|
|
20
|
-
let d = fourth.supplyValue();
|
|
21
|
-
|
|
22
|
-
let output = a * b * c * d;
|
|
23
|
-
return output;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
addValues(third, fourthNumber, fifth, sixthNumber) {
|
|
27
|
-
let a = this.#first.supplyValue();
|
|
28
|
-
let b = this.#second.supplyValue();
|
|
29
|
-
let c = this.#number;
|
|
30
|
-
let d = third.supplyValue();
|
|
31
|
-
let e = fourthNumber;
|
|
32
|
-
let f = fifth.supplyValue();
|
|
33
|
-
let g = sixthNumber;
|
|
34
|
-
|
|
35
|
-
let output = a + b + c + d + e + f + g;
|
|
36
|
-
return output;
|
|
37
|
-
}
|
|
38
|
-
}
|