risei 2.0.0 → 2.0.1
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 +114 -222
- package/package.json +1 -1
- package/Read-me reduced.md +0 -294
- package/Read-me redux.md +0 -581
- package/test-target-objects/ConditionalThrowTarget.js +0 -11
- package/test-target-objects/Counter.js +0 -46
- package/test-target-objects/DomTarget.js +0 -37
- package/test-target-objects/InterSpoofer.js +0 -230
- package/test-target-objects/MixedContents.js +0 -33
- package/test-target-objects/MutationTarget.js +0 -37
- package/test-target-objects/ObjectComposer.js +0 -34
- package/test-target-objects/PolySpoofableInner.js +0 -29
- package/test-target-objects/PolySpoofableOuter.js +0 -52
- package/test-target-objects/PropertiesTarget.js +0 -98
- package/test-target-objects/Returner.js +0 -7
- package/test-target-objects/Searcher.js +0 -25
- package/test-target-objects/Sorter.js +0 -91
- package/test-target-objects/Spoofable.js +0 -36
- package/test-target-objects/StateTarget.js +0 -34
- package/test-target-objects/StaticTarget.js +0 -17
- package/test-target-objects/TestableTarget.js +0 -57
- package/trial-tests/SelfTests.outward-rt.js +0 -511
- package/trial-tests/TopicTests.outward-rt.js +0 -313
- package/usage-examples/Gold-bar-example.png +0 -0
- package/usage-examples/Output-example.png +0 -0
- package/usage-examples/Summary-example.png +0 -0
- package/usage-examples/Syntax-example.png +0 -0
- package/usage-examples/Title-example.png +0 -0
- package/xternal-tests/ASpoofingFixture.tests.js +0 -242
- package/xternal-tests/MethodSpoofer.tests.js +0 -130
- package/xternal-tests/SpoofDef.tests.js +0 -91
- package/xternal-tests/TotalComparer.tests.js +0 -1055
- package/xternal-tests/package.json +0 -7
|
@@ -1,230 +0,0 @@
|
|
|
1
|
-
/**/
|
|
2
|
-
|
|
3
|
-
import MethodSpoofer from "../system/MethodSpoofer.js";
|
|
4
|
-
import PropertySpoofer from "../system/PropertySpoofer.js";
|
|
5
|
-
import PropertiesTarget from "./PropertiesTarget.js";
|
|
6
|
-
|
|
7
|
-
/* &cruft, maybe drop this after direct testing of groundwork
|
|
8
|
-
and reversing it is possible with .do / .undo */
|
|
9
|
-
export default class InterSpoofer {
|
|
10
|
-
// region Components
|
|
11
|
-
|
|
12
|
-
#methodSpoofer = new MethodSpoofer();
|
|
13
|
-
#propSpoofer = new PropertySpoofer();
|
|
14
|
-
|
|
15
|
-
// endregion Components
|
|
16
|
-
|
|
17
|
-
// region Gathered names of all spoofables
|
|
18
|
-
|
|
19
|
-
static staticProps = [ "staticBaseValueProp", "staticBaseAccessorProp", "staticValueProp", "staticAccessorProp" ];
|
|
20
|
-
static staticMethods = [ "staticBaseMethod", "staticMethod" ];
|
|
21
|
-
static props = [ "instanceBaseValueProp", "instanceBaseAccessorProp", "valueProp", "accessorProp" ];
|
|
22
|
-
static methods = [ "instanceBaseMethod", "instanceMethod" ];
|
|
23
|
-
|
|
24
|
-
static allMethods = [ InterSpoofer.staticMethods, InterSpoofer.methods ];
|
|
25
|
-
static allNames = [ InterSpoofer.staticProps, InterSpoofer.staticMethods, InterSpoofer.props, InterSpoofer.methods ];
|
|
26
|
-
|
|
27
|
-
// endregion Gathered names of all spoofables
|
|
28
|
-
|
|
29
|
-
// region Gathered original method defs and values
|
|
30
|
-
|
|
31
|
-
static #origDefs = InterSpoofer.#bundleDefs(
|
|
32
|
-
PropertiesTarget, new PropertiesTarget(), ...InterSpoofer.allMethods
|
|
33
|
-
);
|
|
34
|
-
|
|
35
|
-
static #origValues = InterSpoofer.#bundleValues(
|
|
36
|
-
PropertiesTarget, new PropertiesTarget(), ...InterSpoofer.allNames
|
|
37
|
-
);
|
|
38
|
-
|
|
39
|
-
// endregion Gathered original method defs and values
|
|
40
|
-
|
|
41
|
-
// region Methods to test spoofers
|
|
42
|
-
|
|
43
|
-
/* If these methods all pass, then the spoofers work
|
|
44
|
-
together without breaking each other's changes. */
|
|
45
|
-
|
|
46
|
-
spoofMethodsThenProps(test) /* passed */ {
|
|
47
|
-
this.#methodSpoofer.spoof(test);
|
|
48
|
-
this.#propSpoofer.spoof(test);
|
|
49
|
-
|
|
50
|
-
let type = test.type;
|
|
51
|
-
let target = test.target;
|
|
52
|
-
|
|
53
|
-
let values = InterSpoofer.#bundleValues(type, target, ...InterSpoofer.allNames);
|
|
54
|
-
|
|
55
|
-
this.reverseAllSpoofs(type, target);
|
|
56
|
-
|
|
57
|
-
return values;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
spoofPropsThenMethods(test) /* passed */ {
|
|
61
|
-
this.#propSpoofer.spoof(test);
|
|
62
|
-
this.#methodSpoofer.spoof(test);
|
|
63
|
-
|
|
64
|
-
let type = test.type;
|
|
65
|
-
let target = test.target;
|
|
66
|
-
|
|
67
|
-
let values = InterSpoofer.#bundleValues(type, target, ...InterSpoofer.allNames);
|
|
68
|
-
|
|
69
|
-
this.reverseAllSpoofs(type, target);
|
|
70
|
-
|
|
71
|
-
return values;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
spoofAndUnspoofMethodsThenProps(test) /* passed */ {
|
|
75
|
-
this.#methodSpoofer.spoof(test);
|
|
76
|
-
this.#propSpoofer.spoof(test);
|
|
77
|
-
|
|
78
|
-
let type = test.type;
|
|
79
|
-
let target = test.target;
|
|
80
|
-
|
|
81
|
-
let before = InterSpoofer.#bundleValues(type, target, ...InterSpoofer.allNames);
|
|
82
|
-
|
|
83
|
-
this.#methodSpoofer.unspoof(test);
|
|
84
|
-
this.#propSpoofer.unspoof(test);
|
|
85
|
-
|
|
86
|
-
let after = InterSpoofer.#bundleValues(type, target, ...InterSpoofer.allNames);
|
|
87
|
-
|
|
88
|
-
this.reverseAllSpoofs(type, target);
|
|
89
|
-
|
|
90
|
-
return { before, after };
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
spoofAndUnspoofPropsThenMethods(test) /* passed */ {
|
|
94
|
-
this.#propSpoofer.spoof(test);
|
|
95
|
-
this.#methodSpoofer.spoof(test);
|
|
96
|
-
|
|
97
|
-
let type = test.type;
|
|
98
|
-
let target = test.target;
|
|
99
|
-
|
|
100
|
-
let before = InterSpoofer.#bundleValues(type, target, ...InterSpoofer.allNames);
|
|
101
|
-
|
|
102
|
-
this.#propSpoofer.unspoof(test);
|
|
103
|
-
this.#methodSpoofer.unspoof(test);
|
|
104
|
-
|
|
105
|
-
let after = InterSpoofer.#bundleValues(type, target, ...InterSpoofer.allNames);
|
|
106
|
-
|
|
107
|
-
this.reverseAllSpoofs(type, target);
|
|
108
|
-
|
|
109
|
-
return { before, after };
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
spoofMethodsFirstAndUnspoofThemLast(test) /* passed */ {
|
|
113
|
-
this.#methodSpoofer.spoof(test);
|
|
114
|
-
this.#propSpoofer.spoof(test);
|
|
115
|
-
|
|
116
|
-
let type = test.type;
|
|
117
|
-
let target = test.target;
|
|
118
|
-
|
|
119
|
-
let before = InterSpoofer.#bundleValues(type, target, ...InterSpoofer.allNames);
|
|
120
|
-
|
|
121
|
-
this.#propSpoofer.unspoof(test);
|
|
122
|
-
this.#methodSpoofer.unspoof(test);
|
|
123
|
-
|
|
124
|
-
let after = InterSpoofer.#bundleValues(type, target, ...InterSpoofer.allNames);
|
|
125
|
-
|
|
126
|
-
this.reverseAllSpoofs(type, target);
|
|
127
|
-
|
|
128
|
-
return { before, after };
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
spoofPropsFirstAndUnspoofThemLast(test) /* passed */ {
|
|
132
|
-
this.#propSpoofer.spoof(test);
|
|
133
|
-
this.#methodSpoofer.spoof(test);
|
|
134
|
-
|
|
135
|
-
let type = test.type;
|
|
136
|
-
let target = test.target;
|
|
137
|
-
|
|
138
|
-
let before = InterSpoofer.#bundleValues(type, target, ...InterSpoofer.allNames);
|
|
139
|
-
|
|
140
|
-
this.#methodSpoofer.unspoof(test);
|
|
141
|
-
this.#propSpoofer.unspoof(test);
|
|
142
|
-
|
|
143
|
-
let after = InterSpoofer.#bundleValues(type, target, ...InterSpoofer.allNames);
|
|
144
|
-
|
|
145
|
-
this.reverseAllSpoofs(type, target);
|
|
146
|
-
|
|
147
|
-
return { before, after };
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
// endregion Methods to test spoofers
|
|
151
|
-
|
|
152
|
-
/* To ensure topic class isolated between tests. */
|
|
153
|
-
reverseAllSpoofs(type, target) /* verified */ {
|
|
154
|
-
/* Setting known properties and methods of target type
|
|
155
|
-
back to their stored original definitions / values. */
|
|
156
|
-
|
|
157
|
-
for (let name of InterSpoofer.staticProps) {
|
|
158
|
-
type[name] = InterSpoofer.#origValues[name];
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
for (let name of InterSpoofer.staticMethods) {
|
|
162
|
-
type[name] = InterSpoofer.#origDefs[name];
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
/* Plain instance properties shouldn't need to be reversed. */
|
|
166
|
-
|
|
167
|
-
for (let name of InterSpoofer.methods) {
|
|
168
|
-
type.prototype[name] = InterSpoofer.#origDefs[name];
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
for (let name of InterSpoofer.props) {
|
|
172
|
-
target[name] = InterSpoofer.#origValues[name];
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
let reversed = InterSpoofer.#bundleValues(type, target, ...InterSpoofer.allNames);
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
// region Internals
|
|
179
|
-
|
|
180
|
-
static #bundleDefs(type, target, staticMethods, methods) /* verified */ {
|
|
181
|
-
/* All callables asked for are stored as copies for restoring. */
|
|
182
|
-
|
|
183
|
-
let output = { };
|
|
184
|
-
|
|
185
|
-
for (let name of staticMethods) {
|
|
186
|
-
output[name] = InterSpoofer.#copyMethod(type[name]);
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
for (let name of methods) {
|
|
190
|
-
output[name] = InterSpoofer.#copyMethod(target[name]);
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
return output;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
static #bundleValues(type, target, staticProps, staticMethods, props, methods) /* verified */ {
|
|
197
|
-
/* Everything asked for is dropped into an object, either
|
|
198
|
-
property values or return values of calling methods. */
|
|
199
|
-
|
|
200
|
-
let output = { };
|
|
201
|
-
|
|
202
|
-
for (let name of staticProps) {
|
|
203
|
-
output[name] = type[name];
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
for (let name of staticMethods) {
|
|
207
|
-
output[name] = type[name]();
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
for (let name of props) {
|
|
211
|
-
output[name] = target[name];
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
for (let name of methods) {
|
|
215
|
-
output[name] = target[name]();
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
return output;
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
static #copyMethod(method) /* verified */ {
|
|
222
|
-
let passer = [ method ];
|
|
223
|
-
passer = [ ...passer ];
|
|
224
|
-
let copy = passer[0];
|
|
225
|
-
|
|
226
|
-
return copy;
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
// endregion Internals
|
|
230
|
-
}
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
/**/
|
|
2
|
-
|
|
3
|
-
export default class MixedContents {
|
|
4
|
-
first = 1;
|
|
5
|
-
second = "2";
|
|
6
|
-
third = { three: 3 };
|
|
7
|
-
|
|
8
|
-
static fourth = 4;
|
|
9
|
-
static fifth = "5";
|
|
10
|
-
|
|
11
|
-
getInstanceValueOf(name) {
|
|
12
|
-
return this[name];
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
getInstanceProduct() {
|
|
16
|
-
let a = this.first;
|
|
17
|
-
let b = Number(this.second);
|
|
18
|
-
let c = this.third.three;
|
|
19
|
-
|
|
20
|
-
return a * b * c;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
static getStaticValueOf(name) {
|
|
24
|
-
return MixedContents[name];
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
static getStaticProduct() {
|
|
28
|
-
let a = MixedContents.fourth;
|
|
29
|
-
let b = Number(MixedContents.fifth);
|
|
30
|
-
|
|
31
|
-
return a * b;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
/**/
|
|
2
|
-
|
|
3
|
-
export default class MutationTarget {
|
|
4
|
-
#map;
|
|
5
|
-
#array;
|
|
6
|
-
|
|
7
|
-
constructor(map, array) {
|
|
8
|
-
this.#map = map;
|
|
9
|
-
this.#array = array;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
mutateInitors() {
|
|
13
|
-
// Map mutation allows for consecutive mutations.
|
|
14
|
-
let rawKey = this.#map.size + 1;
|
|
15
|
-
this.#map.set(rawKey.toString(), "C");
|
|
16
|
-
this.#array.shift();
|
|
17
|
-
|
|
18
|
-
return { map: this.#map, array: this.#array };
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
mutateArgs(array, tuple) {
|
|
22
|
-
array.push(10);
|
|
23
|
-
tuple.changes += 10;
|
|
24
|
-
|
|
25
|
-
return { array, tuple };
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
replaceArg(array, index, replacement) {
|
|
29
|
-
// The previous element is added at the end for comparison.
|
|
30
|
-
array.push(array[index].toString());
|
|
31
|
-
|
|
32
|
-
// The new element is set at the original index.
|
|
33
|
-
array[index] = replacement;
|
|
34
|
-
|
|
35
|
-
return array;
|
|
36
|
-
}
|
|
37
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
/**/
|
|
2
|
-
|
|
3
|
-
export default class ObjectComposer {
|
|
4
|
-
constructor() {
|
|
5
|
-
/* No operations. */
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
/* Target of spoofing. */
|
|
9
|
-
supplySomeObject() {
|
|
10
|
-
throw new Error("supplyObjectA() must be spoofed in tests.");
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
enact(chain, method) {
|
|
14
|
-
// Invoke the method to be spoofed.
|
|
15
|
-
let target = this.supplySomeObject();
|
|
16
|
-
|
|
17
|
-
// Traverse the spoofed return
|
|
18
|
-
// value's object tree.
|
|
19
|
-
for (let link of chain) {
|
|
20
|
-
target = target[link];
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// Invoke the method at chain end for its return value.
|
|
24
|
-
let output = target[method]();
|
|
25
|
-
return output;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
doubleEnact(chainOne, methodOne, chainTwo, methodTwo) {
|
|
29
|
-
let outputOne = this.enact(chainOne, methodOne);
|
|
30
|
-
let outputTwo = this.enact(chainTwo, methodTwo);
|
|
31
|
-
|
|
32
|
-
return [ outputOne, outputTwo ];
|
|
33
|
-
}
|
|
34
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
/**/
|
|
2
|
-
|
|
3
|
-
export default class PolySpoofableInner {
|
|
4
|
-
constructor() {
|
|
5
|
-
/* No operations. */
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
/* Spoofing target. */
|
|
9
|
-
addOrTimes(numbers) {
|
|
10
|
-
let a = numbers.supplyA();
|
|
11
|
-
let b = numbers.supplyB();
|
|
12
|
-
|
|
13
|
-
return a + b;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
/* Spoofing target. */
|
|
17
|
-
minusOrOver(numbers) {
|
|
18
|
-
let a = numbers.supplyA();
|
|
19
|
-
let b = numbers.supplyB();
|
|
20
|
-
|
|
21
|
-
return a - b;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/* Spoofing target. Nested object. */
|
|
25
|
-
numberHost = {
|
|
26
|
-
supplyC: () => { return 15; },
|
|
27
|
-
supplyD: () => { return 18; }
|
|
28
|
-
}
|
|
29
|
-
}
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
/**/
|
|
2
|
-
|
|
3
|
-
import PolySpoofableInner from "./PolySpoofableInner.js";
|
|
4
|
-
|
|
5
|
-
export default class PolySpoofableOuter {
|
|
6
|
-
/* Spoofing target. */
|
|
7
|
-
#inner;
|
|
8
|
-
|
|
9
|
-
constructor() {
|
|
10
|
-
this.#inner = new PolySpoofableInner();
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/* Not intended to be spoofed, but to use spoofs. */
|
|
14
|
-
combinedNumbers(numbers) {
|
|
15
|
-
let first = this.#inner.addOrTimes(numbers);
|
|
16
|
-
let second = this.#inner.minusOrOver(numbers);
|
|
17
|
-
|
|
18
|
-
let combined = this.combiner(first, second);
|
|
19
|
-
return combined;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
/* Spoofing target. */
|
|
23
|
-
combiner(first, second) {
|
|
24
|
-
let combined = Math.pow(first, second);
|
|
25
|
-
return combined;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
/* Not intended to be spoofed, but to use spoofs. */
|
|
29
|
-
combinedPlusHosted(numbers) {
|
|
30
|
-
let combined = this.combinedNumbers(numbers);
|
|
31
|
-
let third = this.#inner.numberHost.supplyC();
|
|
32
|
-
let fourth = this.#inner.numberHost.supplyD();
|
|
33
|
-
|
|
34
|
-
return combined + third - fourth;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/* Not intended to be spoofed, but to use arg with spoofs. */
|
|
38
|
-
combinedArgAAndB(inner) {
|
|
39
|
-
let first = inner.supplyA();
|
|
40
|
-
let second = inner.supplyB();
|
|
41
|
-
|
|
42
|
-
return first + second;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
/* Not intended to be spoofed, but to use arg with spoofs. */
|
|
46
|
-
combinedArgHostedCAndD(inner) {
|
|
47
|
-
let third = inner.numberHost.supplyC();
|
|
48
|
-
let fourth = inner.numberHost.supplyD();
|
|
49
|
-
|
|
50
|
-
return third - fourth;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
/**/
|
|
2
|
-
|
|
3
|
-
/* Rarely or never directly addressed elsewhere. */
|
|
4
|
-
export class PropertyBase {
|
|
5
|
-
// region Static members
|
|
6
|
-
|
|
7
|
-
static staticBaseValueProp = 5;
|
|
8
|
-
|
|
9
|
-
// region .staticBaseAccessorProp
|
|
10
|
-
|
|
11
|
-
static #staticAccessedField = "6th";
|
|
12
|
-
|
|
13
|
-
static get staticBaseAccessorProp() {
|
|
14
|
-
return PropertyBase.#staticAccessedField;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
static set staticBaseAccessorProp(value) {
|
|
18
|
-
PropertyBase.#staticAccessedField = value;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// endregion .staticBaseAccessorProp
|
|
22
|
-
|
|
23
|
-
static staticBaseMethod() {
|
|
24
|
-
return "base static";
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// endregion Static members
|
|
28
|
-
|
|
29
|
-
// region Instance members
|
|
30
|
-
|
|
31
|
-
instanceBaseValueProp = 7;
|
|
32
|
-
|
|
33
|
-
// region .instanceBaseAccessorProp
|
|
34
|
-
|
|
35
|
-
#instanceAccessedProp = "8th";
|
|
36
|
-
|
|
37
|
-
get instanceBaseAccessorProp() {
|
|
38
|
-
return this.#instanceAccessedProp;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
set instanceBaseAccessorProp(value) {
|
|
42
|
-
this.#instanceAccessedProp = value;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// endregion .instanceBaseAccessorProp
|
|
46
|
-
|
|
47
|
-
instanceBaseMethod() {
|
|
48
|
-
return "base instance";
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// endregion Instance members
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
export default class PropertiesTarget extends PropertyBase {
|
|
55
|
-
// region Static members
|
|
56
|
-
|
|
57
|
-
static staticValueProp = 3;
|
|
58
|
-
|
|
59
|
-
// region .staticAccessorProp
|
|
60
|
-
|
|
61
|
-
static #staticAccessorValue = "4th";
|
|
62
|
-
|
|
63
|
-
static get staticAccessorProp() {
|
|
64
|
-
return this.#staticAccessorValue;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
static set staticAccessorProp(value) {
|
|
68
|
-
this.#staticAccessorValue = value;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// endregion .staticAccessorProp
|
|
72
|
-
|
|
73
|
-
static staticMethod() {
|
|
74
|
-
return "static";
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// endregion Static members
|
|
78
|
-
|
|
79
|
-
// region Instance members
|
|
80
|
-
|
|
81
|
-
valueProp = 1;
|
|
82
|
-
|
|
83
|
-
#accessorValue = "2nd";
|
|
84
|
-
|
|
85
|
-
get accessorProp() {
|
|
86
|
-
return this.#accessorValue;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
set accessorProp(value) {
|
|
90
|
-
this.#accessorValue = value;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
instanceMethod() {
|
|
94
|
-
return "instance";
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
// endregion Instance members
|
|
98
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
/**/
|
|
2
|
-
|
|
3
|
-
export default class Searcher {
|
|
4
|
-
constructor() {
|
|
5
|
-
/* No operations.*/
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
findLinear(sought, subject) /* passed */ {
|
|
9
|
-
// Fail path. All edge cases return false.
|
|
10
|
-
if (subject === undefined) {
|
|
11
|
-
return false;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
// Main path.
|
|
15
|
-
for (let item of subject) {
|
|
16
|
-
if (item === sought) {
|
|
17
|
-
return true;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// Never found.
|
|
22
|
-
return false;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
}
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
/**/
|
|
2
|
-
|
|
3
|
-
export default class Sorter {
|
|
4
|
-
constructor() {
|
|
5
|
-
/* No operations. */
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
countSort(subject) /* passed */ {
|
|
9
|
-
// To store indices for sorting to.
|
|
10
|
-
let sites = subject
|
|
11
|
-
.map(x => 0);
|
|
12
|
-
|
|
13
|
-
// Finding positions.
|
|
14
|
-
for (let at = 0; at < subject.length; at++) {
|
|
15
|
-
for (let on = 0; on < subject.length; on++) {
|
|
16
|
-
if (subject[on] < subject[at]) {
|
|
17
|
-
sites[at]++;
|
|
18
|
-
}
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
// To retain reordered items.
|
|
23
|
-
let output = sites
|
|
24
|
-
.map(x => 0);
|
|
25
|
-
|
|
26
|
-
// Placing into output positions.
|
|
27
|
-
for (let at = 0; at < sites.length; at++) {
|
|
28
|
-
let to = sites[at];
|
|
29
|
-
output[to] = subject[at];
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// Back to caller.
|
|
33
|
-
return output;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
mergeSort(subject) /* passed */ {
|
|
37
|
-
return this.#mergeRecursor(subject);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// region Private dependencies of mergeSort()
|
|
41
|
-
|
|
42
|
-
#mergeRecursor(subject, level) /* verified */ {
|
|
43
|
-
// Can't split for further merging.
|
|
44
|
-
if (subject.length === 1) {
|
|
45
|
-
return subject;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// Splitting for recursing at next level.
|
|
49
|
-
let { left, right } = this.#splitInHalf(subject);
|
|
50
|
-
|
|
51
|
-
// Actual recursion, calling next level directly.
|
|
52
|
-
let lefts = this.#mergeRecursor(left);
|
|
53
|
-
let rights = this.#mergeRecursor(right);
|
|
54
|
-
|
|
55
|
-
// Actually merging, then back to caller.
|
|
56
|
-
let merged = this.#merge(lefts, rights);
|
|
57
|
-
return merged;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
#splitInHalf(subject) /* verified */ {
|
|
61
|
-
// These slicing args ensure no lost items.
|
|
62
|
-
let left = subject.slice(0, subject.length / 2);
|
|
63
|
-
let right = subject.slice(left.length, subject.length);
|
|
64
|
-
|
|
65
|
-
return { left, right };
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
#merge(lefts, rights) /* verified */ {
|
|
69
|
-
// To hold output.
|
|
70
|
-
let merged = [];
|
|
71
|
-
|
|
72
|
-
// While both sides have items, pop the lowest
|
|
73
|
-
// of the two at the top to the output.
|
|
74
|
-
while (lefts.length > 0 && rights.length > 0) {
|
|
75
|
-
let side = lefts[0] < rights[0] ? lefts : rights;
|
|
76
|
-
let next = side.shift();
|
|
77
|
-
|
|
78
|
-
merged.push(next);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
// When one side is done, pop the rest of the other.
|
|
82
|
-
let surplus = lefts.length > rights.length ? lefts : rights;
|
|
83
|
-
merged.push(...surplus);
|
|
84
|
-
|
|
85
|
-
// Back to caller.
|
|
86
|
-
return merged;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
// endregion Private dependencies of mergeSort()
|
|
90
|
-
|
|
91
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
/**/
|
|
2
|
-
|
|
3
|
-
export default class Spoofable {
|
|
4
|
-
#member;
|
|
5
|
-
|
|
6
|
-
constructor(member) {
|
|
7
|
-
/* Optional member to test spoofing with SOF. */
|
|
8
|
-
if (member) {
|
|
9
|
-
this.#member = member;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
/* Member to test spoofing with SCF. */
|
|
14
|
-
spoofNumber(a, b) { return a + b; }
|
|
15
|
-
|
|
16
|
-
/* Member to test spoofing with SCF.
|
|
17
|
-
* Enables testing of spoofNumber() spoofing that
|
|
18
|
-
* returns no value (the spoofed method is empty). */
|
|
19
|
-
callSpoofNumber(a, b) {
|
|
20
|
-
let result = this.spoofNumber(a, b);
|
|
21
|
-
|
|
22
|
-
if (result === undefined) {
|
|
23
|
-
return "spoofNumber() internal call: no return value";
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return result;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/* Member to test spoofing with SCF. */
|
|
30
|
-
spoofText(t, u) { return `Texts "${ t }" and "${ u }".`; }
|
|
31
|
-
|
|
32
|
-
/* Member to test spoofing with SOF. */
|
|
33
|
-
callMemberMethod() {
|
|
34
|
-
return member.something();
|
|
35
|
-
}
|
|
36
|
-
}
|