fix unary compilation and add tests

This commit is contained in:
Neemek 2025-09-16 19:59:58 +02:00
parent f53ab30dbe
commit 4a0c315ccb
2 changed files with 81 additions and 7 deletions

View file

@ -534,6 +534,65 @@ func GetCompileTestData() map[string]CompileTestData {
},
},
},
"unary/negate": {
program: &Program{
[]string{},
&BlockNode{
[]Node{
&AssignNode{
name: "a",
value: &UnaryNode{
UnaryNegate,
&NumberNode{
1,
0, 0,
},
0, 0,
},
declare: true,
},
},
0, 0,
},
"",
},
expectedStack: []Value{
&VariableValue{
name: "a",
value: &NumberValue{-1},
scope: 0,
},
},
},
"unary/not": {
program: &Program{
[]string{},
&BlockNode{
[]Node{
&AssignNode{
name: "a",
value: &UnaryNode{
UnaryNot,
&BooleanNode{
value: true,
},
0, 0,
},
declare: true,
},
},
0, 0,
},
"",
},
expectedStack: []Value{
&VariableValue{
name: "a",
value: &BoolValue{false},
scope: 0,
},
},
},
}
}