risei 1.2.0 → 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 +113 -46
- package/index.js +18 -5
- package/package.json +3 -4
- 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 +11 -5
- package/system/TestFrame.js +16 -108
- package/system/TestRunner.js +4 -4
- package/system/TestStages.js +5 -13
- package/system/TotalCopier.js +28 -4
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 = { };
|