Skip to content

Commit

Permalink
-#360: Include second nameScope test for the def variant.
Browse files Browse the repository at this point in the history
This clearly shows the difference in parseGraph between the two
variants.

Co-authored-by: jvdb <jeroen@infix.ai>
  • Loading branch information
mvanaken and jvdb committed Mar 2, 2023
1 parent 9ee3a7f commit f28ffe9
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions core/src/test/java/io/parsingdata/metal/token/UntilTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -164,14 +164,25 @@ void errorNegativeSize() {
}

@Test
public void nameScope() {
public void nameScopeWithUntil() {
final Token terminator = def("terminator", con(1), eq(con(0x00)));
final Token token = seq("struct", until("value", terminator), terminator);
final Optional<ParseState> parse = token.parse(env(stream('d', 'a', 't', 'a', 0, 0)));
assertTrue(parse.isPresent());
assertEquals(1, getAllValues(parse.get().order, "struct.terminator").size);
assertEquals(1, getAllValues(parse.get().order, "struct.value").size);
assertEquals(1, getAllValues(parse.get().order, "struct.value.value").size);
assertEquals(1, getAllValues(parse.get().order, "struct.value.terminator").size);
assertEquals("data", getAllValues(parse.get().order, "struct.value.value").head.asString());
}

@Test
public void nameScopeWithDef() {
final Token terminator = def("terminator", con(1), eq(con(0x00)));
final Token token = seq("struct", def("value", terminator), terminator);
final Optional<ParseState> parse = token.parse(env(stream('d', 'a', 't', 'a', 0, 0)));
assertTrue(parse.isPresent());
assertEquals(1, getAllValues(parse.get().order, "struct.terminator").size);
assertEquals(1, getAllValues(parse.get().order, "struct.value").size);
assertEquals("data", getAllValues(parse.get().order, "struct.value").head.asString());
}

Expand Down

0 comments on commit f28ffe9

Please sign in to comment.