neoneo-go/pkg/compiler/type_test.go

40 lines
595 B
Go
Raw Normal View History

package compiler_test
2018-04-22 18:11:37 +00:00
import (
"math/big"
"testing"
)
2018-04-22 18:11:37 +00:00
func TestCustomType(t *testing.T) {
src := `
package foo
type bar int
type specialString string
func Main() specialString {
var x bar
var str specialString
x = 10
str = "some short string"
if x == 10 {
return str
}
return "none"
}
`
eval(t, src, []byte("some short string"))
}
func TestCustomTypeMethods(t *testing.T) {
src := `package foo
type bar int
func (b bar) add(a bar) bar { return a + b }
func Main() bar {
var b bar
b = 10
return b.add(32)
}`
eval(t, src, big.NewInt(42))
}