vm: expand binary expr tests with cases from #294
Make a full set of numeric/string comparisons with `==` and `!=` being evaluated to true and false.
This commit is contained in:
parent
9b421874ae
commit
18d971440b
1 changed files with 73 additions and 3 deletions
|
@ -75,7 +75,7 @@ var binaryExprTestCases = []testCase{
|
|||
big.NewInt(0),
|
||||
},
|
||||
{
|
||||
"compare equal strings",
|
||||
"compare not equal strings with eql",
|
||||
`
|
||||
package testcase
|
||||
func Main() int {
|
||||
|
@ -89,7 +89,49 @@ var binaryExprTestCases = []testCase{
|
|||
big.NewInt(0),
|
||||
},
|
||||
{
|
||||
"compare equal ints",
|
||||
"compare equal strings with eql",
|
||||
`
|
||||
package testcase
|
||||
func Main() int {
|
||||
str := "a string"
|
||||
if str == "a string" {
|
||||
return 1
|
||||
}
|
||||
return 0
|
||||
}
|
||||
`,
|
||||
big.NewInt(1),
|
||||
},
|
||||
{
|
||||
"compare not equal strings with neq",
|
||||
`
|
||||
package testcase
|
||||
func Main() int {
|
||||
str := "a string"
|
||||
if str != "another string" {
|
||||
return 1
|
||||
}
|
||||
return 0
|
||||
}
|
||||
`,
|
||||
big.NewInt(1),
|
||||
},
|
||||
{
|
||||
"compare equal strings with neq",
|
||||
`
|
||||
package testcase
|
||||
func Main() int {
|
||||
str := "a string"
|
||||
if str != "a string" {
|
||||
return 1
|
||||
}
|
||||
return 0
|
||||
}
|
||||
`,
|
||||
big.NewInt(0),
|
||||
},
|
||||
{
|
||||
"compare equal ints with eql",
|
||||
`
|
||||
package testcase
|
||||
func Main() int {
|
||||
|
@ -103,7 +145,7 @@ var binaryExprTestCases = []testCase{
|
|||
big.NewInt(1),
|
||||
},
|
||||
{
|
||||
"compare not equal ints",
|
||||
"compare equal ints with neq",
|
||||
`
|
||||
package testcase
|
||||
func Main() int {
|
||||
|
@ -116,6 +158,34 @@ var binaryExprTestCases = []testCase{
|
|||
`,
|
||||
big.NewInt(0),
|
||||
},
|
||||
{
|
||||
"compare not equal ints with eql",
|
||||
`
|
||||
package testcase
|
||||
func Main() int {
|
||||
x := 11
|
||||
if x == 10 {
|
||||
return 1
|
||||
}
|
||||
return 0
|
||||
}
|
||||
`,
|
||||
big.NewInt(0),
|
||||
},
|
||||
{
|
||||
"compare not equal ints with neq",
|
||||
`
|
||||
package testcase
|
||||
func Main() int {
|
||||
x := 11
|
||||
if x != 10 {
|
||||
return 1
|
||||
}
|
||||
return 0
|
||||
}
|
||||
`,
|
||||
big.NewInt(1),
|
||||
},
|
||||
}
|
||||
|
||||
func TestBinaryExprs(t *testing.T) {
|
||||
|
|
Loading…
Reference in a new issue