2019-12-23 14:05:34 +00:00
|
|
|
package compiler_test
|
2018-04-22 18:11:37 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"math/big"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestImportFunction(t *testing.T) {
|
|
|
|
src := `
|
|
|
|
package somethingelse
|
|
|
|
|
2019-12-23 14:05:34 +00:00
|
|
|
import "github.com/CityOfZion/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
|
|
|
|
|
2019-12-23 14:05:34 +00:00
|
|
|
import "github.com/CityOfZion/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
|
|
|
|
}
|
|
|
|
`
|
2019-09-12 08:42:27 +00:00
|
|
|
eval(t, src, []byte{})
|
2018-04-22 18:11:37 +00:00
|
|
|
}
|
2018-05-06 06:03:26 +00:00
|
|
|
|
|
|
|
func TestMultipleDirFileImport(t *testing.T) {
|
|
|
|
src := `
|
|
|
|
package hello
|
|
|
|
|
2019-12-23 14:05:34 +00:00
|
|
|
import "github.com/CityOfZion/neo-go/pkg/compiler/testdata/foobar"
|
2018-05-06 06:03:26 +00:00
|
|
|
|
|
|
|
func Main() bool {
|
|
|
|
ok := foobar.OtherBool()
|
|
|
|
return ok
|
|
|
|
}
|
|
|
|
`
|
|
|
|
eval(t, src, big.NewInt(1))
|
|
|
|
}
|