Skip to content

Commit 5a4e098

Browse files
committed
test/codegen: port maps test to codegen
And delete them from asm_test. Change-Id: I3cf0934706a640136cb0f646509174f8c1bf3363 Reviewed-on: https://go-review.googlesource.com/101395 Run-TryBot: Alberto Donizetti <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Giovanni Bajo <[email protected]>
1 parent 15b63ee commit 5a4e098

File tree

2 files changed

+38
-35
lines changed

2 files changed

+38
-35
lines changed

src/cmd/compile/internal/gc/asm_test.go

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -279,41 +279,6 @@ var linuxAMD64Tests = []*asmTest{
279279
`,
280280
pos: []string{"\tSHLQ\t\\$5,", "\tLEAQ\t\\(.*\\)\\(.*\\*2\\),"},
281281
},
282-
{
283-
fn: `
284-
func f33(m map[int]int) int {
285-
return m[5]
286-
}
287-
`,
288-
pos: []string{"\tMOVQ\t[$]5,"},
289-
},
290-
// Direct use of constants in fast map access calls. Issue 19015.
291-
{
292-
fn: `
293-
func f34(m map[int]int) bool {
294-
_, ok := m[5]
295-
return ok
296-
}
297-
`,
298-
pos: []string{"\tMOVQ\t[$]5,"},
299-
},
300-
{
301-
fn: `
302-
func f35(m map[string]int) int {
303-
return m["abc"]
304-
}
305-
`,
306-
pos: []string{"\"abc\""},
307-
},
308-
{
309-
fn: `
310-
func f36(m map[string]int) bool {
311-
_, ok := m["abc"]
312-
return ok
313-
}
314-
`,
315-
pos: []string{"\"abc\""},
316-
},
317282
// Bit test ops on amd64, issue 18943.
318283
{
319284
fn: `

test/codegen/maps.go

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
// asmcheck
2+
3+
// Copyright 2018 The Go Authors. All rights reserved.
4+
// Use of this source code is governed by a BSD-style
5+
// license that can be found in the LICENSE file.
6+
7+
package codegen
8+
9+
// This file contains code generation tests related to the handling of
10+
// map types.
11+
12+
// ------------------- //
13+
// Access Const //
14+
// ------------------- //
15+
16+
// Direct use of constants in fast map access calls (Issue #19015).
17+
18+
func AccessInt1(m map[int]int) int {
19+
// amd64:"MOVQ\t[$]5"
20+
return m[5]
21+
}
22+
23+
func AccessInt2(m map[int]int) bool {
24+
// amd64:"MOVQ\t[$]5"
25+
_, ok := m[5]
26+
return ok
27+
}
28+
29+
func AccessString1(m map[string]int) int {
30+
// amd64:`.*"abc"`
31+
return m["abc"]
32+
}
33+
34+
func AccessString2(m map[string]int) bool {
35+
// amd64:`.*"abc"`
36+
_, ok := m["abc"]
37+
return ok
38+
}

0 commit comments

Comments
 (0)