Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions Lara-JS/code/generate-ts-joinpoints.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import fs from "fs";
import os from "os";
import path from "path";
import { generateEnums } from "../scripts/generate-ts-joinpoints.ts";

describe("generateEnums", () => {
it("preserves the enum values from the language specification", () => {
const outputDirectory = fs.mkdtempSync(
path.join(os.tmpdir(), "lara-build-interfaces-"),
);
const outputPath = path.join(outputDirectory, "Joinpoints.ts");

try {
const outputFile = fs.openSync(outputPath, "w");
try {
generateEnums(
[{ name: "StorageClass", entries: ["NONE", "PRIVATE_EXTERN", "STATIC"] }],
outputFile,
);
} finally {
fs.closeSync(outputFile);
}

const output = fs.readFileSync(outputPath, "utf8");
expect(output).toContain(' STATIC: "STATIC",');
expect(output).toContain(' PRIVATE_EXTERN: "PRIVATE_EXTERN",');
} finally {
fs.rmSync(outputDirectory, { recursive: true, force: true });
}
});
});
2 changes: 1 addition & 1 deletion Lara-JS/scripts/generate-ts-joinpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ function generateEnum(e: ConvertedEnum, outputFile: number) {
*/\n`);
fs.writeSync(outputFile, `export const ${e.name} = {\n`);
e.entries.forEach((entry) => {
fs.writeSync(outputFile, ` ${entry}: "${entry.toLowerCase()}",\n`);
fs.writeSync(outputFile, ` ${entry}: "${entry}",\n`);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Honor enum display strings in generated values

When a v3 specification uses the supported value("STATIC", "static") form, JsonSerializer.writeEnumDef() emits both value and display, but convertEnum() discards display, so this line now generates STATIC: "STATIC". The Java bridge returns getDisplay() for enum attributes (WeaverGen2/src/org/lara/weavergen2/emit/JoinPointTypeRenderer.java:143-150), meaning the generated TypeScript type permits only "STATIC" while the runtime yields "static", breaking comparisons and the declared return type. Carry the display string through conversion and use it for the generated value, falling back to the programmatic value when absent.

Useful? React with 👍 / 👎.

});
fs.writeSync(outputFile, `} as const;\n`);
fs.writeSync(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ void testRunCommand_withNullTimeout_handlesGracefully() {
// Given
String command = "echo hello";
boolean printToConsole = false;
long timeoutNanos = 2000000000; // 2 seconds
Long timeoutNanos = null;

// When
ProcessOutputAsString result = LaraSystemTools.runCommand(command, workingDirectory, printToConsole, timeoutNanos);
Expand Down
Loading