summaryrefslogtreecommitdiff
path: root/src/test/java
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2026-08-29 19:45:38 +0100
committerMichael Williamson <mike@zwobble.org>2026-08-29 19:45:38 +0100
commit73b58b585b0e12b9baf263fdc55da2f2b501651f (patch)
tree89a5323be4808f8c74db4507aa03c655fabcc7ae /src/test/java
parent503786f64f2af7725b1b58408396000ede4b3cb4 (diff)
Generate empty TypeScript module for each namespace
Diffstat (limited to 'src/test/java')
-rw-r--r--src/test/java/org/zwobble/hobgoblin/compiler/ExampleTests.java27
-rw-r--r--src/test/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/TypescriptWriterTests.java2
-rw-r--r--src/test/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/ast/TypescriptIdentifierMatcher.java41
-rw-r--r--src/test/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/ast/TypescriptModuleMatcher.java6
4 files changed, 67 insertions, 9 deletions
diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/ExampleTests.java b/src/test/java/org/zwobble/hobgoblin/compiler/ExampleTests.java
index 1c77a83..3cc7048 100644
--- a/src/test/java/org/zwobble/hobgoblin/compiler/ExampleTests.java
+++ b/src/test/java/org/zwobble/hobgoblin/compiler/ExampleTests.java
@@ -32,6 +32,7 @@ public class ExampleTests {
var javaOutputPath = verifyJavaOutput(exampleSet);
var rustOutputPath = verifyRustOutput(exampleSet);
+ verifyTypescriptOutput(exampleSet);
// TODO: make detection more robust
if (exampleSet.name().contains("transient-0")) {
@@ -61,17 +62,24 @@ public class ExampleTests {
}
private Optional<Path> verifyJavaOutput(ExampleSet exampleSet) throws NoSuchAlgorithmException, IOException, InterruptedException {
- return verifyOutput(exampleSet, "java", List.of("mvn", "test"));
+ return verifyOutput(exampleSet, "java", List.of(List.of("mvn", "test")));
}
private Optional<Path> verifyRustOutput(ExampleSet exampleSet) throws NoSuchAlgorithmException, IOException, InterruptedException {
- return verifyOutput(exampleSet, "rust", List.of("cargo", "test"));
+ return verifyOutput(exampleSet, "rust", List.of(List.of("cargo", "test")));
+ }
+
+ private Optional<Path> verifyTypescriptOutput(ExampleSet exampleSet) throws NoSuchAlgorithmException, IOException, InterruptedException {
+ return verifyOutput(exampleSet, "typescript", List.of(
+ List.of("./node_modules/.bin/tsc", "--noEmit"),
+ List.of("npm", "test"))
+ );
}
private Optional<Path> verifyOutput(
ExampleSet exampleSet,
String name,
- List<String> command
+ List<List<String>> commands
) throws NoSuchAlgorithmException, IOException, InterruptedException {
var outputPath = exampleSet.path().resolve("output").resolve(name);
@@ -89,11 +97,14 @@ public class ExampleTests {
}
try {
- TestProcessRunner.command(command)
- .cwd(outputPath)
- .addEnvVar("HOBGOBLIN_OUTPUT_DIR", outputPath.toAbsolutePath().toString())
- .runCaptureOutput()
- .throwOnError();
+ for (var command : commands) {
+ TestProcessRunner.command(command)
+ .cwd(outputPath)
+ .addEnvVar("HOBGOBLIN_OUTPUT_DIR", outputPath.toAbsolutePath().toString())
+ .runCaptureOutput()
+ .throwOnError();
+ }
+
writeLastTestRun(lastTestRunPath, new LastTestRun(currentHash, true));
} catch (Throwable exception) {
writeLastTestRun(lastTestRunPath, new LastTestRun(currentHash, false));
diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/TypescriptWriterTests.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/TypescriptWriterTests.java
index 8712b4a..71978f0 100644
--- a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/TypescriptWriterTests.java
+++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/TypescriptWriterTests.java
@@ -16,7 +16,7 @@ public class TypescriptWriterTests {
@Test
public void emptyModule() throws IOException {
- var typescript = new TypescriptModule();
+ var typescript = TypescriptModule.arbitrary().build();
var string = write(writer -> writer.writeModule(typescript));
diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/ast/TypescriptIdentifierMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/ast/TypescriptIdentifierMatcher.java
new file mode 100644
index 0000000..d54b193
--- /dev/null
+++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/ast/TypescriptIdentifierMatcher.java
@@ -0,0 +1,41 @@
+// Generated by hobgoblin.
+
+package org.zwobble.hobgoblin.compiler.output.lang.typescript.ast;
+
+// Custom area start: org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptIdentifierMatcher imports
+// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptIdentifierMatcher imports
+
+public final class TypescriptIdentifierMatcher implements org.zwobble.precisely.Matcher<java.lang.Object> {
+ public static org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptIdentifierMatcher isTypescriptIdentifier() {
+ return new org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptIdentifierMatcher(java.util.List.of());
+ }
+
+ private final java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptIdentifier>> submatchers;
+
+ private TypescriptIdentifierMatcher(
+ java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptIdentifier>> submatchers
+ ) {
+ this.submatchers = submatchers;
+ }
+
+ public org.zwobble.precisely.MatchResult match(java.lang.Object actual) {
+ return this.toMatcher().match(actual);
+ }
+
+ public org.zwobble.precisely.TextTree describe() {
+ return this.toMatcher().describe();
+ }
+
+ private org.zwobble.precisely.Matcher<java.lang.Object> toMatcher() {
+ return org.zwobble.precisely.Matchers.instanceOf(org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptIdentifier.class, this.submatchers);
+ }
+
+ public org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptIdentifierMatcher withValue(org.zwobble.precisely.Matcher<? super String> value) {
+ var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptIdentifier>>(this.submatchers);
+ submatchers.add(org.zwobble.precisely.Matchers.has("value", org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptIdentifier::value, value));
+ return new org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptIdentifierMatcher(submatchers);
+ }
+
+ // Custom area start: org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptIdentifierMatcher body
+ // Custom area end: org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptIdentifierMatcher body
+}
diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/ast/TypescriptModuleMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/ast/TypescriptModuleMatcher.java
index 088dba0..2a9f2f5 100644
--- a/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/ast/TypescriptModuleMatcher.java
+++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/ast/TypescriptModuleMatcher.java
@@ -30,6 +30,12 @@ public final class TypescriptModuleMatcher implements org.zwobble.precisely.Matc
return org.zwobble.precisely.Matchers.instanceOf(org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptModule.class, this.submatchers);
}
+ public org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptModuleMatcher withName(org.zwobble.precisely.Matcher<? super java.util.List<org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptIdentifier>> name) {
+ var submatchers = new java.util.ArrayList<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptModule>>(this.submatchers);
+ submatchers.add(org.zwobble.precisely.Matchers.has("name", org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptModule::name, name));
+ return new org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptModuleMatcher(submatchers);
+ }
+
// Custom area start: org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptModuleMatcher body
// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptModuleMatcher body
}