neo-go/pkg/vm/tests/contant_test.go
Anthony De Meulemeester 4bd5b2812e
Optimisations and API changes for smart contracts (#67)
* support VM to pass method and arguments to a script.

* added support for type assertions in smartcontracts.

* added native vm support for print.

* moved VM API packages to vm -> API

* reverted the native Print opcode in favor of runtime.Log

* added support for registering custom interop hooks in the VM.

* Updated README

* Updated compiler with @OPTIMIZE tags

* Moved more tests to VM package.

* optimized and refactored compiler and vm API

* updated README with new smartcontract apis

* bumped version
2018-04-10 11:45:31 +02:00

63 lines
795 B
Go

package vm_test
import (
"math/big"
"testing"
)
func TestBasicConstant(t *testing.T) {
src := `
package foo
const x = 10
func Main() int {
return x + 2
}
`
eval(t, src, big.NewInt(12))
}
func TestShortHandMultiConst(t *testing.T) {
src := `
package foo
const (
z = 3
y = 2
x = 1
)
// should load al 3 constants in the Main.
func Main() int {
return x + z + y
}
`
eval(t, src, big.NewInt(6))
}
func TestGlobalsWithFunctionParams(t *testing.T) {
src := `
package foobar
const (
// complex he o_O
bar = "FOO"
foo = "BAR"
)
func something(x int) string {
if x > 10 {
return bar
}
return foo
}
func Main() string {
trigger := 100
x := something(trigger)
return x
}
`
eval(t, src, []byte("FOO"))
}