neo-go/pkg/compiler/limit_test.go
Roman Khimov 1b83dc2476 *: improve for loop syntax
Mostly it's about Go 1.22+ syntax with ranging over integers, but it also
prefers ranging over slices where possible (it makes code a little better to
read).

Notice that we have a number of dangerous loops where slices are mutated
during loop execution, many of these can't be converted since we need proper
length evalutation at every iteration.

Signed-off-by: Roman Khimov <roman@nspcc.ru>
2024-08-30 21:45:18 +03:00

26 lines
542 B
Go

package compiler_test
import (
"bytes"
"fmt"
"math/big"
"testing"
)
// Test for #605, #623.
// Codegen should emit integers in proper format.
func TestManyVariables(t *testing.T) {
// any number with MSB=1 is suitable
// 155 was in the contract where this bug was first found.
const count = 155
buf := bytes.NewBufferString("package main\n")
for i := range count {
buf.WriteString(fmt.Sprintf("var a%d = %d\n", i, i))
}
buf.WriteString("func Main() int {\nreturn 7\n}\n")
src := buf.String()
eval(t, src, big.NewInt(7))
}