2020-01-28 08:59:57 +00:00
|
|
|
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")
|
2024-08-30 18:41:02 +00:00
|
|
|
for i := range count {
|
2020-01-28 08:59:57 +00:00
|
|
|
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))
|
|
|
|
}
|