Debian Codegraph @

cmd/stringer/testdata/prime2.go

raw symbols SCIP
1 // Copyright 2021 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
4
5 // This is a version of ../prime.go with type params
6
7 // Enough gaps to trigger a map implementation of the method.
8 // Also includes a duplicate to test that it doesn't cause problems
9
10 package main
11
12 import "fmt"
13
14 // For now, a lone type parameter is not permitted as RHS in a type declaration (issue #45639).
15 // type Likeint[T interface{ ~int | ~uint8 }] T
16 type Likeint int
17
18 // type Prime2 Likeint[int]
19 type Prime2 Likeint
20
21 const (
22 p2 Prime2 = 2
23 p3 Prime2 = 3
24 p5 Prime2 = 5
25 p7 Prime2 = 7
26 p77 Prime2 = 7 // Duplicate; note that p77 doesn't appear below.
27 p11 Prime2 = 11
28 p13 Prime2 = 13
29 p17 Prime2 = 17
30 p19 Prime2 = 19
31 p23 Prime2 = 23
32 p29 Prime2 = 29
33 p37 Prime2 = 31
34 p41 Prime2 = 41
35 p43 Prime2 = 43
36 )
37
38 func main() {
39 ck(0, "Prime2(0)")
40 ck(1, "Prime2(1)")
41 ck(p2, "p2")
42 ck(p3, "p3")
43 ck(4, "Prime2(4)")
44 ck(p5, "p5")
45 ck(p7, "p7")
46 ck(p77, "p7")
47 ck(p11, "p11")
48 ck(p13, "p13")
49 ck(p17, "p17")
50 ck(p19, "p19")
51 ck(p23, "p23")
52 ck(p29, "p29")
53 ck(p37, "p37")
54 ck(p41, "p41")
55 ck(p43, "p43")
56 ck(44, "Prime2(44)")
57 }
58
59 func ck(prime Prime2, str string) {
60 if fmt.Sprint(prime) != str {
61 panic("prime2.go: " + str)
62 }
63 }