mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-23 03:38:35 +00:00
e21015233b
Before introducing slots it was hard to change global variables preserving changes across multiple function calls. This commit implements such possibility. Closes #638.
21 lines
292 B
Go
21 lines
292 B
Go
package compiler_test
|
|
|
|
import (
|
|
"math/big"
|
|
"testing"
|
|
)
|
|
|
|
func TestChangeGlobal(t *testing.T) {
|
|
src := `package foo
|
|
var a int
|
|
func Main() int {
|
|
setLocal()
|
|
set42()
|
|
setLocal()
|
|
return a
|
|
}
|
|
func set42() { a = 42 }
|
|
func setLocal() { a := 10; _ = a }`
|
|
|
|
eval(t, src, big.NewInt(42))
|
|
}
|