compiler: add test for iterating over map with range
This commit is contained in:
parent
d0735257ce
commit
3926456d86
1 changed files with 18 additions and 0 deletions
|
@ -719,6 +719,24 @@ func TestForLoopRangeValue(t *testing.T) {
|
|||
eval(t, src, big.NewInt(14))
|
||||
}
|
||||
|
||||
func TestForLoopRangeMap(t *testing.T) {
|
||||
src := `package foo
|
||||
func Main() int {
|
||||
m := map[int]int{
|
||||
1: 13,
|
||||
11: 17,
|
||||
}
|
||||
var sum int
|
||||
for i, v := range m {
|
||||
sum += i
|
||||
sum += v
|
||||
}
|
||||
return sum
|
||||
}`
|
||||
|
||||
eval(t, src, big.NewInt(42))
|
||||
}
|
||||
|
||||
func TestForLoopComplexConditions(t *testing.T) {
|
||||
src := `
|
||||
package foo
|
||||
|
|
Loading…
Reference in a new issue