yukigo 0.3.1 → 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/CHANGELOG.md +14 -0
- package/dist/utils/helpers.d.ts +1 -0
- package/dist/utils/helpers.js +35 -6
- package/package.json +1 -1
- package/src/utils/helpers.ts +44 -12
- package/tests/analyzer/helpers.spec.ts +2 -2
- package/tests/tester/Tester.spec.ts +0 -32
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## 0.3.2 (2026-08-04)
|
|
2
|
+
|
|
3
|
+
### 🩹 Fixes
|
|
4
|
+
|
|
5
|
+
- **yukigo:** fix v0 Mulang Inspections translation ([2995ccc](https://github.com/miyukiproject/yukigo/commit/2995ccc))
|
|
6
|
+
|
|
7
|
+
### 🧱 Updated Dependencies
|
|
8
|
+
|
|
9
|
+
- Updated yukigo-ast to 0.3.2
|
|
10
|
+
|
|
11
|
+
### ❤️ Thank You
|
|
12
|
+
|
|
13
|
+
- noiseArch
|
|
14
|
+
|
|
1
15
|
## 0.3.1 (2026-08-01)
|
|
2
16
|
|
|
3
17
|
### 🧱 Updated Dependencies
|
package/dist/utils/helpers.d.ts
CHANGED
package/dist/utils/helpers.js
CHANGED
|
@@ -1,4 +1,28 @@
|
|
|
1
1
|
import { parseDocument } from "yaml";
|
|
2
|
+
const V0_INSPECTIONS_Has = [
|
|
3
|
+
"HasComposition",
|
|
4
|
+
"HasComprehension",
|
|
5
|
+
"HasForeach",
|
|
6
|
+
"HasIf",
|
|
7
|
+
"HasGuards",
|
|
8
|
+
"HasConditional",
|
|
9
|
+
"HasLambda",
|
|
10
|
+
"HasRepeat",
|
|
11
|
+
"HasWhile",
|
|
12
|
+
"HasAnonymousVariable",
|
|
13
|
+
"HasNot",
|
|
14
|
+
"HasForall",
|
|
15
|
+
"HasFindall",
|
|
16
|
+
];
|
|
17
|
+
const V0_INSPECTIONS_Declares = new Map([
|
|
18
|
+
["HasBinding", "Declares"],
|
|
19
|
+
["HasTypeDeclaration", "DeclaresTypeAlias"],
|
|
20
|
+
["HasTypeSignature", "DeclaresTypeSignature"],
|
|
21
|
+
["HasVariable", "DeclaresVariable"],
|
|
22
|
+
["HasArity", "DeclaresComputationWithArity"],
|
|
23
|
+
["HasDirectRecursion", "DeclaresRecursively"],
|
|
24
|
+
["HasUsage", "Uses"],
|
|
25
|
+
]);
|
|
2
26
|
const isValidFormat = (inspection) => typeof inspection === "object" &&
|
|
3
27
|
"inspection" in inspection &&
|
|
4
28
|
"binding" in inspection;
|
|
@@ -14,8 +38,10 @@ export class MulangAdapter {
|
|
|
14
38
|
const inspection = mulangInspection.inspection.split(":");
|
|
15
39
|
const expected = inspection[0] !== "Not" && inspection[0] !== "Except";
|
|
16
40
|
const args = inspection.slice(expected ? 1 : 2);
|
|
41
|
+
const inspectionV0 = expected ? inspection[0] : inspection[1];
|
|
42
|
+
const inspectionV2 = this.translateV0Inspection(inspectionV0);
|
|
17
43
|
return {
|
|
18
|
-
inspection:
|
|
44
|
+
inspection: inspectionV2,
|
|
19
45
|
expected,
|
|
20
46
|
args,
|
|
21
47
|
binding: mulangInspection.binding,
|
|
@@ -37,11 +63,14 @@ export class MulangAdapter {
|
|
|
37
63
|
else {
|
|
38
64
|
throw new Error("Invalid Mulang YAML structure. Expected 'expectations' to be an array.");
|
|
39
65
|
}
|
|
40
|
-
const inspectionRules =
|
|
41
|
-
for (const mulangInspection of expectations) {
|
|
42
|
-
const inspection = this.translateMulangInspection(mulangInspection);
|
|
43
|
-
inspectionRules.push(inspection);
|
|
44
|
-
}
|
|
66
|
+
const inspectionRules = expectations.map((insp) => this.translateMulangInspection(insp));
|
|
45
67
|
return inspectionRules;
|
|
46
68
|
}
|
|
69
|
+
translateV0Inspection(inspection) {
|
|
70
|
+
if (V0_INSPECTIONS_Declares.has(inspection))
|
|
71
|
+
return V0_INSPECTIONS_Declares.get(inspection);
|
|
72
|
+
if (V0_INSPECTIONS_Has.includes(inspection))
|
|
73
|
+
return inspection.replace("Has", "Uses");
|
|
74
|
+
return inspection;
|
|
75
|
+
}
|
|
47
76
|
}
|
package/package.json
CHANGED
package/src/utils/helpers.ts
CHANGED
|
@@ -1,10 +1,34 @@
|
|
|
1
1
|
import { parseDocument } from "yaml";
|
|
2
2
|
import { InspectionRule } from "../analyzer/index.js";
|
|
3
3
|
import { NativeExtension } from "../interpreter/utils.js";
|
|
4
|
-
import { RuntimeContext } from "../interpreter/components/RuntimeContext.js";
|
|
5
|
-
import { YuValue } from "../interpreter/index.js";
|
|
6
4
|
import { YukigoHook } from "../interpreter/components/hooks/YukigoHook.js";
|
|
7
5
|
|
|
6
|
+
const V0_INSPECTIONS_Has = [
|
|
7
|
+
"HasComposition",
|
|
8
|
+
"HasComprehension",
|
|
9
|
+
"HasForeach",
|
|
10
|
+
"HasIf",
|
|
11
|
+
"HasGuards",
|
|
12
|
+
"HasConditional",
|
|
13
|
+
"HasLambda",
|
|
14
|
+
"HasRepeat",
|
|
15
|
+
"HasWhile",
|
|
16
|
+
"HasAnonymousVariable",
|
|
17
|
+
"HasNot",
|
|
18
|
+
"HasForall",
|
|
19
|
+
"HasFindall",
|
|
20
|
+
];
|
|
21
|
+
|
|
22
|
+
const V0_INSPECTIONS_Declares: Map<string, string> = new Map([
|
|
23
|
+
["HasBinding", "Declares"],
|
|
24
|
+
["HasTypeDeclaration", "DeclaresTypeAlias"],
|
|
25
|
+
["HasTypeSignature", "DeclaresTypeSignature"],
|
|
26
|
+
["HasVariable", "DeclaresVariable"],
|
|
27
|
+
["HasArity", "DeclaresComputationWithArity"],
|
|
28
|
+
["HasDirectRecursion", "DeclaresRecursively"],
|
|
29
|
+
["HasUsage", "Uses"],
|
|
30
|
+
]);
|
|
31
|
+
|
|
8
32
|
type MulangInspection = {
|
|
9
33
|
inspection: string;
|
|
10
34
|
binding: string;
|
|
@@ -34,7 +58,7 @@ export class MulangAdapter {
|
|
|
34
58
|
public translateMulangInspection(mulangInspection: any): InspectionRule {
|
|
35
59
|
if (!isValidFormat(mulangInspection))
|
|
36
60
|
throw new Error(
|
|
37
|
-
`Skipping malformed Mulang inspection entry: ${mulangInspection}
|
|
61
|
+
`Skipping malformed Mulang inspection entry: ${mulangInspection}`,
|
|
38
62
|
);
|
|
39
63
|
|
|
40
64
|
const inspection: string[] = mulangInspection.inspection.split(":");
|
|
@@ -42,8 +66,10 @@ export class MulangAdapter {
|
|
|
42
66
|
inspection[0] !== "Not" && inspection[0] !== "Except";
|
|
43
67
|
const args: string[] = inspection.slice(expected ? 1 : 2);
|
|
44
68
|
|
|
69
|
+
const inspectionV0 = expected ? inspection[0] : inspection[1];
|
|
70
|
+
const inspectionV2 = this.translateV0Inspection(inspectionV0);
|
|
45
71
|
return {
|
|
46
|
-
inspection:
|
|
72
|
+
inspection: inspectionV2,
|
|
47
73
|
expected,
|
|
48
74
|
args,
|
|
49
75
|
binding: mulangInspection.binding,
|
|
@@ -51,7 +77,7 @@ export class MulangAdapter {
|
|
|
51
77
|
}
|
|
52
78
|
|
|
53
79
|
public translateMulangExpectations(
|
|
54
|
-
mulangYamlString: string
|
|
80
|
+
mulangYamlString: string,
|
|
55
81
|
): InspectionRule[] {
|
|
56
82
|
if (!mulangYamlString) return [];
|
|
57
83
|
const parsedYaml = parseDocument(mulangYamlString).toJS();
|
|
@@ -65,17 +91,23 @@ export class MulangAdapter {
|
|
|
65
91
|
expectations = parsedYaml.expectations;
|
|
66
92
|
} else {
|
|
67
93
|
throw new Error(
|
|
68
|
-
"Invalid Mulang YAML structure. Expected 'expectations' to be an array."
|
|
94
|
+
"Invalid Mulang YAML structure. Expected 'expectations' to be an array.",
|
|
69
95
|
);
|
|
70
96
|
}
|
|
71
97
|
|
|
72
|
-
const inspectionRules: InspectionRule[] =
|
|
98
|
+
const inspectionRules: InspectionRule[] = expectations.map((insp) =>
|
|
99
|
+
this.translateMulangInspection(insp),
|
|
100
|
+
);
|
|
101
|
+
return inspectionRules;
|
|
102
|
+
}
|
|
73
103
|
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
}
|
|
104
|
+
private translateV0Inspection(inspection: string): string {
|
|
105
|
+
if (V0_INSPECTIONS_Declares.has(inspection))
|
|
106
|
+
return V0_INSPECTIONS_Declares.get(inspection)!;
|
|
78
107
|
|
|
79
|
-
|
|
108
|
+
if (V0_INSPECTIONS_Has.includes(inspection))
|
|
109
|
+
return inspection.replace("Has", "Uses");
|
|
110
|
+
|
|
111
|
+
return inspection;
|
|
80
112
|
}
|
|
81
113
|
}
|
|
@@ -33,7 +33,7 @@ expectations:
|
|
|
33
33
|
mulangAdapter.translateMulangExpectations(mulangExpectations);
|
|
34
34
|
assert.deepEqual(yukigoExpectations, [
|
|
35
35
|
{
|
|
36
|
-
inspection: "
|
|
36
|
+
inspection: "Declares",
|
|
37
37
|
binding: "squareList",
|
|
38
38
|
args: [],
|
|
39
39
|
expected: true,
|
|
@@ -51,7 +51,7 @@ expectations:
|
|
|
51
51
|
expected: true,
|
|
52
52
|
},
|
|
53
53
|
{
|
|
54
|
-
inspection: "
|
|
54
|
+
inspection: "Declares",
|
|
55
55
|
binding: "doble",
|
|
56
56
|
args: [],
|
|
57
57
|
expected: false,
|
|
@@ -153,36 +153,4 @@ describe("Tester class", () => {
|
|
|
153
153
|
expect(results[0].status).to.equal("error");
|
|
154
154
|
expect(results[0].message).to.contain("Type mismatch");
|
|
155
155
|
});
|
|
156
|
-
it("TEMP", () => {
|
|
157
|
-
const func = new Function(new SymbolPrimitive("cantidadDiasEnero"), [
|
|
158
|
-
new Equation(
|
|
159
|
-
[],
|
|
160
|
-
new UnguardedBody(new Sequence([new Return(new NumberPrimitive(23))])),
|
|
161
|
-
),
|
|
162
|
-
]);
|
|
163
|
-
// test "Error" { 1 + "a" }
|
|
164
|
-
const errorTest = new TestGroup(
|
|
165
|
-
new StringPrimitive("cantidadDiasEnero"),
|
|
166
|
-
new Sequence([
|
|
167
|
-
new Test(
|
|
168
|
-
new StringPrimitive("es igual a 31"),
|
|
169
|
-
new Sequence([
|
|
170
|
-
new Assert(
|
|
171
|
-
new BooleanPrimitive(false),
|
|
172
|
-
new Equality(
|
|
173
|
-
new NumberPrimitive(31),
|
|
174
|
-
new SymbolPrimitive("cantidadDiasEnero"),
|
|
175
|
-
),
|
|
176
|
-
),
|
|
177
|
-
]),
|
|
178
|
-
[],
|
|
179
|
-
),
|
|
180
|
-
]),
|
|
181
|
-
);
|
|
182
|
-
|
|
183
|
-
const tester = new Tester([func]);
|
|
184
|
-
const results = tester.test([errorTest]);
|
|
185
|
-
|
|
186
|
-
console.log(results)
|
|
187
|
-
});
|
|
188
156
|
});
|