...
Run Format

Source file test/fixedbugs/issue5856.go

Documentation: test/fixedbugs

     1  // run
     2  
     3  // Copyright 2013 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 main
     8  
     9  import (
    10  	"fmt"
    11  	"os"
    12  	"runtime"
    13  	"strings"
    14  )
    15  
    16  func main() {
    17  	f()
    18  	panic("deferred function not run")
    19  }
    20  
    21  var x = 1
    22  
    23  func f() {
    24  	if x == 0 {
    25  		return
    26  	}
    27  	defer g()
    28  	panic("panic")
    29  }
    30  
    31  func g() {
    32  	_, file, line, _ := runtime.Caller(3)
    33  	if !strings.HasSuffix(file, "issue5856.go") || line != 28 {
    34  		fmt.Printf("BUG: defer called from %s:%d, want issue5856.go:28\n", file, line)
    35  		os.Exit(1)
    36  	}
    37  	os.Exit(0)
    38  }
    39  

View as plain text