fix unary compilation and add tests
This commit is contained in:
parent
f53ab30dbe
commit
4a0c315ccb
2 changed files with 81 additions and 7 deletions
|
|
@ -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,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue