prefix expressions

This commit is contained in:
Chuck Smith
2024-02-07 10:51:09 -05:00
parent dcc869a6e2
commit cff4375649
5 changed files with 84 additions and 0 deletions

View File

@@ -68,6 +68,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)
@@ -151,6 +160,15 @@ func TestBooleanExpressions(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)