From 06916c3e7796c3ad351fc3f1165f3fdd41b4eae0 Mon Sep 17 00:00:00 2001 From: philip Date: Wed, 13 Jan 2016 23:39:39 +0000 Subject: [PATCH 1/3] line numbers in listings - issue #40 --- lib/debug.go | 2 +- .../example-session-list-2.txt | 52 +++++------ .../example-session-list.txt | 90 +++++++++---------- testdata/single-file-tests/select-session.txt | 54 +++++------ 4 files changed, 99 insertions(+), 99 deletions(-) diff --git a/lib/debug.go b/lib/debug.go index 9183f28..9008eef 100644 --- a/lib/debug.go +++ b/lib/debug.go @@ -397,7 +397,7 @@ func printContext(lines []string, line, contextCount int) { } if i >= 0 && i < len(lines) { line := strings.TrimRightFunc(prefix+lines[i], unicode.IsSpace) - fmt.Println(line) + fmt.Printf("%d: %s\n", i, line) } } fmt.Println() diff --git a/testdata/single-file-tests/example-session-list-2.txt b/testdata/single-file-tests/example-session-list-2.txt index af07c8c..46e0384 100644 --- a/testdata/single-file-tests/example-session-list-2.txt +++ b/testdata/single-file-tests/example-session-list-2.txt @@ -3,29 +3,29 @@ -> x = mul(x, x) (godebug) list - - func main() { - x := mul(1, 2) - _ = "breakpoint" ---> x = mul(x, x) - if x == 4 { - fmt.Println("It works! x == 4.") - } else if n := 2; n == 3 { - fmt.Println("Math is broken. Ah!") +3: +4: func main() { +5: x := mul(1, 2) +6: _ = "breakpoint" +7: --> x = mul(x, x) +8: if x == 4 { +9: fmt.Println("It works! x == 4.") +10: } else if n := 2; n == 3 { +11: fmt.Println("Math is broken. Ah!") (godebug) step -> var x int (godebug) list - return n + m - } - - func mul(n, m int) int { ---> var x int - for i := 0; i < m; i++ { - x = add(x, m) - } - return x +24: return n + m +25: } +26: +27: func mul(n, m int) int { +28: --> var x int +29: for i := 0; i < m; i++ { +30: x = add(x, m) +31: } +32: return x (godebug) n -> for i := 0; i < m; i++ { @@ -33,14 +33,14 @@ -> x = add(x, m) (godebug) l - - func mul(n, m int) int { - var x int - for i := 0; i < m; i++ { ---> x = add(x, m) - } - return x - } +26: +27: func mul(n, m int) int { +28: var x int +29: for i := 0; i < m; i++ { +30: --> x = add(x, m) +31: } +32: return x +33: } (godebug) continue What's going on? x == 16 diff --git a/testdata/single-file-tests/example-session-list.txt b/testdata/single-file-tests/example-session-list.txt index 15dfd88..bfe07f9 100644 --- a/testdata/single-file-tests/example-session-list.txt +++ b/testdata/single-file-tests/example-session-list.txt @@ -3,71 +3,71 @@ -> x = mul(x, x) (godebug) list - - func main() { - x := mul(1, 2) - _ = "breakpoint" ---> x = mul(x, x) - if x == 4 { - fmt.Println("It works! x == 4.") - } else if n := 2; n == 3 { - fmt.Println("Math is broken. Ah!") +3: +4: func main() { +5: x := mul(1, 2) +6: _ = "breakpoint" +7: --> x = mul(x, x) +8: if x == 4 { +9: fmt.Println("It works! x == 4.") +10: } else if n := 2; n == 3 { +11: fmt.Println("Math is broken. Ah!") (godebug) n -> if x == 4 { (godebug) list - func main() { - x := mul(1, 2) - _ = "breakpoint" - x = mul(x, x) ---> if x == 4 { - fmt.Println("It works! x == 4.") - } else if n := 2; n == 3 { - fmt.Println("Math is broken. Ah!") - } else { +4: func main() { +5: x := mul(1, 2) +6: _ = "breakpoint" +7: x = mul(x, x) +8: --> if x == 4 { +9: fmt.Println("It works! x == 4.") +10: } else if n := 2; n == 3 { +11: fmt.Println("Math is broken. Ah!") +12: } else { (godebug) n -> } else if n := 2; n == 3 { (godebug) l - _ = "breakpoint" - x = mul(x, x) - if x == 4 { - fmt.Println("It works! x == 4.") ---> } else if n := 2; n == 3 { - fmt.Println("Math is broken. Ah!") - } else { - fmt.Println("What's going on? x ==", x) - } +6: _ = "breakpoint" +7: x = mul(x, x) +8: if x == 4 { +9: fmt.Println("It works! x == 4.") +10: --> } else if n := 2; n == 3 { +11: fmt.Println("Math is broken. Ah!") +12: } else { +13: fmt.Println("What's going on? x ==", x) +14: } (godebug) n -> } else { (godebug) l - if x == 4 { - fmt.Println("It works! x == 4.") - } else if n := 2; n == 3 { - fmt.Println("Math is broken. Ah!") ---> } else { - fmt.Println("What's going on? x ==", x) - } - } - +8: if x == 4 { +9: fmt.Println("It works! x == 4.") +10: } else if n := 2; n == 3 { +11: fmt.Println("Math is broken. Ah!") +12: --> } else { +13: fmt.Println("What's going on? x ==", x) +14: } +15: } +16: (godebug) n -> fmt.Println("What's going on? x ==", x) (godebug) l - fmt.Println("It works! x == 4.") - } else if n := 2; n == 3 { - fmt.Println("Math is broken. Ah!") - } else { ---> fmt.Println("What's going on? x ==", x) - } - } - - func add(n, m int) int { +9: fmt.Println("It works! x == 4.") +10: } else if n := 2; n == 3 { +11: fmt.Println("Math is broken. Ah!") +12: } else { +13: --> fmt.Println("What's going on? x ==", x) +14: } +15: } +16: +17: func add(n, m int) int { (godebug) next What's going on? x == 16 diff --git a/testdata/single-file-tests/select-session.txt b/testdata/single-file-tests/select-session.txt index 5e6c27a..af8ca70 100644 --- a/testdata/single-file-tests/select-session.txt +++ b/testdata/single-file-tests/select-session.txt @@ -3,15 +3,15 @@ -> go func() { (godebug) list - - // ------------------- - // Check simple cases. - ---> go func() { - select {} - }() - - select { +24: +25: // ------------------- +26: // Check simple cases. +27: +28: --> go func() { +29: select {} +30: }() +31: +32: select { (godebug) step -> select { @@ -133,15 +133,15 @@ hello -> case r1 = <-foo(): (godebug) list - _, _ = r2, ok - - case <-foo(): - case _ = <-foo(): ---> case r1 = <-foo(): - case r2 := <-foo(): - _ = r2 - - case _, _ = <-foo(): +96: _, _ = r2, ok +97: +98: case <-foo(): +99: case _ = <-foo(): +100: --> case r1 = <-foo(): +101: case r2 := <-foo(): +102: _ = r2 +103: +104: case _, _ = <-foo(): (godebug) n -> case r2 := <-foo(): @@ -164,15 +164,15 @@ hello -> case r2, ok := <-c[9]: // This is the case that will proceed. (godebug) list - case _, ok = <-c[6]: - case _, ok1 := <-c[7]: - _ = ok1 - case r1, ok = <-c[8]: ---> case r2, ok := <-c[9]: // This is the case that will proceed. - _, _ = r2, ok - - case <-foo(): - case _ = <-foo(): +91: case _, ok = <-c[6]: +92: case _, ok1 := <-c[7]: +93: _ = ok1 +94: case r1, ok = <-c[8]: +95: --> case r2, ok := <-c[9]: // This is the case that will proceed. +96: _, _ = r2, ok +97: +98: case <-foo(): +99: case _ = <-foo(): (godebug) n -> _, _ = r2, ok From e789bdac6c0cd25eac79c623da2035b4988a8a2c Mon Sep 17 00:00:00 2001 From: philip Date: Mon, 11 Apr 2016 23:15:15 +0100 Subject: [PATCH 2/3] Added some whitespace somewhere innocuous to see if it'll persuade the tests to re-run in github. --- testdata/test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testdata/test.yaml b/testdata/test.yaml index 8817c4d..ab2b650 100644 --- a/testdata/test.yaml +++ b/testdata/test.yaml @@ -204,7 +204,7 @@ creates: - $TMP/src/testpkg2/test_test.go transcript: | - godebug test: Ignoring breakpoint at foo/subfoo/subfoo.go:8 because package "subfoo" has not been flagged for instrumentation. See 'godebug help test'. //slashes + godebug test: Ignoring breakpoint at foo/subfoo/subfoo.go:8 because package "subfoo" has not been flagged for instrumentation. See 'godebug help test'. // slashes -> _ = "breakpoint" (godebug) n From 1c19209afe67dc41581e7d7d871ce73c764ce082 Mon Sep 17 00:00:00 2001 From: philip Date: Tue, 12 Apr 2016 22:47:59 +0100 Subject: [PATCH 3/3] removing the added whitespace --- testdata/test.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testdata/test.yaml b/testdata/test.yaml index ab2b650..8817c4d 100644 --- a/testdata/test.yaml +++ b/testdata/test.yaml @@ -204,7 +204,7 @@ creates: - $TMP/src/testpkg2/test_test.go transcript: | - godebug test: Ignoring breakpoint at foo/subfoo/subfoo.go:8 because package "subfoo" has not been flagged for instrumentation. See 'godebug help test'. // slashes + godebug test: Ignoring breakpoint at foo/subfoo/subfoo.go:8 because package "subfoo" has not been flagged for instrumentation. See 'godebug help test'. //slashes -> _ = "breakpoint" (godebug) n