Arithmetic
This commit is contained in:
@@ -33,7 +33,7 @@ func runVmTests(t *testing.T, tests []vmTestCase) {
|
||||
t.Fatalf("vm error: %s", err)
|
||||
}
|
||||
|
||||
stackElem := vm.StackTop()
|
||||
stackElem := vm.LastPoppedStackElem()
|
||||
|
||||
testExpectedObject(t, tt.expected, stackElem)
|
||||
}
|
||||
@@ -75,6 +75,14 @@ func TestIntegerArithmetic(t *testing.T) {
|
||||
{"1", 1},
|
||||
{"2", 2},
|
||||
{"1 + 2", 3},
|
||||
{"1 * 2", 2},
|
||||
{"4 / 2", 2},
|
||||
{"50 / 2 * 2 + 10 - 5", 55},
|
||||
{"5 + 5 + 5 + 5 - 10", 10},
|
||||
{"2 * 2 * 2 * 2 * 2", 32},
|
||||
{"5 * 2 + 10", 20},
|
||||
{"5 + 2 * 10", 25},
|
||||
{"5 * (2 + 10)", 60},
|
||||
}
|
||||
|
||||
runVmTests(t, tests)
|
||||
|
||||
Reference in New Issue
Block a user