github.com/v2fly/tools@v0.100.0/go/pointer/testdata/a_test.go (about) 1 // +build ignore 2 3 package a 4 5 // This test exercises the synthesis of testmain packages for tests. 6 // The test framework doesn't directly let us perform negative 7 // assertions (i.e. that TestingQuux isn't called, or that its 8 // parameter's PTS is empty) so this test is rather roundabout. 9 10 import "testing" 11 12 func log(f func(*testing.T)) { 13 // The PTS of f is the set of called tests. TestingQuux is not present. 14 print(f) // @pointsto main.Test | main.TestFoo 15 } 16 17 func Test(t *testing.T) { 18 // Don't assert @pointsto(t) since its label contains a fragile line number. 19 log(Test) 20 } 21 22 func TestFoo(t *testing.T) { 23 // Don't assert @pointsto(t) since its label contains a fragile line number. 24 log(TestFoo) 25 } 26 27 func TestingQuux(t *testing.T) { 28 // We can't assert @pointsto(t) since this is dead code. 29 log(TestingQuux) 30 } 31 32 func BenchmarkFoo(b *testing.B) { 33 } 34 35 func ExampleBar() { 36 } 37 38 // Excludes TestingQuux. 39 // @calls testing.tRunner -> main.Test 40 // @calls testing.tRunner -> main.TestFoo 41 // @calls testing.runExample -> main.ExampleBar 42 // @calls (*testing.B).runN -> main.BenchmarkFoo