From 3926456d86ef0df37dcac9643216ab4652dc3e23 Mon Sep 17 00:00:00 2001 From: Evgenii Stratonikov Date: Tue, 19 May 2020 18:10:17 +0300 Subject: [PATCH] compiler: add test for iterating over map with range --- pkg/compiler/for_test.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/pkg/compiler/for_test.go b/pkg/compiler/for_test.go index 31515951f..71160a41f 100644 --- a/pkg/compiler/for_test.go +++ b/pkg/compiler/for_test.go @@ -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