示例#1
0
 @Test
 public void testConstructor() {
   Symbol symbol = new Symbol("Symbol1", SymbolType.CONTENT, 2);
   Production production = new Production(symbol, 7);
   assertEquals("head", symbol, production.getHead());
   assertEquals("handle", 0, production.getHandle().size());
   assertEquals("index", 7, production.getTableIndex());
 }
示例#2
0
  @Test
  public void testSetters() {
    Symbol symbol = new Symbol("Symbol1", SymbolType.CONTENT, 2);
    Production production = new Production(symbol, 7);

    // Setting to null creates a new, empty list
    production.setHandle(null);
    assertNotNull("handle", production.getHandle());

    Symbol newSymbol = new Symbol("Symbol2", SymbolType.CONTENT, 2);
    production.setHead(newSymbol);

    SymbolList newList = new SymbolList(3);
    production.setHandle(newList);

    production.setTableIndex(44);

    assertEquals("head", newSymbol, production.getHead());
    assertEquals("handle", newList, production.getHandle());
    assertEquals("handle size", 3, production.getHandle().size());
    assertEquals("index", 44, production.getTableIndex());
  }