summaryrefslogtreecommitdiff
path: root/src/test/java/org
diff options
context:
space:
mode:
authorMichael Williamson <mike@zwobble.org>2026-08-29 10:15:00 +0100
committerMichael Williamson <mike@zwobble.org>2026-08-29 10:15:00 +0100
commit2b887718befc50679896368ae6852335ffff49a6 (patch)
tree72d1c0a7e1a68d08727b424bd26ae3410a97964f /src/test/java/org
parenta0c7aa1008f31e969fe868edf1f5408f3eaa959a (diff)
Add stubbed TypeScript code writer
Diffstat (limited to 'src/test/java/org')
-rw-r--r--src/test/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/TypescriptWriterTests.java46
-rw-r--r--src/test/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/ast/TypescriptModuleMatcher.java35
2 files changed, 81 insertions, 0 deletions
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
new file mode 100644
index 0000000..8712b4a
--- /dev/null
+++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/TypescriptWriterTests.java
@@ -0,0 +1,46 @@
+package org.zwobble.hobgoblin.compiler.output.lang.typescript;
+
+import org.junit.jupiter.api.Test;
+import org.zwobble.hobgoblin.compiler.output.CodeWriter;
+import org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptModule;
+
+import java.io.IOException;
+import java.io.StringWriter;
+import java.util.Optional;
+
+import static org.zwobble.precisely.AssertThat.assertThat;
+import static org.zwobble.precisely.Matchers.equalTo;
+
+public class TypescriptWriterTests {
+ // == Modules ==
+
+ @Test
+ public void emptyModule() throws IOException {
+ var typescript = new TypescriptModule();
+
+ var string = write(writer -> writer.writeModule(typescript));
+
+ assertThat(string, equalTo("""
+ // Generated by hobgoblin.
+
+ """
+ ));
+ }
+
+ private String write(TypescriptWriter.Write write) throws IOException {
+ return write(write, Optional.empty());
+ }
+
+ private String write(TypescriptWriter.Write write, String originalContents) throws IOException {
+ return write(write, Optional.of(originalContents));
+ }
+
+ private String write(TypescriptWriter.Write write, Optional<String> originalContents) throws IOException {
+ var stringWriter = new StringWriter();
+ TypescriptWriter.writeTo(
+ new CodeWriter.InMemoryCodeWriterFile(originalContents, stringWriter),
+ write
+ );
+ return stringWriter.toString();
+ }
+}
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
new file mode 100644
index 0000000..088dba0
--- /dev/null
+++ b/src/test/java/org/zwobble/hobgoblin/compiler/output/lang/typescript/ast/TypescriptModuleMatcher.java
@@ -0,0 +1,35 @@
+// Generated by hobgoblin.
+
+package org.zwobble.hobgoblin.compiler.output.lang.typescript.ast;
+
+// Custom area start: org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptModuleMatcher imports
+// Custom area end: org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptModuleMatcher imports
+
+public final class TypescriptModuleMatcher implements org.zwobble.precisely.Matcher<java.lang.Object> {
+ public static org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptModuleMatcher isTypescriptModule() {
+ return new org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptModuleMatcher(java.util.List.of());
+ }
+
+ private final java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptModule>> submatchers;
+
+ private TypescriptModuleMatcher(
+ java.util.List<org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.output.lang.typescript.ast.TypescriptModule>> 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.TypescriptModule.class, this.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
+}