}
public void testVMExecuteSimple() throws RecognitionException, IOException {
{
VM vm = new VM("" + "INTEGERS { variable.a } "
+ "FUNCTION {init.state.consts}{ #5 'variable.a := } "
+ "EXECUTE {init.state.consts}");
Vector<BibtexEntry> v = new Vector<BibtexEntry>();
vm.run(v);
assertEquals(new Integer(5), vm.getIntegers().get("variable.a"));
}
{
VM vm = new VM("FUNCTION {a}{ #5 #5 = " + "#1 #2 = " + "#3 #4 < " + "#4 #3 < "
+ "#4 #4 < " + "#3 #4 > " + "#4 #3 > " + "#4 #4 > " + "\"H\" \"H\" = "
+ "\"H\" \"Ha\" = } " + "EXECUTE {a}");
Vector<BibtexEntry> v = new Vector<BibtexEntry>();
vm.run(v);
assertEquals(VM.FALSE, vm.getStack().pop());
assertEquals(VM.TRUE, vm.getStack().pop());
assertEquals(VM.FALSE, vm.getStack().pop());
assertEquals(VM.TRUE, vm.getStack().pop());
assertEquals(VM.FALSE, vm.getStack().pop());
assertEquals(VM.FALSE, vm.getStack().pop());
assertEquals(VM.FALSE, vm.getStack().pop());
assertEquals(VM.TRUE, vm.getStack().pop());
assertEquals(VM.FALSE, vm.getStack().pop());
assertEquals(VM.TRUE, vm.getStack().pop());
assertEquals(0, vm.getStack().size());
}
}