Nonterminal C = new Nonterminal("C");
Nonterminal D = new Nonterminal("D");
grammar = new Grammar();
Production production = new Production(A);
production.getDefinition().addSymbol(B);
production.getDefinition().addSymbol(a);
grammar.addProduction(production);
production = new Production(B);
production.getDefinition().addSymbol(b);
grammar.addProduction(production);
production = new Production(C);
production.getDefinition().addSymbol(B);
production.getDefinition().addSymbol(D);
grammar.addProduction(production);
production = new Production(D);
// empty
grammar.addProduction(production);
firstsets = new FirstSetCollection(grammar);
set = new ItemSet(grammar, firstsets);
set.addItem(0, 0, c);
result = new ItemSet(grammar, firstsets);
result.addItem(0, 0, c);
result.addItem(1, 0, a);
assertEquals("Test if sets are equal", result, set.closure());
set = new ItemSet(grammar, firstsets);
set.addItem(2, 0, a);
result = new ItemSet(grammar, firstsets);
result.addItem(2, 0, a);
result.addItem(1, 0, a);
assertEquals("Test if sets are equal", result, set.closure());
// ---- Case 3 ----
grammar = new Grammar();
production = new Production(A);
production.getDefinition().addSymbol(B);
production.getDefinition().addSymbol(D);
grammar.addProduction(production);
production = new Production(B);
production.getDefinition().addSymbol(C);
grammar.addProduction(production);
production = new Production(C);
production.getDefinition().addSymbol(d);
grammar.addProduction(production);
production = new Production(D);
production.getDefinition().addSymbol(b);
grammar.addProduction(production);
firstsets = new FirstSetCollection(grammar);
set = new ItemSet(grammar, firstsets);