22 lines
292 B
Go
22 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))
|
||
|
}
|