use of org.whole.lang.grammars.model.Choose in project whole by wholeplatform.
the class IteratorFactoryTest method testTopDownIteratorAdd.
@Test
public void testTopDownIteratorAdd() {
Grammar g = new TestXmlGrammar().create();
Production production = (Production) g.getPhraseStructure().wGet(3);
Choose choose = (Choose) production.getRule();
int size = choose.wSize();
int count = 0;
Rule rAdded1 = null;
Rule rAdded2 = null;
IEntityIterator<IEntity> i = IteratorFactory.<IEntity>descendantOrSelfIterator();
i.reset(production);
i.next();
i.next();
while (i.hasNext()) {
IEntity r = i.next();
assertNotSame(rAdded1, r);
assertNotSame(rAdded2, r);
if (count == 0)
assertSame(choose, r);
else if (count == 1)
i.add(rAdded1 = GrammarsEntityFactory.instance.createProduction());
else if (count == 10) {
i.add(rAdded1 = GrammarsEntityFactory.instance.createProduction());
i.add(rAdded2 = GrammarsEntityFactory.instance.createProduction());
}
count++;
}
assertEquals(size + 3, choose.wSize());
}
Aggregations