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,354 +0,0 @@
1
- /**/
2
-
3
- /* Lists tuples defining tests of CountModel and other model code,
4
- possibly along with any fixtures needed for those tests. */
5
-
6
- import { ATestSource } from "../../node_modules/risei/public/javascript/ATestSource.js";
7
-
8
- import { CountModel } from "../target-objects/CountModel.js";
9
- import { SortModel } from "../target-objects/SortModel.js";
10
- import { SearchModel } from "../target-objects/SearchModel.js";
11
- import { DomModel } from "../target-objects/DomModel.js";
12
- import { StaticModel } from "../target-objects/StaticModel.js";
13
- import { CompositionModel } from "../target-objects/CompositionModel.js";
14
- import { StateModel } from "../target-objects/StateModel.js";
15
-
16
- export class TopicTests extends ATestSource {
17
- // region Tests
18
-
19
- tests = [
20
- /* CountModel . howMany() */
21
- { on: CountModel, with: [], of: "howMany" },
22
-
23
- {
24
- for: "Returns the right number for a repeated single character.", /* good */
25
- in: [ "a b c a b c", "a" ], out: 2
26
- },
27
- {
28
- for: "Returns the right number for a repeated string.", /* good */
29
- in: [ "more text with more words", "more" ], out: 2
30
- },
31
- {
32
- for: "Returns one for a target once at the start.", /* good */
33
- in: [ "a b c d e f", "a" ], out: 1
34
- },
35
- {
36
- for: "Returns one for a target once in the middle.", /* good */
37
- in: [ "x b c a b c", "a" ], out: 1
38
- },
39
- {
40
- for: "Returns one for a target once at the end.", /* good */
41
- in: [ "a b x a b c", "c" ], out: 1
42
- },
43
-
44
- /* Trying out .type-restatement syntax. */
45
- { on: CountModel, with: [], of: "howMany" },
46
-
47
- {
48
- for: "Returns one for a multi-character target present once.", /* good */
49
- in: [ "some text with words", "text" ], out: 1
50
- },
51
- {
52
- for: "When target is not present in subject, returns zero.", /* good */
53
- in: [ "a b c a b c", "x" ], out: 0
54
- },
55
-
56
- /* Trying out .method-restatement syntax. */
57
- { of: "howMany" },
58
-
59
- {
60
- for: "When subject is empty, returns zero.", /* good */
61
- in: [ "", "a" ], out: 0
62
- },
63
- {
64
- for: "When target is empty, returns zero.", /* good */
65
- in: [ "something", "" ], out: 0
66
- },
67
- {
68
- for: "When both args are empty, returns zero.", /* good */
69
- in: [ "", "" ], out: 0
70
- },
71
- {
72
- for: "When only subject is provided, returns zero.", /* good */
73
- in: [ "something" ], out: 0
74
- },
75
- {
76
- for: "When no arguments are provided, returns zero.", /* good */
77
- in: [], out: 0
78
- },
79
- {
80
- for: "When subject is null, returns zero.", /* good */
81
- in: [ null, "a" ], out: 0
82
- },
83
- {
84
- for: "When target is null, returns zero.", /* good */
85
- in: [ "something", null ], out: 0
86
- },
87
- {
88
- for: "When both args are null, returns zero.", /* good */
89
- in: [ null, null ], out: 0
90
- },
91
-
92
- /* SortModel */
93
- { on: SortModel, with: [] },
94
-
95
- /* .countSort() */
96
- {
97
- for: "When given an unsorted array, returns the values sorted.", /* good */
98
- of: "countSort",
99
- in: [ [ 3, 2, 6, 4, 1, 5 ] ], out: [ 1, 2, 3, 4, 5, 6 ]
100
- },
101
- {
102
- for: "When given a sorted array, returns the same sort order.", /* good */
103
- in: [ [ 2, 4, 6, 8, 9, 10 ] ], out: [ 2, 4, 6, 8, 9, 10 ]
104
- },
105
-
106
- /* .mergeSort() */
107
- {
108
- for: "When given an unsorted array, returns the values sorted.", /* good */
109
- of: "mergeSort",
110
- in: [ [ 3, 2, 6, 4, 1, 5 ] ], out: [ 1, 2, 3, 4, 5, 6 ]
111
- },
112
- {
113
- for: "Sorts correctly when all stages are divisible by two.", /* good */
114
- in: [ [ 3, 2, 6, 4, 1, 5, 8, 7 ] ],
115
- out: [ 1, 2, 3, 4, 5, 6, 7, 8 ]
116
- },
117
-
118
- {
119
- for: "Sorts interval values correctly.",
120
- of: "mergeSort",
121
- in: this.getIntervalValues(3, 10, true, true), out: this.getIntervalValues(3, 10, false, false)
122
- },
123
-
124
- { on: SearchModel, with: [], of: "findLinear" },
125
-
126
- {
127
- for: "When sought is present in subject, returns true.", /* good */
128
- in: [ 3, [ 6, 2, 8, 1, 4, 4, 3, 7, 2, 9, 11 ] ], out: true
129
- },
130
- {
131
- for: "When sought is not present, returns false.", /* good */
132
- in: [ 10, [ 6, 2, 8, 1, 4, 4, 3, 7, 2, 9, 11 ] ], out: false
133
- },
134
- {
135
- for: "When no subject is provided, returns false.", /* good */
136
- in: [ 7 ], out: false
137
- },
138
- {
139
- for: "When no sought is provided, returns false.", /* good */
140
- in: [ undefined, [ 3, 8, 10 ] ], out: false
141
- },
142
- {
143
- for: "When no args are provided, returns false.", /* good */
144
- in: [], out: false
145
- },
146
-
147
- { on: DomModel, with: [ "spoof-id" ] },
148
-
149
- {
150
- for: "When an instance is inited, `id` arg is set as .id.", /* good */
151
- of: "constructor",
152
- plus: [ { of: "domNodeFrom" } ],
153
- in: [ "arg-id" ],
154
- out: "arg-id",
155
- from: "id"
156
- },
157
- {
158
- for: "When an instance is inited, return value from domNodeFrom() is set as .node.", /* good */
159
- of: "constructor",
160
- plus: [ { of: "domNodeFrom", as: "returned-node" } ],
161
- in: [ "arg-node" ],
162
- out: "returned-node",
163
- from: "node"
164
- },
165
- {
166
- for: "When changeDomItem() is called, its arg is the new .id.", /* good */
167
- of: "changeDomItem",
168
- plus: [ { of: "domNodeFrom" } ],
169
- in: [ "new-id" ],
170
- out: "new-id",
171
- from: "id"
172
- },
173
- {
174
- for: "When changeDomItem() is called, domNodeFrom() changes .node based on the arg.", /* good */
175
- of: "changeDomItem",
176
- plus: [ { of: "domNodeFrom", as: (arg) => { return arg; } } ],
177
- in: [ "new-node" ],
178
- out: "new-node",
179
- from: "node"
180
- },
181
-
182
- /* Tests of inline tuple-based spoofing for static methods, using StaticModel. */
183
-
184
- { on: StaticModel, with: [] },
185
-
186
- { for: "When a call is made to a static method with .and set, " +
187
- "that method is invoked to return the right result.", /* good */
188
- of: "multiplyThenDivide",
189
- and: "static",
190
- in: [ 3, 4, 2 ],
191
- out: 6 /* (3 *4) ÷2 */ },
192
- { for: "When .and is set and .from is an arrow function, a value " +
193
- "retrieved after a static method call is the right result.", /* good */
194
- of: "setStaticProperty",
195
- and: "static",
196
- in: [ "static-was-set" ],
197
- out: "static-was-set",
198
- from: (target, test) => { return test.on.staticProperty; }
199
- },
200
- { for: "When .and is set and .from is a static property name, a value " +
201
- "retrieved after a static method call is the right result.", /* */
202
- of: "setStaticProperty",
203
- and: "static",
204
- in: [ "static-was-set" ],
205
- out: "static-was-set",
206
- from: "staticProperty"
207
- },
208
-
209
- /* Tests of inline tuple-based spoofing, using CompositionModel. */
210
-
211
- { on: CompositionModel },
212
-
213
- {
214
- for: "When objects are spoofed for call, values from spoofs are used.", /* good */
215
- with: [
216
- { of: "supplyValue", as: 2 },
217
- { of: "supplyValue", as: 3 }
218
- ],
219
- of: "multiplyValues",
220
- in: [
221
- { of: "supplyValue", as: 4 },
222
- { of: "supplyValue", as: 5 }
223
- ],
224
- out: 120 // 2 * 3 * 4 * 5
225
- },
226
- {
227
- for: "When only some objects are spoofed, spoofing still works correctly.", /* good */
228
- with: [
229
- { supplyValue: () => { return 3; } }, // Custom object, not spoof definition.
230
- { of: "supplyValue", as: 5 } // Spoof definition.
231
- ],
232
- of: "multiplyValues",
233
- in: [
234
- { of: "supplyValue", as: 7 }, // Spoof definition.
235
- { supplyValue: () => { return 1; } } // Custom object, not spoof definition.
236
- ],
237
- out: 105 // 3 * 5 * 7 ( * 1 )
238
- },
239
- {
240
- for: "When no objects are spoofed, spoofing still works correctly.", /* good */
241
- with: [
242
- { supplyValue: () => { return 11; } }, // Custom object, not spoof definition.
243
- { supplyValue: () => { return 1; } } // Custom object, not spoof definition.
244
- ],
245
- of: "multiplyValues",
246
- in: [
247
- { supplyValue: () => { return 12; } }, // Custom object, not spoof definition.
248
- { supplyValue: () => { return 1; } } // Custom object, not spoof definition.
249
- ],
250
- out: 132 // 11 * 12 ( * 1 * 1 )
251
- },
252
- {
253
- for: "When given objects, spoof definitions, and values, spoofing still works correctly.", /* good */
254
- with: [
255
- { supplyValue: () => { return 20; } }, // Custom object, not spoof definition.
256
- { of: "supplyValue", as: 21 }, // Spoof definition.
257
- 22 // Value.
258
- ],
259
- of: "addValues",
260
- in: [
261
- { of: "supplyValue", as: 23 }, // Spoof definition.
262
- 24, // Value.
263
- { supplyValue: () => { return 25; } }, // Custom object, not spoof definition.
264
- 26 // Value.
265
- ],
266
- out: 161 // 20 + 21 + 22 + 23 + 24 + 25 + 26
267
- },
268
-
269
- { on: StateModel, with: [] },
270
-
271
- { for: "When instance is constructed, .numberState is 1.", /* good */
272
- of: "constructor",
273
- from: "numberState",
274
- in: [ ], out: 1 },
275
- { for: "When instance is constructed, .textState is \"1\".", /* good */
276
- of: "constructor",
277
- from: "textState",
278
- in: [ ], out: "1" },
279
- { for: "When number is set, .numberState propery has the chosen value.", /* good */
280
- of: "setNumberState",
281
- from: "numberState",
282
- in: [ 77 ], out: 77 },
283
- { for: "When text is set, .textState has the chosen value.", /* good */
284
- of: "setTextState",
285
- from: "textState",
286
- in: [ "This is some text." ], out: "This is some text." },
287
-
288
- { of: "changeNumberAndTextState" },
289
-
290
- { for: "When text and number are changed, .numberState matches the number arg.", /* good */
291
- from: "numberState",
292
- in: [ 2, "a phrase" ], out: 2 },
293
- { for: "When a change is made with property test.from before a test with .from of [], property is used.", /* good */
294
- from: "textState",
295
- in: [ 2, "a phrase" ], out: "a phrase" },
296
- { for: "When a change is made and test.from is [], not a retrieval, the return value is used.", /* good */
297
- from: [ ],
298
- in: [ 2, "a phrase" ], out: { number: 2, text: "a phrase" } },
299
- { for: "When a change is made with property test.from before a test with .from of { }, property is used.", /* good */
300
- from: "numberState",
301
- in: [ 2, "a phrase" ], out: 2 },
302
- { for: "When a change is made and test.from is { }, not a retrieval, the return value is used.", /* good */
303
- from: { },
304
- in: [ 2, "a phrase" ], out: { number: 2, text: "a phrase" } },
305
- { for: "When a change is made with property test.from before a test with .from of false, property is used.", /* good */
306
- from: "textState",
307
- in: [ 2, "a phrase" ], out: "a phrase" },
308
- { for: "When a change is made and test.from is false, not a retrieval, the return value is used.", /* good */
309
- from: false,
310
- in: [ 2, "a phrase" ], out: { number: 2, text: "a phrase" } },
311
- { for: "When a change is made with property test.from before a test with .from of \"\", property is used.", /* good */
312
- from: "numberState",
313
- in: [ 2, "a phrase" ], out: 2 },
314
- { for: "When a change is made and test.from is \"\", not a retrieval, the return value is used.", /* good */
315
- from: "",
316
- in: [ 2, "a phrase" ], out: { number: 2, text: "a phrase" } }
317
-
318
- ];
319
-
320
- // endregion Tests
321
-
322
- // region Local test fixtures
323
-
324
- getIntervalValues(interval, count, doPermute, doWrap) {
325
- let values = [];
326
-
327
- for (let of = 0; of < count; of++) {
328
- let value = interval * of;
329
- values.push(value);
330
- }
331
-
332
- if (doPermute) {
333
- /* Permuting order by pairing each value with a random value,
334
- sorting on the random values, then dropping those again. */
335
-
336
- let pairings = [];
337
-
338
- for (let at = 0; at < values.length; at++) {
339
- pairings.push({ value: values[at], order: Math.random() });
340
- }
341
-
342
- pairings.sort((a, b) => a.order - b.order);
343
- values = pairings.map(x => x.value);
344
- }
345
-
346
- if (doWrap) {
347
- return [ values ];
348
- }
349
-
350
- return values;
351
- }
352
-
353
- // endregion Local test fixtures
354
- }