|
|
@@ -25,6 +25,17 @@ func TestIntegerArithmetic(t *testing.T) {
|
|
|
code.Make(code.OpConstant, 0),
|
|
|
code.Make(code.OpConstant, 1),
|
|
|
code.Make(code.OpAdd),
|
|
|
+ code.Make(code.OpPop),
|
|
|
+ },
|
|
|
+ },
|
|
|
+ {
|
|
|
+ input: "1;2",
|
|
|
+ expectedConstants: []interface{}{1, 2},
|
|
|
+ expectedInstructions: []code.Instructions{
|
|
|
+ code.Make(code.OpConstant, 0),
|
|
|
+ code.Make(code.OpPop),
|
|
|
+ code.Make(code.OpConstant, 1),
|
|
|
+ code.Make(code.OpPop),
|
|
|
},
|
|
|
},
|
|
|
}
|
|
|
@@ -62,6 +73,8 @@ func testConstants(
|
|
|
expected []interface{},
|
|
|
actual []object.Object,
|
|
|
) error {
|
|
|
+ t.Helper()
|
|
|
+
|
|
|
if len(expected) != len(actual) {
|
|
|
return fmt.Errorf("wrong number of constants. got=%d, want=%d", len(actual), len(expected))
|
|
|
}
|