vm: add tests

This commit is contained in:
Vsevolod Brekelov 2019-12-19 15:22:04 +03:00
parent b68e9591aa
commit 1458116567

View file

@ -39,6 +39,17 @@ var binaryExprTestCases = []testCase{
`,
big.NewInt(1),
},
{
"simple mod",
`
package testcase
func Main() int {
x := 3 % 2
return x
}
`,
big.NewInt(1),
},
{
"simple mul",
`
@ -186,6 +197,66 @@ var binaryExprTestCases = []testCase{
`,
big.NewInt(1),
},
{
"simple add and assign",
`
package testcase
func Main() int {
x := 2
x += 1
return x
}
`,
big.NewInt(3),
},
{
"simple sub and assign",
`
package testcase
func Main() int {
x := 2
x -= 1
return x
}
`,
big.NewInt(1),
},
{
"simple mul and assign",
`
package testcase
func Main() int {
x := 2
x *= 2
return x
}
`,
big.NewInt(4),
},
{
"simple div and assign",
`
package testcase
func Main() int {
x := 2
x /= 2
return x
}
`,
big.NewInt(1),
},
{
"simple mod and assign",
`
package testcase
func Main() int {
x := 5
x %= 2
return x
}
`,
big.NewInt(1),
},
}
func TestBinaryExprs(t *testing.T) {