2014-06-29 16:52:21 +00:00
|
|
|
package line
|
|
|
|
|
|
|
|
import (
|
2014-09-12 20:19:36 +00:00
|
|
|
"os"
|
|
|
|
"os/exec"
|
2014-06-29 16:52:21 +00:00
|
|
|
"path/filepath"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
var testfile string
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
testfile, _ = filepath.Abs("../../_fixtures/testnextprog")
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestNextLocAfterPC(t *testing.T) {
|
2014-09-12 20:19:36 +00:00
|
|
|
p, err := filepath.Abs("../../_fixtures/testnextprog")
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal(err)
|
|
|
|
}
|
|
|
|
|
|
|
|
err = exec.Command("go", "build", "-gcflags=-N -l", "-o", p, p+".go").Run()
|
|
|
|
if err != nil {
|
|
|
|
t.Fatal("Could not compile test file", p, err)
|
|
|
|
}
|
|
|
|
defer os.Remove(p)
|
|
|
|
|
2014-06-29 16:52:21 +00:00
|
|
|
var (
|
2014-09-17 03:37:48 +00:00
|
|
|
data = grabDebugLineSection(p, t)
|
|
|
|
dbl = Parse(data)
|
2014-06-29 16:52:21 +00:00
|
|
|
)
|
|
|
|
|
2014-09-17 03:37:48 +00:00
|
|
|
loc := dbl.NextLocation(testfile+".go", 20)
|
2014-06-29 16:52:21 +00:00
|
|
|
|
2014-07-11 19:52:55 +00:00
|
|
|
if loc.File != testfile+".go" {
|
|
|
|
t.Fatal("File not returned correctly", loc.File)
|
2014-06-29 16:52:21 +00:00
|
|
|
}
|
|
|
|
|
2014-07-11 19:52:55 +00:00
|
|
|
if loc.Line != 22 {
|
|
|
|
t.Fatal("Line not returned correctly", loc.Line)
|
2014-06-29 16:52:21 +00:00
|
|
|
}
|
|
|
|
}
|