Debian Codegraph @

go/analysis/passes/inline/testdata/src/issue76190.txtar

raw
1 This test checks that calls are not inlined when the call appears in a specific
2 test of the function. (Even deprecated functions deserve tests.)
3
4 Variants:
5 - functions (TestF) vs methods (TestT_F)
6 - optional comment suffixes (TestSYMBOL_comment)
7 - in-package test vs external test
8 - test of same or different package from symbol
9
10 -- go.mod --
11 module example.com
12
13 -- a/a.go --
14 package a
15
16 //go:fix inline
17 func F() { print("F") } // want F:"goFixInline a.F"
18 //go:fix inline
19 func G() { print("G") } // want G:"goFixInline a.G"
20
21 type T int
22 //go:fix inline
23 func (T) F() { print("T.F") } // want F:`goFixInline \(a.T\).F`
24 //go:fix inline
25 func (T) G() { print("T.G") } // want G:`goFixInline \(a.T\).G`
26
27 -- a/a_test.go --
28 package a
29
30 import "testing"
31
32 func TestF(t *testing.T) {
33 F() // not inlined
34 G() // want "Call of a.G should be inlined"
35 }
36
37 func TestG_comment(t *testing.T) {
38 F() // want "Call of a.F should be inlined"
39 G() // not inlined
40 }
41
42 func TestT_F(t *testing.T) {
43 T(0).F() // not inlined
44 T(0).G() // want `Call of \(a.T\).G should be inlined`
45 }
46
47 func TestT_G(t *testing.T) {
48 T(0).F() // want `Call of \(a.T\).F should be inlined`
49 T(0).G() // not inlined
50 }
51
52 -- a/a_test.go.golden --
53 package a
54
55 import "testing"
56
57 func TestF(t *testing.T) {
58 F() // not inlined
59 print("G") // want "Call of a.G should be inlined"
60 }
61
62 func TestG_comment(t *testing.T) {
63 print("F") // want "Call of a.F should be inlined"
64 G() // not inlined
65 }
66
67 func TestT_F(t *testing.T) {
68 T(0).F() // not inlined
69 print("T.G") // want `Call of \(a.T\).G should be inlined`
70 }
71
72 func TestT_G(t *testing.T) {
73 print("T.F") // want `Call of \(a.T\).F should be inlined`
74 T(0).G() // not inlined
75 }
76
77 -- a/a_x_test.go --
78 package a_test
79
80 import (
81 "example.com/a"
82 "testing"
83 )
84
85 func TestF(t *testing.T) {
86 a.F() // not inlined
87 a.G() // want "Call of a.G should be inlined"
88 }
89
90 func TestG_comment(t *testing.T) {
91 a.F() // want "Call of a.F should be inlined"
92 a.G() // not inlined
93 }
94
95 func TestT_F(t *testing.T) {
96 a.T(0).F() // not inlined
97 a.T(0).G() // want `Call of \(a.T\).G should be inlined`
98 }
99
100 func TestT_G(t *testing.T) {
101 a.T(0).F() // want `Call of \(a.T\).F should be inlined`
102 a.T(0).G() // not inlined
103 }
104
105 -- a/a_x_test.go.golden --
106 package a_test
107
108 import (
109 "example.com/a"
110 "testing"
111 )
112
113 func TestF(t *testing.T) {
114 a.F() // not inlined
115 print("G") // want "Call of a.G should be inlined"
116 }
117
118 func TestG_comment(t *testing.T) {
119 print("F") // want "Call of a.F should be inlined"
120 a.G() // not inlined
121 }
122
123 func TestT_F(t *testing.T) {
124 a.T(0).F() // not inlined
125 print("T.G") // want `Call of \(a.T\).G should be inlined`
126 }
127
128 func TestT_G(t *testing.T) {
129 print("T.F") // want `Call of \(a.T\).F should be inlined`
130 a.T(0).G() // not inlined
131 }
132
133 -- b/b_test.go --
134 package b_test
135
136 import (
137 "example.com/a"
138 "testing"
139 )
140
141 func TestF(t *testing.T) {
142 a.F() // want "Call of a.F should be inlined"
143 }
144
145 -- b/b_test.go.golden --
146 package b_test
147
148 import (
149 "testing"
150 )
151
152 func TestF(t *testing.T) {
153 print("F") // want "Call of a.F should be inlined"
154 }