Permalink
Browse files

Ensure all test files compile

  • Loading branch information...
1 parent 12cefce commit 05d0d3d25068e2df45cb0b1a0880906e4d532744 @dominikh committed Nov 11, 2016
Showing with 15 additions and 13 deletions.
  1. +3 −3 testdata/contains.go
  2. +4 −2 testdata/if-return.go
  3. +8 −8 testdata/if-simpler-return.go
@@ -33,7 +33,7 @@ func fn() {
_ = strings.Index("", "") != 0
_ = strings.Index("", "") < 0 // MATCH /!strings.Contains/
- _ = bytes.IndexRune("", 'x') > -1 // MATCH / bytes.ContainsRune/
- _ = bytes.IndexAny("", "") > -1 // MATCH / bytes.ContainsAny/
- _ = bytes.Index(nil, nil) > -1 // MATCH / bytes.Contains/
+ _ = bytes.IndexRune(nil, 'x') > -1 // MATCH / bytes.ContainsRune/
+ _ = bytes.IndexAny(nil, "") > -1 // MATCH / bytes.ContainsAny/
+ _ = bytes.Index(nil, nil) > -1 // MATCH / bytes.Contains/
}
@@ -1,5 +1,6 @@
package pkg
+func fn() bool { return true }
func fn1() bool {
x := true
if x { // MATCH /should use 'return <expr>'/
@@ -20,6 +21,7 @@ func fn2() bool {
}
func fn3() int {
+ var x bool
if x {
return 1
}
@@ -29,7 +31,7 @@ func fn3() int {
func fn4() bool { return true }
func fn5() bool {
- if fn3() { // MATCH /should use 'return <expr>'/
+ if fn() { // MATCH /should use 'return <expr>'/
return false
}
return true
@@ -50,7 +52,7 @@ func fn7() bool {
}
func fn8() bool {
- if fn3() || fn3() {
+ if fn() || fn() {
return true
}
return false
@@ -10,7 +10,7 @@ func fn1() error {
}
return nil
- _ = nil
+ _ = 0
if err != nil { // MATCH /simplified/
return err
@@ -29,28 +29,28 @@ func fn2() (int, string, error) {
}
return x, y, nil
- _ = nil
+ _ = 0
if err != nil { // MATCH /simplified/
return x, y, err
}
return x, y, err
- _ = nil
+ _ = 0
if err != nil {
return x, y, err
}
return z, y, err
- _ = nil
+ _ = 0
if err != nil {
return 0, "", err
}
return x, y, err
- _ = nil
+ _ = 0
// TODO(dominikh): currently, only returning identifiers is
// supported
@@ -80,7 +80,7 @@ func fn4(i int, err error) error {
return nil
}
-func fn4() interface{} {
+func fn5() interface{} {
var i *int
if i != nil {
return i
@@ -94,8 +94,8 @@ func fn4() interface{} {
return nil
}
-func fn5() {
- func() error {
+func fn6() {
+ _ = func() error {
var err error
if err != nil { // MATCH /simplified/
return err

0 comments on commit 05d0d3d

Please sign in to comment.