fixed test cases concerning identical paths and nested prefix paths

This commit is contained in:
overflowerror 2021-12-17 21:59:00 +01:00
parent 2726ec0e09
commit 36f790b37b

View file

@ -637,7 +637,7 @@ public class HoistingProcessorTest extends AbstractXtextTests {
HoistingGuard guard = hoistingProcessor.findHoistingGuard(rule.getAlternatives()); HoistingGuard guard = hoistingProcessor.findHoistingGuard(rule.getAlternatives());
assertFalse(guard.isTrivial()); assertFalse(guard.isTrivial());
assertTrue(guard.hasTerminal()); assertTrue(guard.hasTerminal());
assertEquals("((" + getSyntaxForKeywordToken("j", 10) + " || ((p0) || (p1))) && (" + getSyntaxForKeywordToken("k", 10) + " || (p2)))", guard.render()); assertEquals("((" + getSyntaxForKeywordToken("j", 10) + " || (p0) || (p1)) && (" + getSyntaxForKeywordToken("k", 10) + " || (p2)))", guard.render());
} }
@Test @Test
@ -658,7 +658,7 @@ public class HoistingProcessorTest extends AbstractXtextTests {
HoistingGuard guard = hoistingProcessor.findHoistingGuard(rule.getAlternatives()); HoistingGuard guard = hoistingProcessor.findHoistingGuard(rule.getAlternatives());
assertFalse(guard.isTrivial()); assertFalse(guard.isTrivial());
assertTrue(guard.hasTerminal()); assertTrue(guard.hasTerminal());
assertEquals("((" + getSyntaxForKeywordToken("a", 1) + " || ((p0) || (p1))) && (" + getSyntaxForKeywordToken("b", 1) + " || (p2)))", guard.render()); assertEquals("((" + getSyntaxForKeywordToken("a", 1) + " || (p0) || (p1)) && (" + getSyntaxForKeywordToken("b", 1) + " || (p2)))", guard.render());
// number of elements in Alternatives object has to stay the same // number of elements in Alternatives object has to stay the same
// even though the identical paths are collapsed during the hoisting process // even though the identical paths are collapsed during the hoisting process
@ -924,12 +924,13 @@ public class HoistingProcessorTest extends AbstractXtextTests {
HoistingGuard guard = hoistingProcessor.findHoistingGuard(rule.getAlternatives()); HoistingGuard guard = hoistingProcessor.findHoistingGuard(rule.getAlternatives());
assertFalse(guard.isTrivial()); assertFalse(guard.isTrivial());
assertTrue(guard.hasTerminal()); assertTrue(guard.hasTerminal());
System.out.println(guard.render()); System.out.println(guard.toString());
assertEquals( assertEquals(
"(" + "(" +
"(" + getSyntaxForKeywordToken("a", 1) + " || (" + getSyntaxForEofToken(2) + " && " + getSyntaxForKeywordToken("b", 2) + ") || (p0)) && " + "(" + getSyntaxForKeywordToken("a", 1) + " || " + getSyntaxForEofToken(2) + " || (p0) || (p1)) && " +
"(" + getSyntaxForKeywordToken("a", 1) + " || (" + getSyntaxForEofToken(2) + " && " + getSyntaxForKeywordToken("c", 2) + ") || (p1)) && " + "(" + getSyntaxForKeywordToken("b", 2) + " || (p0)) && " +
"(" + getSyntaxForKeywordToken("d", 1) + " || (p2))" + "(" + getSyntaxForKeywordToken("c", 2) + " || (p1)) && " +
"(" + getSyntaxForKeywordToken("d", 1) + " || (p2))" +
")", ")",
guard.render() guard.render()
); );