yukigo 0.2.3 → 0.3.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/.mocharc.json +3 -3
- package/CHANGELOG.md +105 -40
- package/README.md +193 -193
- package/dist/analyzer/GraphBuilder.d.ts +1 -0
- package/dist/analyzer/GraphBuilder.js +2 -1
- package/dist/analyzer/index.d.ts +0 -7
- package/dist/analyzer/index.js +3 -3
- package/dist/analyzer/inspections/functional/functional.d.ts +1 -1
- package/dist/analyzer/inspections/functional/functional.js +1 -1
- package/dist/analyzer/inspections/functional/smells.d.ts +3 -3
- package/dist/analyzer/inspections/functional/smells.js +27 -35
- package/dist/analyzer/inspections/generic/generic.d.ts +22 -14
- package/dist/analyzer/inspections/generic/generic.js +82 -60
- package/dist/analyzer/inspections/generic/smells.d.ts +2 -0
- package/dist/analyzer/inspections/generic/smells.js +55 -64
- package/dist/analyzer/inspections/imperative/imperative.d.ts +3 -3
- package/dist/analyzer/inspections/imperative/imperative.js +3 -3
- package/dist/analyzer/inspections/imperative/smells.d.ts +1 -0
- package/dist/analyzer/inspections/imperative/smells.js +8 -5
- package/dist/analyzer/inspections/logic/logic.d.ts +8 -8
- package/dist/analyzer/inspections/logic/logic.js +5 -5
- package/dist/analyzer/inspections/logic/smells.js +2 -2
- package/dist/analyzer/inspections/object/object.d.ts +5 -5
- package/dist/analyzer/inspections/object/object.js +22 -21
- package/dist/analyzer/inspections/object/smells.js +11 -23
- package/dist/analyzer/utils.d.ts +6 -2
- package/dist/analyzer/utils.js +6 -2
- package/dist/interpreter/components/EnvBuilder.d.ts +20 -1
- package/dist/interpreter/components/EnvBuilder.js +211 -66
- package/dist/interpreter/components/EqualityComparer.d.ts +15 -0
- package/dist/interpreter/components/EqualityComparer.js +69 -0
- package/dist/interpreter/components/Operations.d.ts +17 -14
- package/dist/interpreter/components/Operations.js +61 -62
- package/dist/interpreter/components/PatternMatcher.d.ts +19 -58
- package/dist/interpreter/components/PatternMatcher.js +185 -286
- package/dist/interpreter/components/RuntimeContext.d.ts +24 -15
- package/dist/interpreter/components/RuntimeContext.js +43 -4
- package/dist/interpreter/components/TestRunner.d.ts +15 -13
- package/dist/interpreter/components/TestRunner.js +86 -53
- package/dist/interpreter/components/evaluators/BaseEvaluator.d.ts +19 -0
- package/dist/interpreter/components/evaluators/BaseEvaluator.js +20 -0
- package/dist/interpreter/components/evaluators/ExpressionEvaluator.d.ts +34 -0
- package/dist/interpreter/components/evaluators/ExpressionEvaluator.js +298 -0
- package/dist/interpreter/components/evaluators/OperationEvaluator.d.ts +25 -0
- package/dist/interpreter/components/evaluators/OperationEvaluator.js +226 -0
- package/dist/interpreter/components/evaluators/PrimitiveEvaluator.d.ts +19 -0
- package/dist/interpreter/components/evaluators/PrimitiveEvaluator.js +50 -0
- package/dist/interpreter/components/evaluators/StatementEvaluator.d.ts +28 -0
- package/dist/interpreter/components/evaluators/StatementEvaluator.js +240 -0
- package/dist/interpreter/components/evaluators/TestingEvaluator.d.ts +15 -0
- package/dist/interpreter/components/evaluators/TestingEvaluator.js +14 -0
- package/dist/interpreter/components/evaluators/index.d.ts +110 -0
- package/dist/interpreter/components/evaluators/index.js +21 -0
- package/dist/interpreter/components/evaluators/utils.d.ts +7 -0
- package/dist/interpreter/components/evaluators/utils.js +50 -0
- package/dist/interpreter/components/hooks/YukigoHook.d.ts +27 -0
- package/dist/interpreter/components/hooks/YukigoHook.js +1 -0
- package/dist/interpreter/components/kernel/commands.d.ts +122 -0
- package/dist/interpreter/components/kernel/commands.js +203 -0
- package/dist/interpreter/components/kernel/index.d.ts +51 -0
- package/dist/interpreter/components/kernel/index.js +176 -0
- package/dist/interpreter/components/logic/LogicEngine.d.ts +26 -23
- package/dist/interpreter/components/logic/LogicEngine.js +234 -221
- package/dist/interpreter/components/logic/LogicResolver.d.ts +22 -51
- package/dist/interpreter/components/logic/LogicResolver.js +73 -440
- package/dist/interpreter/components/logic/LogicTerm.d.ts +104 -0
- package/dist/interpreter/components/logic/LogicTerm.js +423 -0
- package/dist/interpreter/components/logic/LogicTranslator.d.ts +25 -9
- package/dist/interpreter/components/logic/LogicTranslator.js +211 -74
- package/dist/interpreter/components/runtimes/FunctionRuntime.d.ts +6 -4
- package/dist/interpreter/components/runtimes/FunctionRuntime.js +82 -84
- package/dist/interpreter/components/runtimes/LazyRuntime.d.ts +13 -14
- package/dist/interpreter/components/runtimes/LazyRuntime.js +112 -239
- package/dist/interpreter/components/runtimes/ObjectRuntime.d.ts +17 -14
- package/dist/interpreter/components/runtimes/ObjectRuntime.js +105 -74
- package/dist/interpreter/errors.d.ts +10 -0
- package/dist/interpreter/errors.js +17 -0
- package/dist/interpreter/index.d.ts +9 -5
- package/dist/interpreter/index.js +11 -13
- package/dist/interpreter/primitives/YuValue.d.ts +21 -0
- package/dist/interpreter/primitives/YuValue.js +40 -0
- package/dist/interpreter/primitives/capabilities.d.ts +90 -0
- package/dist/interpreter/primitives/capabilities.js +1 -0
- package/dist/interpreter/primitives/entities/LazyList.d.ts +48 -0
- package/dist/interpreter/primitives/entities/LazyList.js +164 -0
- package/dist/interpreter/primitives/entities/LogicResult.d.ts +51 -0
- package/dist/interpreter/primitives/entities/LogicResult.js +101 -0
- package/dist/interpreter/primitives/entities/RuntimeClass.d.ts +24 -0
- package/dist/interpreter/primitives/entities/RuntimeClass.js +57 -0
- package/dist/interpreter/primitives/entities/RuntimeFunction.d.ts +40 -0
- package/dist/interpreter/primitives/entities/RuntimeFunction.js +73 -0
- package/dist/interpreter/primitives/entities/RuntimeObject.d.ts +27 -0
- package/dist/interpreter/primitives/entities/RuntimeObject.js +82 -0
- package/dist/interpreter/primitives/entities/RuntimePredicate.d.ts +19 -0
- package/dist/interpreter/primitives/entities/RuntimePredicate.js +59 -0
- package/dist/interpreter/primitives/index.d.ts +14 -0
- package/dist/interpreter/primitives/index.js +14 -0
- package/dist/interpreter/primitives/scalars/YuBoolean.d.ts +24 -0
- package/dist/interpreter/primitives/scalars/YuBoolean.js +69 -0
- package/dist/interpreter/primitives/scalars/YuChar.d.ts +28 -0
- package/dist/interpreter/primitives/scalars/YuChar.js +78 -0
- package/dist/interpreter/primitives/scalars/YuNil.d.ts +25 -0
- package/dist/interpreter/primitives/scalars/YuNil.js +73 -0
- package/dist/interpreter/primitives/scalars/YuNumber.d.ts +49 -0
- package/dist/interpreter/primitives/scalars/YuNumber.js +165 -0
- package/dist/interpreter/primitives/sequences/YuArray.d.ts +33 -0
- package/dist/interpreter/primitives/sequences/YuArray.js +150 -0
- package/dist/interpreter/primitives/sequences/YuString.d.ts +40 -0
- package/dist/interpreter/primitives/sequences/YuString.js +130 -0
- package/dist/interpreter/utils.d.ts +23 -10
- package/dist/interpreter/utils.js +25 -30
- package/dist/tester/index.d.ts +3 -3
- package/dist/tester/index.js +39 -28
- package/dist/utils/helpers.d.ts +13 -5
- package/dist/utils/helpers.js +38 -85
- package/package.json +3 -16
- package/src/analyzer/GraphBuilder.ts +143 -142
- package/src/analyzer/index.ts +185 -194
- package/src/analyzer/inspections/functional/functional.ts +121 -121
- package/src/analyzer/inspections/functional/smells.ts +88 -102
- package/src/analyzer/inspections/generic/generic.ts +610 -577
- package/src/analyzer/inspections/generic/smells.ts +355 -365
- package/src/analyzer/inspections/imperative/imperative.ts +104 -101
- package/src/analyzer/inspections/imperative/smells.ts +58 -54
- package/src/analyzer/inspections/logic/logic.ts +84 -90
- package/src/analyzer/inspections/logic/smells.ts +54 -54
- package/src/analyzer/inspections/object/object.ts +295 -264
- package/src/analyzer/inspections/object/smells.ts +130 -144
- package/src/analyzer/utils.ts +115 -109
- package/src/index.ts +3 -3
- package/src/interpreter/components/EnvBuilder.ts +405 -202
- package/src/interpreter/components/EqualityComparer.ts +107 -0
- package/src/interpreter/components/Operations.ts +126 -99
- package/src/interpreter/components/PatternMatcher.ts +375 -475
- package/src/interpreter/components/RuntimeContext.ts +181 -119
- package/src/interpreter/components/TestRunner.ts +223 -151
- package/src/interpreter/components/evaluators/BaseEvaluator.ts +36 -0
- package/src/interpreter/components/evaluators/ExpressionEvaluator.ts +475 -0
- package/src/interpreter/components/evaluators/OperationEvaluator.ts +477 -0
- package/src/interpreter/components/evaluators/PrimitiveEvaluator.ts +80 -0
- package/src/interpreter/components/evaluators/StatementEvaluator.ts +372 -0
- package/src/interpreter/components/evaluators/TestingEvaluator.ts +26 -0
- package/src/interpreter/components/evaluators/index.ts +34 -0
- package/src/interpreter/components/evaluators/utils.ts +64 -0
- package/src/interpreter/components/hooks/YukigoHook.ts +45 -0
- package/src/interpreter/components/kernel/commands.ts +255 -0
- package/src/interpreter/components/kernel/index.ts +222 -0
- package/src/interpreter/components/logic/LogicEngine.ts +509 -519
- package/src/interpreter/components/logic/LogicResolver.ts +209 -858
- package/src/interpreter/components/logic/LogicTerm.ts +477 -0
- package/src/interpreter/components/logic/LogicTranslator.ts +362 -149
- package/src/interpreter/components/runtimes/FunctionRuntime.ts +249 -227
- package/src/interpreter/components/runtimes/LazyRuntime.ts +226 -334
- package/src/interpreter/components/runtimes/ObjectRuntime.ts +262 -224
- package/src/interpreter/errors.ts +68 -47
- package/src/interpreter/index.ts +50 -52
- package/src/interpreter/primitives/YuValue.ts +64 -0
- package/src/interpreter/primitives/capabilities.ts +111 -0
- package/src/interpreter/primitives/entities/LazyList.ts +225 -0
- package/src/interpreter/primitives/entities/LogicResult.ts +133 -0
- package/src/interpreter/primitives/entities/RuntimeClass.ts +70 -0
- package/src/interpreter/primitives/entities/RuntimeFunction.ts +108 -0
- package/src/interpreter/primitives/entities/RuntimeObject.ts +110 -0
- package/src/interpreter/primitives/entities/RuntimePredicate.ts +77 -0
- package/src/interpreter/primitives/index.ts +17 -0
- package/src/interpreter/primitives/scalars/YuBoolean.ts +79 -0
- package/src/interpreter/primitives/scalars/YuChar.ts +94 -0
- package/src/interpreter/primitives/scalars/YuNil.ts +84 -0
- package/src/interpreter/primitives/scalars/YuNumber.ts +187 -0
- package/src/interpreter/primitives/sequences/YuArray.ts +178 -0
- package/src/interpreter/primitives/sequences/YuString.ts +165 -0
- package/src/interpreter/utils.ts +105 -84
- package/src/tester/index.ts +157 -128
- package/src/utils/helpers.ts +113 -169
- package/tests/analyzer/functional.spec.ts +221 -207
- package/tests/analyzer/generic.spec.ts +178 -178
- package/tests/analyzer/helpers.spec.ts +83 -89
- package/tests/analyzer/logic.spec.ts +237 -237
- package/tests/analyzer/oop.spec.ts +320 -323
- package/tests/analyzer/transitive.spec.ts +166 -166
- package/tests/interpreter/EnvBuilder.spec.ts +181 -183
- package/tests/interpreter/FunctionRuntime.spec.ts +224 -223
- package/tests/interpreter/LazyRuntime.spec.ts +227 -225
- package/tests/interpreter/LogicEngine.spec.ts +371 -327
- package/tests/interpreter/LogicSubstitution.spec.ts +90 -80
- package/tests/interpreter/ObjectRuntime.spec.ts +431 -606
- package/tests/interpreter/Operations.spec.ts +312 -220
- package/tests/interpreter/PatternSystem.spec.ts +254 -213
- package/tests/interpreter/Tests.spec.ts +122 -122
- package/tests/interpreter/interpreter.spec.ts +1143 -991
- package/tests/kernel/YukigoKernel.spec.ts +112 -0
- package/tests/tester/Tester.spec.ts +156 -152
- package/tsconfig.build.json +16 -15
- package/tsconfig.json +27 -25
- package/dist/interpreter/components/Visitor.d.ts +0 -70
- package/dist/interpreter/components/Visitor.js +0 -634
- package/dist/interpreter/entities.d.ts +0 -105
- package/dist/interpreter/entities.js +0 -96
- package/dist/interpreter/trampoline.d.ts +0 -17
- package/dist/interpreter/trampoline.js +0 -38
- package/dist/src/analyzer/GraphBuilder.d.ts +0 -30
- package/dist/src/analyzer/GraphBuilder.js +0 -100
- package/dist/src/analyzer/index.d.ts +0 -59
- package/dist/src/analyzer/index.js +0 -152
- package/dist/src/analyzer/inspections/functional/functional.d.ts +0 -44
- package/dist/src/analyzer/inspections/functional/functional.js +0 -149
- package/dist/src/analyzer/inspections/functional/smells.d.ts +0 -16
- package/dist/src/analyzer/inspections/functional/smells.js +0 -98
- package/dist/src/analyzer/inspections/generic/generic.d.ts +0 -178
- package/dist/src/analyzer/inspections/generic/generic.js +0 -604
- package/dist/src/analyzer/inspections/generic/smells.d.ts +0 -61
- package/dist/src/analyzer/inspections/generic/smells.js +0 -349
- package/dist/src/analyzer/inspections/imperative/imperative.d.ts +0 -35
- package/dist/src/analyzer/inspections/imperative/imperative.js +0 -109
- package/dist/src/analyzer/inspections/imperative/smells.d.ts +0 -16
- package/dist/src/analyzer/inspections/imperative/smells.js +0 -58
- package/dist/src/analyzer/inspections/logic/logic.d.ts +0 -32
- package/dist/src/analyzer/inspections/logic/logic.js +0 -96
- package/dist/src/analyzer/inspections/logic/smells.d.ts +0 -15
- package/dist/src/analyzer/inspections/logic/smells.js +0 -60
- package/dist/src/analyzer/inspections/object/object.d.ts +0 -90
- package/dist/src/analyzer/inspections/object/object.js +0 -321
- package/dist/src/analyzer/inspections/object/smells.d.ts +0 -30
- package/dist/src/analyzer/inspections/object/smells.js +0 -135
- package/dist/src/analyzer/utils.d.ts +0 -30
- package/dist/src/analyzer/utils.js +0 -78
- package/dist/src/index.d.ts +0 -4
- package/dist/src/index.js +0 -4
- package/dist/src/interpreter/components/EnvBuilder.d.ts +0 -21
- package/dist/src/interpreter/components/EnvBuilder.js +0 -155
- package/dist/src/interpreter/components/Operations.d.ts +0 -14
- package/dist/src/interpreter/components/Operations.js +0 -84
- package/dist/src/interpreter/components/PatternMatcher.d.ts +0 -73
- package/dist/src/interpreter/components/PatternMatcher.js +0 -358
- package/dist/src/interpreter/components/RuntimeContext.d.ts +0 -35
- package/dist/src/interpreter/components/RuntimeContext.js +0 -93
- package/dist/src/interpreter/components/TestRunner.d.ts +0 -19
- package/dist/src/interpreter/components/TestRunner.js +0 -110
- package/dist/src/interpreter/components/Visitor.d.ts +0 -71
- package/dist/src/interpreter/components/Visitor.js +0 -638
- package/dist/src/interpreter/components/logic/LogicEngine.d.ts +0 -29
- package/dist/src/interpreter/components/logic/LogicEngine.js +0 -259
- package/dist/src/interpreter/components/logic/LogicResolver.d.ts +0 -53
- package/dist/src/interpreter/components/logic/LogicResolver.js +0 -484
- package/dist/src/interpreter/components/logic/LogicTranslator.d.ts +0 -14
- package/dist/src/interpreter/components/logic/LogicTranslator.js +0 -99
- package/dist/src/interpreter/components/runtimes/FunctionRuntime.d.ts +0 -12
- package/dist/src/interpreter/components/runtimes/FunctionRuntime.js +0 -149
- package/dist/src/interpreter/components/runtimes/LazyRuntime.d.ts +0 -19
- package/dist/src/interpreter/components/runtimes/LazyRuntime.js +0 -269
- package/dist/src/interpreter/components/runtimes/ObjectRuntime.d.ts +0 -35
- package/dist/src/interpreter/components/runtimes/ObjectRuntime.js +0 -126
- package/dist/src/interpreter/errors.d.ts +0 -19
- package/dist/src/interpreter/errors.js +0 -36
- package/dist/src/interpreter/index.d.ts +0 -24
- package/dist/src/interpreter/index.js +0 -41
- package/dist/src/interpreter/trampoline.d.ts +0 -17
- package/dist/src/interpreter/trampoline.js +0 -38
- package/dist/src/interpreter/utils.d.ts +0 -11
- package/dist/src/interpreter/utils.js +0 -65
- package/dist/src/tester/index.d.ts +0 -25
- package/dist/src/tester/index.js +0 -113
- package/dist/src/utils/helpers.d.ts +0 -13
- package/dist/src/utils/helpers.js +0 -52
- package/src/interpreter/components/Visitor.ts +0 -1065
- package/src/interpreter/trampoline.ts +0 -71
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { YuValue } from "../YuValue.js";
|
|
2
|
+
import { BindCommand, StepCommand, } from "../../components/kernel/commands.js";
|
|
3
|
+
import { YuNil } from "../scalars/YuNil.js";
|
|
4
|
+
import { UnsupportedOperation } from "../../errors.js";
|
|
5
|
+
import { LazyStepResult } from "../entities/LazyList.js";
|
|
6
|
+
import { YuNumber, YuString } from "../index.js";
|
|
7
|
+
import { boolean, compareResult, number, raise } from "../../utils.js";
|
|
8
|
+
export class YuArray extends YuValue {
|
|
9
|
+
items;
|
|
10
|
+
index;
|
|
11
|
+
constructor(items, index = 0) {
|
|
12
|
+
super();
|
|
13
|
+
this.items = items;
|
|
14
|
+
this.index = index;
|
|
15
|
+
}
|
|
16
|
+
get asSequence() {
|
|
17
|
+
return this;
|
|
18
|
+
}
|
|
19
|
+
get asComparable() {
|
|
20
|
+
return this;
|
|
21
|
+
}
|
|
22
|
+
*[Symbol.iterator]() {
|
|
23
|
+
for (let i = this.index; i < this.items.length; i++) {
|
|
24
|
+
yield this.items[i];
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
size() {
|
|
28
|
+
return number(this.items.length);
|
|
29
|
+
}
|
|
30
|
+
step() {
|
|
31
|
+
if (this.index >= this.items.length) {
|
|
32
|
+
return new StepCommand(YuNil.getInstance());
|
|
33
|
+
}
|
|
34
|
+
const item = this.items[this.index];
|
|
35
|
+
const tail = new YuArray(this.items, this.index + 1);
|
|
36
|
+
return new StepCommand(new LazyStepResult(item, tail));
|
|
37
|
+
}
|
|
38
|
+
concat(other) {
|
|
39
|
+
const seq = other.asSequence;
|
|
40
|
+
if (!seq)
|
|
41
|
+
return raise(new UnsupportedOperation(other, "concat"));
|
|
42
|
+
return seq.concatWithArray(this);
|
|
43
|
+
}
|
|
44
|
+
concatWithArray(arr) {
|
|
45
|
+
return new StepCommand(new YuArray([...arr, ...this]));
|
|
46
|
+
}
|
|
47
|
+
concatWithString(str) {
|
|
48
|
+
return new StepCommand(new YuString(this.toJSON() + str.toJSON()));
|
|
49
|
+
}
|
|
50
|
+
at(index) {
|
|
51
|
+
return this.items[this.index + index];
|
|
52
|
+
}
|
|
53
|
+
flat() {
|
|
54
|
+
return new YuArray([...this].flatMap((item) => {
|
|
55
|
+
const seq = item.asSequence;
|
|
56
|
+
return seq instanceof YuArray ? [...seq] : [item];
|
|
57
|
+
}));
|
|
58
|
+
}
|
|
59
|
+
equals(other) {
|
|
60
|
+
const c = other.asComparable;
|
|
61
|
+
if (!c)
|
|
62
|
+
return boolean(false);
|
|
63
|
+
return c.equalsWithArray(this);
|
|
64
|
+
}
|
|
65
|
+
equalsWithNumber() {
|
|
66
|
+
return boolean(false);
|
|
67
|
+
}
|
|
68
|
+
equalsWithBoolean() {
|
|
69
|
+
return boolean(false);
|
|
70
|
+
}
|
|
71
|
+
equalsWithString() {
|
|
72
|
+
return boolean(false);
|
|
73
|
+
}
|
|
74
|
+
equalsWithArray(left) {
|
|
75
|
+
return new BindCommand(left.size(), (res) => {
|
|
76
|
+
const leftSize = res.asNumeric?.asComparable;
|
|
77
|
+
if (!leftSize || !leftSize.equals(new YuNumber(this.items.length)))
|
|
78
|
+
return boolean(false);
|
|
79
|
+
const compareNext = (index) => {
|
|
80
|
+
if (compareResult(leftSize.compare(new YuNumber(index)), (res) => res >= 0)) {
|
|
81
|
+
return boolean(true);
|
|
82
|
+
}
|
|
83
|
+
return new BindCommand(left.at(index).equals(this.at(index)), (res) => {
|
|
84
|
+
if (!res.toJSON())
|
|
85
|
+
return boolean(false);
|
|
86
|
+
return compareNext(index + 1);
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
return compareNext(0);
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
equalsWithNil() {
|
|
93
|
+
return boolean(false);
|
|
94
|
+
}
|
|
95
|
+
compare(other) {
|
|
96
|
+
const c = other.asComparable;
|
|
97
|
+
if (!c)
|
|
98
|
+
return raise(new UnsupportedOperation(other, "compare"));
|
|
99
|
+
return c.compareWithArray(this);
|
|
100
|
+
}
|
|
101
|
+
compareWithNumber() {
|
|
102
|
+
return raise(new UnsupportedOperation(this, "compare"));
|
|
103
|
+
}
|
|
104
|
+
compareWithBoolean() {
|
|
105
|
+
return raise(new UnsupportedOperation(this, "compare"));
|
|
106
|
+
}
|
|
107
|
+
compareWithString() {
|
|
108
|
+
return raise(new UnsupportedOperation(this, "compare"));
|
|
109
|
+
}
|
|
110
|
+
compareWithArray(left) {
|
|
111
|
+
const a = [...left];
|
|
112
|
+
const b = [...this];
|
|
113
|
+
const minLen = Math.min(a.length, b.length);
|
|
114
|
+
const compareNext = (index) => {
|
|
115
|
+
if (index >= minLen) {
|
|
116
|
+
return new StepCommand(new YuNumber(a.length - b.length));
|
|
117
|
+
}
|
|
118
|
+
return new BindCommand(a[index].compare(b[index]), (res) => {
|
|
119
|
+
const cmp = res.toJSON();
|
|
120
|
+
if (cmp !== 0) {
|
|
121
|
+
return new StepCommand(res);
|
|
122
|
+
}
|
|
123
|
+
return compareNext(index + 1);
|
|
124
|
+
});
|
|
125
|
+
};
|
|
126
|
+
return compareNext(0);
|
|
127
|
+
}
|
|
128
|
+
compareWithNil() {
|
|
129
|
+
return raise(new UnsupportedOperation(this, "compare"));
|
|
130
|
+
}
|
|
131
|
+
toJSON(keyOrSeen) {
|
|
132
|
+
const seen = keyOrSeen instanceof Set ? keyOrSeen : new Set();
|
|
133
|
+
if (seen.has(this))
|
|
134
|
+
return "[Circular]";
|
|
135
|
+
seen.add(this);
|
|
136
|
+
const result = this.index === 0
|
|
137
|
+
? this.items.map((i) => i.toJSON(seen))
|
|
138
|
+
: this.items.slice(this.index).map((i) => i.toJSON(seen));
|
|
139
|
+
seen.delete(this);
|
|
140
|
+
return result;
|
|
141
|
+
}
|
|
142
|
+
toString(seen = new Set()) {
|
|
143
|
+
if (seen.has(this))
|
|
144
|
+
return "[Circular]";
|
|
145
|
+
seen.add(this);
|
|
146
|
+
const result = `[${[...this].map((i) => i.toString(seen)).join(", ")}]`;
|
|
147
|
+
seen.delete(this);
|
|
148
|
+
return result;
|
|
149
|
+
}
|
|
150
|
+
}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { YuValue } from "../YuValue.js";
|
|
2
|
+
import { YuChar } from "../scalars/YuChar.js";
|
|
3
|
+
import { ExecutionCommand } from "../../components/kernel/commands.js";
|
|
4
|
+
import { YuNumber } from "../scalars/YuNumber.js";
|
|
5
|
+
import { YuArray } from "./YuArray.js";
|
|
6
|
+
import { Comparable, Sequence, Summable, YuComparable, YuSequence, YuSummable } from "../capabilities.js";
|
|
7
|
+
export declare class YuString extends YuValue implements Sequence, Summable, Comparable {
|
|
8
|
+
readonly value: string;
|
|
9
|
+
readonly index: number;
|
|
10
|
+
constructor(value: string, index?: number);
|
|
11
|
+
get asSequence(): YuSequence;
|
|
12
|
+
get asSummable(): YuSummable;
|
|
13
|
+
get asComparable(): YuComparable;
|
|
14
|
+
[Symbol.iterator](): Iterator<YuChar>;
|
|
15
|
+
step(): ExecutionCommand;
|
|
16
|
+
size(): ExecutionCommand;
|
|
17
|
+
plus(other: YuValue): ExecutionCommand;
|
|
18
|
+
plusWithNumber(left: YuNumber): ExecutionCommand;
|
|
19
|
+
plusWithString(left: YuString): ExecutionCommand;
|
|
20
|
+
split(): ExecutionCommand;
|
|
21
|
+
concat(other: YuValue): ExecutionCommand;
|
|
22
|
+
concatWithString(str: YuString): ExecutionCommand;
|
|
23
|
+
concatWithArray(arr: YuArray): ExecutionCommand;
|
|
24
|
+
realize(): ExecutionCommand;
|
|
25
|
+
equals(other: YuValue): ExecutionCommand;
|
|
26
|
+
contains(other: YuValue): ExecutionCommand;
|
|
27
|
+
equalsWithNumber(left: YuNumber): ExecutionCommand;
|
|
28
|
+
equalsWithBoolean(): ExecutionCommand;
|
|
29
|
+
equalsWithString(left: YuString): ExecutionCommand;
|
|
30
|
+
equalsWithArray(): ExecutionCommand;
|
|
31
|
+
equalsWithNil(): ExecutionCommand;
|
|
32
|
+
compare(other: YuValue): ExecutionCommand;
|
|
33
|
+
compareWithNumber(left: YuNumber): ExecutionCommand;
|
|
34
|
+
compareWithBoolean(): ExecutionCommand;
|
|
35
|
+
compareWithString(left: YuString): ExecutionCommand;
|
|
36
|
+
compareWithArray(): ExecutionCommand;
|
|
37
|
+
compareWithNil(): ExecutionCommand;
|
|
38
|
+
toJSON(): string;
|
|
39
|
+
toString(): string;
|
|
40
|
+
}
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { YuValue } from "../YuValue.js";
|
|
2
|
+
import { YuChar } from "../scalars/YuChar.js";
|
|
3
|
+
import { StepCommand, } from "../../components/kernel/commands.js";
|
|
4
|
+
import { YuNil } from "../scalars/YuNil.js";
|
|
5
|
+
import { YuNumber } from "../scalars/YuNumber.js";
|
|
6
|
+
import { YuArray } from "./YuArray.js";
|
|
7
|
+
import { UnsupportedOperation } from "../../errors.js";
|
|
8
|
+
import { LazyStepResult, YuBoolean } from "../index.js";
|
|
9
|
+
import { boolean, number, raise } from "../../utils.js";
|
|
10
|
+
export class YuString extends YuValue {
|
|
11
|
+
value;
|
|
12
|
+
index;
|
|
13
|
+
constructor(value, index = 0) {
|
|
14
|
+
super();
|
|
15
|
+
this.value = value;
|
|
16
|
+
this.index = index;
|
|
17
|
+
}
|
|
18
|
+
get asSequence() {
|
|
19
|
+
return this;
|
|
20
|
+
}
|
|
21
|
+
get asSummable() {
|
|
22
|
+
return this;
|
|
23
|
+
}
|
|
24
|
+
get asComparable() {
|
|
25
|
+
return this;
|
|
26
|
+
}
|
|
27
|
+
*[Symbol.iterator]() {
|
|
28
|
+
for (let i = this.index; i < this.value.length; i++) {
|
|
29
|
+
yield new YuChar(this.value[i]);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
step() {
|
|
33
|
+
if (this.index >= this.value.length) {
|
|
34
|
+
return new StepCommand(YuNil.getInstance());
|
|
35
|
+
}
|
|
36
|
+
const char = new YuChar(this.value[this.index]);
|
|
37
|
+
const tail = new YuString(this.value, this.index + 1);
|
|
38
|
+
return new StepCommand(new LazyStepResult(char, tail));
|
|
39
|
+
}
|
|
40
|
+
size() {
|
|
41
|
+
return number(this.value.length);
|
|
42
|
+
}
|
|
43
|
+
plus(other) {
|
|
44
|
+
const s = other.asSummable;
|
|
45
|
+
if (!s)
|
|
46
|
+
return raise(new UnsupportedOperation(other, "plus"));
|
|
47
|
+
return s.plusWithString(this);
|
|
48
|
+
}
|
|
49
|
+
plusWithNumber(left) {
|
|
50
|
+
return new StepCommand(new YuString(left.toJSON().toString() + this.toJSON()));
|
|
51
|
+
}
|
|
52
|
+
plusWithString(left) {
|
|
53
|
+
return new StepCommand(new YuString(left.toJSON() + this.toJSON()));
|
|
54
|
+
}
|
|
55
|
+
split() {
|
|
56
|
+
const items = this.toJSON()
|
|
57
|
+
.split("")
|
|
58
|
+
.map((char) => new YuChar(char));
|
|
59
|
+
return new StepCommand(new YuArray(items));
|
|
60
|
+
}
|
|
61
|
+
concat(other) {
|
|
62
|
+
const seq = other.asSequence;
|
|
63
|
+
if (!seq)
|
|
64
|
+
return raise(new UnsupportedOperation(other, "concat"));
|
|
65
|
+
return seq.concatWithString(this);
|
|
66
|
+
}
|
|
67
|
+
concatWithString(str) {
|
|
68
|
+
return new StepCommand(new YuString(str.toJSON() + this.toJSON()));
|
|
69
|
+
}
|
|
70
|
+
concatWithArray(arr) {
|
|
71
|
+
return new StepCommand(new YuString(arr.toString()));
|
|
72
|
+
}
|
|
73
|
+
realize() {
|
|
74
|
+
return this.split();
|
|
75
|
+
}
|
|
76
|
+
equals(other) {
|
|
77
|
+
const c = other.asComparable;
|
|
78
|
+
if (!c)
|
|
79
|
+
return boolean(false);
|
|
80
|
+
return c.equalsWithString(this);
|
|
81
|
+
}
|
|
82
|
+
contains(other) {
|
|
83
|
+
if (other instanceof YuString) {
|
|
84
|
+
return boolean(this.value.includes(other.value));
|
|
85
|
+
}
|
|
86
|
+
return raise(new UnsupportedOperation(other, "contains"));
|
|
87
|
+
}
|
|
88
|
+
equalsWithNumber(left) {
|
|
89
|
+
return new StepCommand(new YuBoolean(left.value.toString() === this.toJSON()));
|
|
90
|
+
}
|
|
91
|
+
equalsWithBoolean() {
|
|
92
|
+
return boolean(false);
|
|
93
|
+
}
|
|
94
|
+
equalsWithString(left) {
|
|
95
|
+
return boolean(left.toJSON() === this.toJSON());
|
|
96
|
+
}
|
|
97
|
+
equalsWithArray() {
|
|
98
|
+
return boolean(false);
|
|
99
|
+
}
|
|
100
|
+
equalsWithNil() {
|
|
101
|
+
return boolean(false);
|
|
102
|
+
}
|
|
103
|
+
compare(other) {
|
|
104
|
+
const c = other.asComparable;
|
|
105
|
+
if (!c)
|
|
106
|
+
return raise(new UnsupportedOperation(other, "compare"));
|
|
107
|
+
return c.compareWithString(this);
|
|
108
|
+
}
|
|
109
|
+
compareWithNumber(left) {
|
|
110
|
+
return new StepCommand(new YuNumber(left.value - Number(this.toJSON())));
|
|
111
|
+
}
|
|
112
|
+
compareWithBoolean() {
|
|
113
|
+
return raise(new UnsupportedOperation(this, "compare"));
|
|
114
|
+
}
|
|
115
|
+
compareWithString(left) {
|
|
116
|
+
return new StepCommand(new YuNumber(left.toJSON().localeCompare(this.toJSON())));
|
|
117
|
+
}
|
|
118
|
+
compareWithArray() {
|
|
119
|
+
return raise(new UnsupportedOperation(this, "compare"));
|
|
120
|
+
}
|
|
121
|
+
compareWithNil() {
|
|
122
|
+
return raise(new UnsupportedOperation(this, "compare"));
|
|
123
|
+
}
|
|
124
|
+
toJSON() {
|
|
125
|
+
return this.index === 0 ? this.value : this.value.slice(this.index);
|
|
126
|
+
}
|
|
127
|
+
toString() {
|
|
128
|
+
return this.toJSON();
|
|
129
|
+
}
|
|
130
|
+
}
|
|
@@ -1,11 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export declare
|
|
7
|
-
export declare
|
|
8
|
-
export declare
|
|
9
|
-
export declare
|
|
1
|
+
import { ExecutionCommand, RaiseCommand, StepCommand } from "./components/kernel/commands.js";
|
|
2
|
+
import { RuntimeContext } from "./components/RuntimeContext.js";
|
|
3
|
+
import { YuValue, YuNumber, LazyList } from "./primitives/index.js";
|
|
4
|
+
import { InterpreterError } from "./errors.js";
|
|
5
|
+
export declare const raise: (err: InterpreterError) => RaiseCommand;
|
|
6
|
+
export declare const error: (ctx: string, msg: string) => InterpreterError;
|
|
7
|
+
export declare const boolean: (condition: boolean) => StepCommand;
|
|
8
|
+
export declare const number: (num: number) => StepCommand;
|
|
9
|
+
export declare const not: (command: ExecutionCommand) => ExecutionCommand;
|
|
10
|
+
export declare const isTrue: (val: unknown) => boolean;
|
|
11
|
+
export declare const compareResult: (command: ExecutionCommand, predicate: (num: number) => boolean) => ExecutionCommand;
|
|
12
|
+
export type NativeExtension = (self: YuValue, args: YuValue[], ctx: RuntimeContext) => ExecutionCommand;
|
|
13
|
+
export type PrimitiveThunk = () => YuValue;
|
|
14
|
+
export type Environment = Map<string, YuValue>;
|
|
15
|
+
export type EnvStack = {
|
|
16
|
+
head: Environment;
|
|
17
|
+
tail: EnvStack | null;
|
|
18
|
+
};
|
|
19
|
+
export declare function isArrayOfNumbers(arr: YuValue): boolean;
|
|
20
|
+
export declare function generateRange(start: number, end: number, step: number): YuNumber[];
|
|
21
|
+
export declare function createEnv(bindings: [string, YuValue][]): Environment;
|
|
10
22
|
export declare function createGlobalEnv(): EnvStack;
|
|
11
|
-
export declare function getYukigoType(val:
|
|
23
|
+
export declare function getYukigoType(val: YuValue): string;
|
|
24
|
+
export declare function createStream(generator: () => ExecutionCommand): LazyList;
|
|
@@ -1,14 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
import { BindCommand, RaiseCommand, StepCommand, } from "./components/kernel/commands.js";
|
|
2
|
+
import { YuNumber, LazyList, YuBoolean } from "./primitives/index.js";
|
|
3
|
+
import { InterpreterError } from "./errors.js";
|
|
4
|
+
export const raise = (err) => new RaiseCommand(err);
|
|
5
|
+
export const error = (ctx, msg) => new InterpreterError(ctx, msg);
|
|
6
|
+
export const boolean = (condition) => new StepCommand(new YuBoolean(condition));
|
|
7
|
+
export const number = (num) => {
|
|
8
|
+
const rounded = Math.round(num * 100000) / 100000;
|
|
9
|
+
return new StepCommand(new YuNumber(rounded));
|
|
10
|
+
};
|
|
11
|
+
export const not = (command) => new BindCommand(command, (res) => res.asLogic?.not() || boolean(false));
|
|
12
|
+
export const isTrue = (val) => val instanceof YuBoolean && val.value;
|
|
13
|
+
export const compareResult = (command, predicate) => new BindCommand(command, (res) => boolean(predicate(res.toJSON())));
|
|
8
14
|
export function isArrayOfNumbers(arr) {
|
|
9
|
-
|
|
10
|
-
|
|
15
|
+
const seq = arr.asSequence;
|
|
16
|
+
if (!seq)
|
|
17
|
+
return false;
|
|
18
|
+
for (const item of seq) {
|
|
19
|
+
if (!item.asNumeric)
|
|
11
20
|
return false;
|
|
21
|
+
}
|
|
12
22
|
return true;
|
|
13
23
|
}
|
|
14
24
|
export function generateRange(start, end, step) {
|
|
@@ -18,13 +28,13 @@ export function generateRange(start, end, step) {
|
|
|
18
28
|
let current = start;
|
|
19
29
|
if (step > 0) {
|
|
20
30
|
while (current <= end) {
|
|
21
|
-
result.push(current);
|
|
31
|
+
result.push(new YuNumber(current));
|
|
22
32
|
current += step;
|
|
23
33
|
}
|
|
24
34
|
}
|
|
25
35
|
else {
|
|
26
36
|
while (current >= end) {
|
|
27
|
-
result.push(current);
|
|
37
|
+
result.push(new YuNumber(current));
|
|
28
38
|
current += step;
|
|
29
39
|
}
|
|
30
40
|
}
|
|
@@ -43,23 +53,8 @@ export function createGlobalEnv() {
|
|
|
43
53
|
};
|
|
44
54
|
}
|
|
45
55
|
export function getYukigoType(val) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
if (typeof val === "boolean")
|
|
51
|
-
return "YuBoolean";
|
|
52
|
-
if (typeof val === "string")
|
|
53
|
-
return val.length === 1 ? "YuChar" : "YuString";
|
|
54
|
-
if (Array.isArray(val) || isLazyList(val))
|
|
55
|
-
return "YuList";
|
|
56
|
-
if (isRuntimeFunction(val))
|
|
57
|
-
return "YuFunction";
|
|
58
|
-
if (isRuntimeObject(val))
|
|
59
|
-
return "YuObject";
|
|
60
|
-
if (isRuntimeClass(val))
|
|
61
|
-
return "YuClass";
|
|
62
|
-
if (isRuntimePredicate(val))
|
|
63
|
-
return "YuPredicate";
|
|
64
|
-
return "YuUnknown";
|
|
56
|
+
return val.getType();
|
|
57
|
+
}
|
|
58
|
+
export function createStream(generator) {
|
|
59
|
+
return new LazyList(() => generator());
|
|
65
60
|
}
|
package/dist/tester/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AST } from "yukigo-ast";
|
|
2
|
-
import { InterpreterConfig } from "../
|
|
2
|
+
import { InterpreterConfig } from "../utils/helpers.js";
|
|
3
3
|
export type TestStatus = "passed" | "failed" | "error";
|
|
4
4
|
export interface TestReport {
|
|
5
5
|
name: string;
|
|
@@ -14,8 +14,8 @@ export interface TestReport {
|
|
|
14
14
|
*/
|
|
15
15
|
export declare class Tester {
|
|
16
16
|
private ast;
|
|
17
|
-
private config
|
|
18
|
-
constructor(ast: AST, config?: InterpreterConfig);
|
|
17
|
+
private config;
|
|
18
|
+
constructor(ast: AST, config?: Partial<InterpreterConfig>);
|
|
19
19
|
/**
|
|
20
20
|
* Executes all Test and TestGroup nodes found at the top level of the provided AST.
|
|
21
21
|
* @param nodes The AST (or subset of nodes) to scan for tests.
|
package/dist/tester/index.js
CHANGED
|
@@ -1,19 +1,36 @@
|
|
|
1
1
|
import { Test, TestGroup, TraverseVisitor, } from "yukigo-ast";
|
|
2
2
|
import { Interpreter } from "../interpreter/index.js";
|
|
3
3
|
import { FailedAssert } from "../interpreter/components/TestRunner.js";
|
|
4
|
+
import { DefaultConfiguration, } from "../interpreter/components/RuntimeContext.js";
|
|
5
|
+
import { UnexpectedNode } from "../interpreter/errors.js";
|
|
4
6
|
class TestExecutor extends TraverseVisitor {
|
|
5
|
-
|
|
7
|
+
ast;
|
|
8
|
+
config;
|
|
9
|
+
parentGroupStatements;
|
|
6
10
|
report = null;
|
|
7
|
-
constructor(
|
|
11
|
+
constructor(ast, config, parentGroupStatements = []) {
|
|
8
12
|
super();
|
|
9
|
-
this.
|
|
13
|
+
this.ast = ast;
|
|
14
|
+
this.config = config;
|
|
15
|
+
this.parentGroupStatements = parentGroupStatements;
|
|
10
16
|
}
|
|
11
17
|
visitTest(node) {
|
|
12
|
-
const
|
|
18
|
+
const interpreter = new Interpreter(this.ast, this.config);
|
|
19
|
+
for (const stmt of this.parentGroupStatements) {
|
|
20
|
+
if (!(stmt instanceof Test) && !(stmt instanceof TestGroup)) {
|
|
21
|
+
interpreter.evaluate(stmt);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
const name = this.evaluateName(interpreter, node.name);
|
|
13
25
|
const start = Date.now();
|
|
14
26
|
try {
|
|
15
|
-
|
|
16
|
-
|
|
27
|
+
interpreter
|
|
28
|
+
.getContext()
|
|
29
|
+
.dispatchHook("beforeEachTest", interpreter, node);
|
|
30
|
+
interpreter.evaluate(node);
|
|
31
|
+
interpreter
|
|
32
|
+
.getContext()
|
|
33
|
+
.dispatchHook("afterEachTest", interpreter, node);
|
|
17
34
|
this.report = {
|
|
18
35
|
name,
|
|
19
36
|
status: "passed",
|
|
@@ -24,30 +41,20 @@ class TestExecutor extends TraverseVisitor {
|
|
|
24
41
|
this.report = this.handleError(name, start, error);
|
|
25
42
|
}
|
|
26
43
|
}
|
|
27
|
-
/* private bindParameters(node: Test): void {
|
|
28
|
-
if (!node.args || node.args.length === 0) return;
|
|
29
|
-
|
|
30
|
-
for (const pattern of node.args) {
|
|
31
|
-
if (pattern instanceof VariablePattern) {
|
|
32
|
-
this.interpreter.define(pattern.name.value, null);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
} */
|
|
36
44
|
visitTestGroup(node) {
|
|
37
|
-
const
|
|
45
|
+
const interpreter = new Interpreter(this.ast, this.config);
|
|
46
|
+
const name = this.evaluateName(interpreter, node.name);
|
|
38
47
|
const start = Date.now();
|
|
39
48
|
try {
|
|
40
49
|
const children = [];
|
|
50
|
+
const nonTestStmts = node.group.statements.filter((stmt) => !(stmt instanceof Test) && !(stmt instanceof TestGroup));
|
|
41
51
|
for (const stmt of node.group.statements) {
|
|
42
52
|
if (stmt instanceof Test || stmt instanceof TestGroup) {
|
|
43
|
-
const visitor = new TestExecutor(this.
|
|
53
|
+
const visitor = new TestExecutor(this.ast, this.config, [...this.parentGroupStatements, ...nonTestStmts]);
|
|
44
54
|
stmt.accept(visitor);
|
|
45
55
|
if (visitor.report)
|
|
46
56
|
children.push(visitor.report);
|
|
47
57
|
}
|
|
48
|
-
else {
|
|
49
|
-
this.interpreter.evaluate(stmt);
|
|
50
|
-
}
|
|
51
58
|
}
|
|
52
59
|
const anyFailed = children.some((c) => c.status !== "passed");
|
|
53
60
|
this.report = {
|
|
@@ -61,9 +68,9 @@ class TestExecutor extends TraverseVisitor {
|
|
|
61
68
|
this.report = this.handleError(name, start, error);
|
|
62
69
|
}
|
|
63
70
|
}
|
|
64
|
-
evaluateName(nameExpr) {
|
|
71
|
+
evaluateName(interpreter, nameExpr) {
|
|
65
72
|
try {
|
|
66
|
-
return String(
|
|
73
|
+
return String(interpreter.evaluate(nameExpr));
|
|
67
74
|
}
|
|
68
75
|
catch {
|
|
69
76
|
return "Unknown Test";
|
|
@@ -73,9 +80,13 @@ class TestExecutor extends TraverseVisitor {
|
|
|
73
80
|
const duration = Date.now() - start;
|
|
74
81
|
if (error instanceof FailedAssert)
|
|
75
82
|
return { name, status: "failed", message: error.message, duration };
|
|
83
|
+
console.error(error);
|
|
76
84
|
const message = error instanceof Error ? error.message : String(error);
|
|
77
85
|
return { name, status: "error", message, duration };
|
|
78
86
|
}
|
|
87
|
+
fallback(node) {
|
|
88
|
+
throw new UnexpectedNode(node.constructor.name, "TestExecutor");
|
|
89
|
+
}
|
|
79
90
|
}
|
|
80
91
|
/**
|
|
81
92
|
* The Tester class provides a high-level API for executing test nodes
|
|
@@ -84,7 +95,7 @@ class TestExecutor extends TraverseVisitor {
|
|
|
84
95
|
export class Tester {
|
|
85
96
|
ast;
|
|
86
97
|
config;
|
|
87
|
-
constructor(ast, config) {
|
|
98
|
+
constructor(ast, config = DefaultConfiguration) {
|
|
88
99
|
this.ast = ast;
|
|
89
100
|
this.config = config;
|
|
90
101
|
}
|
|
@@ -96,12 +107,12 @@ export class Tester {
|
|
|
96
107
|
test(nodes) {
|
|
97
108
|
const reports = [];
|
|
98
109
|
for (const node of nodes) {
|
|
99
|
-
if (node
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
110
|
+
if (!node.is(Test) && !node.is(TestGroup))
|
|
111
|
+
continue;
|
|
112
|
+
const visitor = new TestExecutor(this.ast, this.config);
|
|
113
|
+
node.accept(visitor);
|
|
114
|
+
if (visitor.report)
|
|
103
115
|
reports.push(visitor.report);
|
|
104
|
-
}
|
|
105
116
|
}
|
|
106
117
|
return reports;
|
|
107
118
|
}
|
package/dist/utils/helpers.d.ts
CHANGED
|
@@ -1,14 +1,22 @@
|
|
|
1
1
|
import { InspectionRule } from "../analyzer/index.js";
|
|
2
|
+
import { NativeExtension } from "../interpreter/utils.js";
|
|
3
|
+
import { YukigoHook } from "../interpreter/components/hooks/YukigoHook.js";
|
|
4
|
+
export type LogicSearchMode = "first" | "all" | "stream";
|
|
5
|
+
export interface InterpreterConfig {
|
|
6
|
+
nativeProviders: Map<string, NativeExtension>;
|
|
7
|
+
lazyLoading: boolean;
|
|
8
|
+
debug: boolean;
|
|
9
|
+
outputMode: LogicSearchMode;
|
|
10
|
+
mutability: boolean;
|
|
11
|
+
hooks?: YukigoHook[];
|
|
12
|
+
}
|
|
2
13
|
/**
|
|
3
14
|
* Translates Mulang inspections (YAML format) to an array of `InspectionRule` objects.
|
|
4
15
|
* @param mulangYamlString The Mulang inspection syntax as a YAML string.
|
|
5
16
|
* @returns An array of InspectionRule objects.
|
|
6
17
|
*/
|
|
7
18
|
export declare class MulangAdapter {
|
|
8
|
-
translateMulangInspection(mulangInspection:
|
|
19
|
+
translateMulangInspection(mulangInspection: any): InspectionRule;
|
|
9
20
|
translateMulangExpectations(mulangYamlString: string): InspectionRule[];
|
|
10
|
-
private
|
|
11
|
-
private parseNegation;
|
|
12
|
-
private applyV0ToV2;
|
|
13
|
-
private retrieveArguments;
|
|
21
|
+
private translateV0Inspection;
|
|
14
22
|
}
|