|
|
@@ -80,6 +80,15 @@ func TestIntegerArithmetic(t *testing.T) {
|
|
|
code.Make(code.OpPop),
|
|
|
},
|
|
|
},
|
|
|
+ {
|
|
|
+ input: "-1",
|
|
|
+ expectedConstants: []interface{}{1},
|
|
|
+ expectedInstructions: []code.Instructions{
|
|
|
+ code.Make(code.OpConstant, 0),
|
|
|
+ code.Make(code.OpMinus),
|
|
|
+ code.Make(code.OpPop),
|
|
|
+ },
|
|
|
+ },
|
|
|
}
|
|
|
|
|
|
runCompilerTests(t, tests)
|
|
|
@@ -163,6 +172,15 @@ func TestBooleanExpression(t *testing.T) {
|
|
|
code.Make(code.OpPop),
|
|
|
},
|
|
|
},
|
|
|
+ {
|
|
|
+ input: "!true",
|
|
|
+ expectedConstants: []interface{}{},
|
|
|
+ expectedInstructions: []code.Instructions{
|
|
|
+ code.Make(code.OpTrue),
|
|
|
+ code.Make(code.OpBang),
|
|
|
+ code.Make(code.OpPop),
|
|
|
+ },
|
|
|
+ },
|
|
|
}
|
|
|
|
|
|
runCompilerTests(t, tests)
|