(t *testing.T, testfile string)
| 230 | } |
| 231 | |
| 232 | func testValueForExpr(t *testing.T, testfile string) { |
| 233 | if runtime.GOOS == "android" { |
| 234 | t.Skipf("no testdata dir on %s", runtime.GOOS) |
| 235 | } |
| 236 | |
| 237 | conf := loader.Config{ParserMode: parser.ParseComments} |
| 238 | f, err := conf.ParseFile(testfile, nil) |
| 239 | if err != nil { |
| 240 | t.Error(err) |
| 241 | return |
| 242 | } |
| 243 | conf.CreateFromFiles("main", f) |
| 244 | |
| 245 | iprog, err := conf.Load() |
| 246 | if err != nil { |
| 247 | t.Error(err) |
| 248 | return |
| 249 | } |
| 250 | |
| 251 | mainInfo := iprog.Created[0] |
| 252 | |
| 253 | prog := ssautil.CreateProgram(iprog, 0) |
| 254 | mainPkg := prog.Package(mainInfo.Pkg) |
| 255 | mainPkg.SetDebugMode(true) |
| 256 | mainPkg.Build() |
| 257 | |
| 258 | if false { |
| 259 | // debugging |
| 260 | for _, mem := range mainPkg.Members { |
| 261 | if fn, ok := mem.(*types.Function); ok { |
| 262 | fn.WriteTo(os.Stderr) |
| 263 | } |
| 264 | } |
| 265 | } |
| 266 | |
| 267 | var parenExprs []*ParenExpr |
| 268 | Inspect(f, func(n Node) bool { |
| 269 | if n != nil { |
| 270 | if e, ok := n.(*ParenExpr); ok { |
| 271 | parenExprs = append(parenExprs, e) |
| 272 | } |
| 273 | } |
| 274 | return true |
| 275 | }) |
| 276 | |
| 277 | notes, err := expect.ExtractGo(prog.Fset, f) |
| 278 | if err != nil { |
| 279 | t.Fatal(err) |
| 280 | } |
| 281 | for _, n := range notes { |
| 282 | want := n.Name |
| 283 | if want == "nil" { |
| 284 | want = "<nil>" |
| 285 | } |
| 286 | position := n.Pos |
| 287 | var e Expr |
| 288 | for _, paren := range parenExprs { |
| 289 | if paren.Pos() > n.Pos { |
no test coverage detected