| // Copyright 2018 The Go Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style |
| // license that can be found in the LICENSE file. |
| // Ensure that range loops over maps with delete statements |
| // have the requisite side-effects. |
| if want := 0; l != want { |
| fmt.Printf("len after map clear = %d want %d\n", l, want) |
| m[0] = 0 // To have non empty map and avoid internal map code fast paths. |
| if want := 1; n != want { |
| fmt.Printf("number of keys found = %d want %d\n", n, want) |
| if want := 42; k != want { |
| fmt.Printf("var after range with side-effect = %d want %d\n", k, want) |
| func checksideeffects() { |
| if want := 2; x != want { |
| fmt.Printf("var after range with side-effect = %d want %d\n", x, want) |
| if want := 2; n != want { |
| fmt.Printf("counter for range with side-effect = %d want %d\n", n, want) |