risei 1.1.2 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +124 -58
- package/index.js +18 -5
- package/package.json +2 -2
- package/system/ASpoofingFixture.js +3 -3
- package/system/ATestFinder.js +13 -0
- package/system/Risei.js +82 -52
- package/system/SpoofClassMethodsFixture.js +5 -5
- package/system/{SpoofTuple.js → SpoofDefinition.js} +20 -20
- package/system/SpoofObjectMethodsFixture.js +3 -3
- package/system/{TestTuple.js → TestDefinition.js} +43 -28
- package/system/TestFinder.js +30 -8
- package/system/TestFrame.js +16 -108
- package/system/TestRunner.js +5 -5
- package/system/TestStages.js +5 -13
- package/system/TotalCopier.js +28 -4
package/system/TestStages.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**/
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { TestDefinition } from "./TestDefinition.js";
|
|
4
4
|
import { TotalComparer } from "./TotalComparer.js";
|
|
5
5
|
import { TotalCopier } from "./TotalCopier.js";
|
|
6
6
|
|
|
@@ -14,14 +14,6 @@ export class TestStages {
|
|
|
14
14
|
static #comparer = new TotalComparer();
|
|
15
15
|
static #copier = new TotalCopier();
|
|
16
16
|
|
|
17
|
-
setLocalInitorsAndInputs(test) /* passed */ {
|
|
18
|
-
/* Sets local__ of each to a copy of the original,
|
|
19
|
-
so any mutated args aren't collapsed forward. */
|
|
20
|
-
|
|
21
|
-
test.localInitors = TestStages.#copier.copy(test.with);
|
|
22
|
-
test.localInputs = TestStages.#copier.copy(test.in);
|
|
23
|
-
}
|
|
24
|
-
|
|
25
17
|
anyPreTargetingGroundwork(test) {
|
|
26
18
|
// Spoofing of class members here.
|
|
27
19
|
// Setting any static properties here.
|
|
@@ -37,7 +29,7 @@ export class TestStages {
|
|
|
37
29
|
return;
|
|
38
30
|
}
|
|
39
31
|
|
|
40
|
-
let callable =
|
|
32
|
+
let callable = TestDefinition.plainNameOf(test.of);
|
|
41
33
|
|
|
42
34
|
let target = test.isInstanceTest
|
|
43
35
|
? this.#supplyInstanceLocalTarget(test, callable)
|
|
@@ -61,7 +53,7 @@ export class TestStages {
|
|
|
61
53
|
}
|
|
62
54
|
|
|
63
55
|
#supplyInstanceLocalTarget(test, callable) /* verified */ {
|
|
64
|
-
let instance = new test.on.prototype.constructor(...test.
|
|
56
|
+
let instance = new test.on.prototype.constructor(...test.with);
|
|
65
57
|
|
|
66
58
|
// Methods are called on instance directly.
|
|
67
59
|
// Properties are called on instance in nonce.
|
|
@@ -79,8 +71,8 @@ export class TestStages {
|
|
|
79
71
|
or a nonce method for a property test. */
|
|
80
72
|
|
|
81
73
|
test.localCallable = test.isMethodTest
|
|
82
|
-
?
|
|
83
|
-
:
|
|
74
|
+
? TestDefinition.plainNameOf(test.method)
|
|
75
|
+
: TestDefinition.nonceLocalCallableName;
|
|
84
76
|
}
|
|
85
77
|
|
|
86
78
|
anyPostTargetingGroundwork(test) {
|
package/system/TotalCopier.js
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
/**/
|
|
2
2
|
|
|
3
|
+
import { TypeIdentifier } from "./TypeIdentifier.js";
|
|
4
|
+
import { Types } from "./Types.js";
|
|
5
|
+
|
|
3
6
|
export class TotalCopier {
|
|
7
|
+
#identifier = new TypeIdentifier();
|
|
8
|
+
|
|
4
9
|
copy(original) /* passed */ {
|
|
5
10
|
return this.recursiveCopy(original);
|
|
6
11
|
}
|
|
@@ -13,8 +18,10 @@ export class TotalCopier {
|
|
|
13
18
|
not a value; then recursively replaced at next level, and so on. */
|
|
14
19
|
|
|
15
20
|
let copy;
|
|
21
|
+
|
|
22
|
+
let type = this.#identifier.identify(original);
|
|
16
23
|
|
|
17
|
-
if (
|
|
24
|
+
if (type === Types.isArray) {
|
|
18
25
|
copy = [ ];
|
|
19
26
|
|
|
20
27
|
// Traversal construction with recursion.
|
|
@@ -26,7 +33,7 @@ export class TotalCopier {
|
|
|
26
33
|
return copy;
|
|
27
34
|
}
|
|
28
35
|
|
|
29
|
-
if (
|
|
36
|
+
if (type === Types.isMap) {
|
|
30
37
|
copy = new Map();
|
|
31
38
|
|
|
32
39
|
// Traversal construction with recursion.
|
|
@@ -38,7 +45,7 @@ export class TotalCopier {
|
|
|
38
45
|
return copy;
|
|
39
46
|
}
|
|
40
47
|
|
|
41
|
-
if (
|
|
48
|
+
if (type === Types.isSet) {
|
|
42
49
|
copy = new Set();
|
|
43
50
|
|
|
44
51
|
// Traversal construction with recursion.
|
|
@@ -50,10 +57,27 @@ export class TotalCopier {
|
|
|
50
57
|
return copy;
|
|
51
58
|
}
|
|
52
59
|
|
|
53
|
-
if (
|
|
60
|
+
if (type === Types.isDate) {
|
|
54
61
|
copy = new Date(original);
|
|
55
62
|
return copy;
|
|
56
63
|
}
|
|
64
|
+
|
|
65
|
+
// Actually copying isn't needed (or desirable) here,
|
|
66
|
+
// since should always point to same thing regardless.
|
|
67
|
+
if (type === Types.isClass) {
|
|
68
|
+
copy = original;
|
|
69
|
+
return copy;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// The workaround here makes a true independent copy of the
|
|
73
|
+
// original function, regardless of its definition style.
|
|
74
|
+
if (type === Types.isFunction) {
|
|
75
|
+
let passer = [ original ];
|
|
76
|
+
passer = [ ...passer ];
|
|
77
|
+
copy = passer[0];
|
|
78
|
+
|
|
79
|
+
return copy;
|
|
80
|
+
}
|
|
57
81
|
|
|
58
82
|
if (original instanceof Object) {
|
|
59
83
|
copy = { };
|