neoneo-go/pkg/compiler/import_test.go

64 lines
1 KiB
Go
Raw Normal View History

package compiler_test
2018-04-22 18:11:37 +00:00
import (
"math/big"
"testing"
)
func TestImportFunction(t *testing.T) {
src := `
package somethingelse
import "github.com/nspcc-dev/neo-go/pkg/compiler/testdata/foo"
2018-04-22 18:11:37 +00:00
func Main() int {
i := foo.NewBar()
return i
}
`
eval(t, src, big.NewInt(10))
}
func TestImportStruct(t *testing.T) {
src := `
package somethingwedontcareabout
import "github.com/nspcc-dev/neo-go/pkg/compiler/testdata/bar"
2018-04-22 18:11:37 +00:00
func Main() int {
b := bar.Bar{
X: 4,
}
return b.Y
}
`
2020-05-20 13:31:10 +00:00
eval(t, src, big.NewInt(0))
2018-04-22 18:11:37 +00:00
}
func TestMultipleDirFileImport(t *testing.T) {
src := `
package hello
import "github.com/nspcc-dev/neo-go/pkg/compiler/testdata/foobar"
func Main() bool {
ok := foobar.OtherBool()
return ok
}
`
eval(t, src, big.NewInt(1))
}
2021-03-04 11:36:15 +00:00
func TestImportNameSameAsOwn(t *testing.T) {
src := `package foo
import "github.com/nspcc-dev/neo-go/pkg/compiler/testdata/foo"
func get3() int { return 3 }
func Main() int {
return get3()
}
func unused() int {
return foo.Bar()
}`
eval(t, src, big.NewInt(3))
}