mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-12-23 23:25:22 +00:00
6b21ad9922
Everywhere including examples, external interop APIs, bindings generators code and in other valuable places. A couple of `interface{}` usages are intentionally left in the CHANGELOG.md, documentation and tests.
55 lines
640 B
Go
55 lines
640 B
Go
package compiler_test
|
|
|
|
import (
|
|
"math/big"
|
|
"testing"
|
|
)
|
|
|
|
var nilTestCases = []testCase{
|
|
{
|
|
"nil check positive right",
|
|
`
|
|
package foo
|
|
func Main() int {
|
|
var t any
|
|
if t == nil {
|
|
return 1
|
|
}
|
|
return 2
|
|
}
|
|
`,
|
|
big.NewInt(1),
|
|
},
|
|
{
|
|
"nil check negative right",
|
|
`
|
|
package foo
|
|
func Main() int {
|
|
t := []byte{}
|
|
if t == nil {
|
|
return 1
|
|
}
|
|
return 2
|
|
}
|
|
`,
|
|
big.NewInt(2),
|
|
},
|
|
{
|
|
"nil check positive left",
|
|
`
|
|
package foo
|
|
func Main() int {
|
|
var t any
|
|
if nil == t {
|
|
return 1
|
|
}
|
|
return 2
|
|
}
|
|
`,
|
|
big.NewInt(1),
|
|
},
|
|
}
|
|
|
|
func TestNil(t *testing.T) {
|
|
runTestCases(t, nilTestCases)
|
|
}
|