//System.out.print(result);
List<Integer> unreachableAlts = dfa.getUnreachableAlts();
// make sure unreachable alts are as expected
if ( expectingUnreachableAlts!=null ) {
BitSet s = new BitSet();
s.addAll(expectingUnreachableAlts);
BitSet s2 = new BitSet();
s2.addAll(unreachableAlts);
assertEquals("unreachable alts mismatch", s, s2);
}
else {
assertEquals("unreachable alts mismatch", 0,
unreachableAlts!=null?unreachableAlts.size():0);
}
// check conflicting input
if ( expectingAmbigInput!=null ) {
// first, find nondet message
Message msg = getNonDeterminismMessage(equeue.warnings);
assertNotNull("no nondeterminism warning?", msg);
assertTrue("expecting nondeterminism; found "+msg.getClass().getName(),
msg instanceof GrammarNonDeterminismMessage);
GrammarNonDeterminismMessage nondetMsg =
getNonDeterminismMessage(equeue.warnings);
List<Label> labels =
nondetMsg.probe.getSampleNonDeterministicInputSequence(nondetMsg.problemState);
String input = nondetMsg.probe.getInputSequenceDisplay(labels);
assertEquals(expectingAmbigInput, input);
}
// check nondet alts
if ( expectingNonDetAlts!=null ) {
GrammarNonDeterminismMessage nondetMsg =
getNonDeterminismMessage(equeue.warnings);
assertNotNull("found no nondet alts; expecting: "+
str(expectingNonDetAlts), nondetMsg);
List<Integer> nonDetAlts =
nondetMsg.probe.getNonDeterministicAltsForState(nondetMsg.problemState);
// compare nonDetAlts with expectingNonDetAlts
BitSet s = new BitSet();
s.addAll(expectingNonDetAlts);
BitSet s2 = new BitSet();
s2.addAll(nonDetAlts);
assertEquals("nondet alts mismatch", s, s2);
assertEquals("mismatch between expected hasPredHiddenByAction", hasPredHiddenByAction,
nondetMsg.problemState.dfa.hasPredicateBlockedByAction);
}
else {
// not expecting any nondet alts, make sure there are none
GrammarNonDeterminismMessage nondetMsg =
getNonDeterminismMessage(equeue.warnings);
assertNull("found nondet alts, but expecting none", nondetMsg);
}
if ( expectingInsufficientPredAlts!=null ) {
GrammarInsufficientPredicatesMessage insuffPredMsg =
getGrammarInsufficientPredicatesMessage(equeue.warnings);
assertNotNull("found no GrammarInsufficientPredicatesMessage alts; expecting: "+
str(expectingNonDetAlts), insuffPredMsg);
Map<Integer, Set<Token>> locations = insuffPredMsg.altToLocations;
Set<Integer> actualAlts = locations.keySet();
BitSet s = new BitSet();
s.addAll(expectingInsufficientPredAlts);
BitSet s2 = new BitSet();
s2.addAll(actualAlts);
assertEquals("mismatch between insufficiently covered alts", s, s2);
assertEquals("mismatch between expected hasPredHiddenByAction", hasPredHiddenByAction,
insuffPredMsg.problemState.dfa.hasPredicateBlockedByAction);
}
else {