Program { public final void addVariable(final Variable var) throws VariableAlreadyDeclared { if (this.variables.containsKey(var.getId())) { throw new VariableAlreadyDeclared(); } this.variables.put(var.getId(), var); } Program(final String id); final String getId(); final Variable getVariable(final String id); final void addVariable(final Variable var); final Function getFunction(final String id); final void addFunction(final Function function); final OperationSequence getBody(); Set<Variable> getVariables(); Set<Function> getFunctions(); @Override final String toString();  }
@Test(expected = VariableAlreadyDeclared.class) public void testAddVariable() throws Exception { Program program = new Program("test"); Variable v = Variable.create(Type.INT, "v", "10"); program.addVariable(v); program.addVariable(Variable.create(Type.INT, "v", "10")); }