| 1 |
Regression test for #42134, |
| 2 |
"rename fails to update doc comment for local variable of function type" |
| 3 |
|
| 4 |
-- 1.go -- |
| 5 |
package issue42134 |
| 6 |
|
| 7 |
func _() { |
| 8 |
// foo computes things. |
| 9 |
foo := func() {} |
| 10 |
|
| 11 |
foo() //@rename("foo", "bar", fooTobar) |
| 12 |
} |
| 13 |
-- @fooTobar/1.go -- |
| 14 |
@@ -4,2 +4,2 @@ |
| 15 |
- // foo computes things. |
| 16 |
- foo := func() {} |
| 17 |
+ // bar computes things. |
| 18 |
+ bar := func() {} |
| 19 |
@@ -7 +7 @@ |
| 20 |
- foo() //@rename("foo", "bar", fooTobar) |
| 21 |
+ bar() //@rename("foo", "bar", fooTobar) |
| 22 |
-- 2.go -- |
| 23 |
package issue42134 |
| 24 |
|
| 25 |
import "fmt" |
| 26 |
|
| 27 |
func _() { |
| 28 |
// minNumber is a min number. |
| 29 |
// Second line. |
| 30 |
minNumber := min(1, 2) |
| 31 |
fmt.Println(minNumber) //@rename("minNumber", "res", minNumberTores) |
| 32 |
} |
| 33 |
|
| 34 |
func min(a, b int) int { return a + b } |
| 35 |
-- @minNumberTores/2.go -- |
| 36 |
@@ -6 +6 @@ |
| 37 |
- // minNumber is a min number. |
| 38 |
+ // res is a min number. |
| 39 |
@@ -8,2 +8,2 @@ |
| 40 |
- minNumber := min(1, 2) |
| 41 |
- fmt.Println(minNumber) //@rename("minNumber", "res", minNumberTores) |
| 42 |
+ res := min(1, 2) |
| 43 |
+ fmt.Println(res) //@rename("minNumber", "res", minNumberTores) |
| 44 |
-- 3.go -- |
| 45 |
package issue42134 |
| 46 |
|
| 47 |
func _() { |
| 48 |
/* |
| 49 |
tests contains test cases |
| 50 |
*/ |
| 51 |
tests := []struct { //@rename("tests", "testCases", testsTotestCases) |
| 52 |
in, out string |
| 53 |
}{} |
| 54 |
_ = tests |
| 55 |
} |
| 56 |
-- @testsTotestCases/3.go -- |
| 57 |
@@ -5 +5 @@ |
| 58 |
- tests contains test cases |
| 59 |
+ testCases contains test cases |
| 60 |
@@ -7 +7 @@ |
| 61 |
- tests := []struct { //@rename("tests", "testCases", testsTotestCases) |
| 62 |
+ testCases := []struct { //@rename("tests", "testCases", testsTotestCases) |
| 63 |
@@ -10 +10 @@ |
| 64 |
- _ = tests |
| 65 |
+ _ = testCases |
| 66 |
-- 4.go -- |
| 67 |
package issue42134 |
| 68 |
|
| 69 |
func _() { |
| 70 |
// a is equal to 5. Comment must stay the same |
| 71 |
|
| 72 |
a := 5 |
| 73 |
_ = a //@rename("a", "b", aTob) |
| 74 |
} |
| 75 |
-- @aTob/4.go -- |
| 76 |
@@ -6,2 +6,2 @@ |
| 77 |
- a := 5 |
| 78 |
- _ = a //@rename("a", "b", aTob) |
| 79 |
+ b := 5 |
| 80 |
+ _ = b //@rename("a", "b", aTob) |