mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-12-23 03:41:34 +00:00
1b83dc2476
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>
26 lines
542 B
Go
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))
|
|
}
|