Esempio n. 1
0
 @Test
 public void testConst() throws StackRuntimeException {
   List<Instruction> instructions = new ArrayList<Instruction>();
   instructions.add(new Instruction("const", new IntStackValue(2)));
   StackMachine machine = new StackMachine(instructions);
   machine.step();
   assertEquals(new Integer(2), machine.getStack().pop().getValue());
 }
Esempio n. 2
0
 @Test
 public void testInput() throws StackRuntimeException {
   List<Instruction> instructions = new ArrayList<Instruction>();
   instructions.add(new Instruction("input"));
   List<StackValue<?>> input = new ArrayList<StackValue<?>>();
   input.add(new IntStackValue(2));
   StackMachine machine = new StackMachine(instructions, input);
   machine.step();
   assertEquals(new Integer(2), machine.getStack().pop().getValue());
 }