use of org.batfish.grammar.MockGrammarSettings in project batfish by batfish.
the class RecoveryGrammarTest method testParsingRecoveryWithModes.
@Test
public void testParsingRecoveryWithModes() {
String recoveryText = CommonUtil.readResource("org/batfish/grammar/recovery/recovery_badmode");
GrammarSettings settings = new MockGrammarSettings(false, 0, 0, 0, false, true, true);
RecoveryCombinedParser cp = new RecoveryCombinedParser(recoveryText, settings);
RecoveryContext ctx = cp.parse();
RecoveryExtractor extractor = new RecoveryExtractor();
ParseTreeWalker walker = new ParseTreeWalker();
walker.walk(extractor, ctx);
assertThat(extractor.getFirstErrorLine(), equalTo(4));
assertThat(extractor.getNumErrorNodes(), equalTo(1));
}
use of org.batfish.grammar.MockGrammarSettings in project batfish by batfish.
the class RecoveryGrammarTest method testParsingRecovery.
@Test
public void testParsingRecovery() {
String recoveryText = CommonUtil.readResource("org/batfish/grammar/recovery/recovery_text");
int totalLines = recoveryText.split("\n", -1).length;
GrammarSettings settings = new MockGrammarSettings(false, 0, 0, 0, false, true, true);
RecoveryCombinedParser cp = new RecoveryCombinedParser(recoveryText, settings);
RecoveryContext ctx = cp.parse();
RecoveryExtractor extractor = new RecoveryExtractor();
ParseTreeWalker walker = new ParseTreeWalker();
walker.walk(extractor, ctx);
assertThat(extractor.getFirstErrorLine(), equalTo(2));
assertThat(extractor.getNumBlockStatements(), equalTo(2));
assertThat(extractor.getNumErrorNodes(), equalTo(15));
assertThat(extractor.getNumInnerStatements(), equalTo(1));
assertThat(extractor.getNumSimpleStatements(), equalTo(5));
assertThat(extractor.getNumStatements(), equalTo(extractor.getNumBlockStatements() + extractor.getNumSimpleStatements()));
assertThat(extractor.getNumTailWords(), equalTo(5));
/*
* We don't know how many lines were hidden comments, so we only know there should be more
* lines than the ones that actually end up in the parse tree.
*/
assertThat(totalLines, greaterThanOrEqualTo(extractor.getNumBlockStatements() + extractor.getNumInnerStatements() + extractor.getNumSimpleStatements() + extractor.getNumErrorNodes()));
}
Aggregations