add test for alternatives with only unguarded paths

This commit is contained in:
overflowerror 2021-11-27 16:55:38 +01:00
parent 61847d2d82
commit cb606d6937

View file

@ -294,6 +294,23 @@ public class HoistingProcessorTest extends AbstractXtextTests {
assertEquals("((" + getSyntaxForKeywordToken("j", 10) + " || ((p0) || (p1))) && (" + getSyntaxForKeywordToken("k", 10) + " || (p2)))", guard.render());
}
@Test
public void testAlternativeUnguarded() throws Exception {
// @formatter:off
String model =
MODEL_PREAMBLE +
"S: {S} 'a' \n" +
" | {S} 'b' ;";
// @formatter:off
XtextResource resource = getResourceFromString(model);
Grammar grammar = ((Grammar) resource.getContents().get(0));
AbstractRule rule = getRule(grammar, "S");
HoistingGuard guard = hoistingProcessor.findGuardForElement(rule.getAlternatives());
assertTrue(guard.isTrivial());
assertTrue(guard.hasTerminal());
}
@Test
public void testAlternativeUnguardedPath() throws Exception {
// @formatter:off