diff options
| author | Michael Williamson <mike@zwobble.org> | 2026-06-14 11:12:46 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2026-06-14 11:12:46 +0100 |
| commit | 6465a06977c79ccb3c328d3c97d6873066e46b11 (patch) | |
| tree | e50fbbee8b097051a3a1b9c96943a42895390c4c /src/test | |
| parent | 8f4049e29116e1f80a2ab8d740ca1f4519a64aa2 (diff) | |
Create ancestor depth field
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/java/org/zwobble/hobgoblin/compiler/ast/untyped/UntypedImportNodeMatcher.java | 4 | ||||
| -rw-r--r-- | src/test/java/org/zwobble/hobgoblin/compiler/parser/ParserNamespaceTests.java | 7 |
2 files changed, 9 insertions, 2 deletions
diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/ast/untyped/UntypedImportNodeMatcher.java b/src/test/java/org/zwobble/hobgoblin/compiler/ast/untyped/UntypedImportNodeMatcher.java index 9c8c183..e902170 100644 --- a/src/test/java/org/zwobble/hobgoblin/compiler/ast/untyped/UntypedImportNodeMatcher.java +++ b/src/test/java/org/zwobble/hobgoblin/compiler/ast/untyped/UntypedImportNodeMatcher.java @@ -29,6 +29,10 @@ public class UntypedImportNodeMatcher implements org.zwobble.precisely.Matcher<j return new org.zwobble.hobgoblin.compiler.ast.untyped.UntypedImportNodeMatcher(java.util.stream.Stream.concat(this.submatchers.stream(), java.util.stream.Stream.of(org.zwobble.precisely.Matchers.has("importedNames", org.zwobble.hobgoblin.compiler.ast.untyped.UntypedImportNode::importedNames, importedNames))).toList()); } + public org.zwobble.hobgoblin.compiler.ast.untyped.UntypedImportNodeMatcher withAncestorDepth(org.zwobble.precisely.Matcher<? super java.util.Optional<java.lang.Integer>> ancestorDepth) { + return new org.zwobble.hobgoblin.compiler.ast.untyped.UntypedImportNodeMatcher(java.util.stream.Stream.concat(this.submatchers.stream(), java.util.stream.Stream.of(org.zwobble.precisely.Matchers.has("ancestorDepth", org.zwobble.hobgoblin.compiler.ast.untyped.UntypedImportNode::ancestorDepth, ancestorDepth))).toList()); + } + public org.zwobble.hobgoblin.compiler.ast.untyped.UntypedImportNodeMatcher withNamespaceName(org.zwobble.precisely.Matcher<? super org.zwobble.hobgoblin.compiler.types.NamespaceName> namespaceName) { return new org.zwobble.hobgoblin.compiler.ast.untyped.UntypedImportNodeMatcher(java.util.stream.Stream.concat(this.submatchers.stream(), java.util.stream.Stream.of(org.zwobble.precisely.Matchers.has("namespaceName", org.zwobble.hobgoblin.compiler.ast.untyped.UntypedImportNode::namespaceName, namespaceName))).toList()); } diff --git a/src/test/java/org/zwobble/hobgoblin/compiler/parser/ParserNamespaceTests.java b/src/test/java/org/zwobble/hobgoblin/compiler/parser/ParserNamespaceTests.java index 4df8b95..ada6414 100644 --- a/src/test/java/org/zwobble/hobgoblin/compiler/parser/ParserNamespaceTests.java +++ b/src/test/java/org/zwobble/hobgoblin/compiler/parser/ParserNamespaceTests.java @@ -42,13 +42,16 @@ public class ParserNamespaceTests { .withImports(isSequence( isUntypedImportNode() .withImportedNames(isSequence(equalTo("Point"))) + .withAncestorDepth(isOptionalEmpty()) .withNamespaceName(equalTo(NamespaceName.of("point"))), isUntypedImportNode() .withImportedNames(isSequence(equalTo("Square"), equalTo("Rectangle"))) - .withNamespaceName(equalTo(NamespaceName.of(".", "shapes"))), + .withAncestorDepth(isOptionalOf(equalTo(0))) + .withNamespaceName(equalTo(NamespaceName.of("shapes"))), isUntypedImportNode() .withImportedNames(isSequence(equalTo("Line"))) - .withNamespaceName(equalTo(NamespaceName.of("..", "..", "line"))) + .withAncestorDepth(isOptionalOf(equalTo(2))) + .withNamespaceName(equalTo(NamespaceName.of("line"))) )) ); } |
