2019-12-23 14:05:34 +00:00
|
|
|
package compiler_test
|
2018-04-02 15:04:42 +00:00
|
|
|
|
2019-08-20 17:37:06 +00:00
|
|
|
import (
|
|
|
|
"math/big"
|
|
|
|
"testing"
|
|
|
|
)
|
2018-04-02 15:04:42 +00:00
|
|
|
|
|
|
|
var numericTestCases = []testCase{
|
|
|
|
{
|
|
|
|
"add",
|
|
|
|
`
|
|
|
|
package foo
|
|
|
|
func Main() int {
|
|
|
|
x := 2
|
|
|
|
y := 4
|
|
|
|
return x + y
|
|
|
|
}
|
|
|
|
`,
|
|
|
|
big.NewInt(6),
|
|
|
|
},
|
2023-10-05 12:57:50 +00:00
|
|
|
{
|
|
|
|
"shift uint64",
|
|
|
|
`package foo
|
|
|
|
func Main() uint64 {
|
|
|
|
return 1 << 63
|
|
|
|
}`,
|
|
|
|
new(big.Int).SetUint64(1 << 63),
|
|
|
|
},
|
2018-04-02 15:04:42 +00:00
|
|
|
}
|
2019-08-20 17:37:06 +00:00
|
|
|
|
|
|
|
func TestNumericExprs(t *testing.T) {
|
2019-10-18 15:36:54 +00:00
|
|
|
runTestCases(t, numericTestCases)
|
2019-08-20 17:37:06 +00:00
|
|
|
}
|