-
Notifications
You must be signed in to change notification settings - Fork 745
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Inline addSourceFile/addInput/addOutput in third_party ErrorProne.
This is mostly fully automated (unknown commit; I suggest averting your eyes, it's awful code), but with some modifications and reversions to make stuff compile: mostly modifications to BUILD files, and escaping things properly. There are some stragglers that I'll look at once some dust has settled. PiperOrigin-RevId: 682363540
- Loading branch information
1 parent
74ae417
commit e023166
Showing
515 changed files
with
27,580 additions
and
30,574 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,21 +32,257 @@ public class ArrayEqualsTest { | |
|
||
@Test | ||
public void positiveCase() { | ||
compilationHelper.addSourceFile("testdata/ArrayEqualsPositiveCases.java").doTest(); | ||
compilationHelper | ||
.addSourceLines( | ||
"ArrayEqualsPositiveCases.java", | ||
""" | ||
package com.google.errorprone.bugpatterns.testdata; | ||
import com.google.common.base.Objects; | ||
/** | ||
* @author [email protected] (Eddie Aftandilian) | ||
*/ | ||
public class ArrayEqualsPositiveCases { | ||
public void intArray() { | ||
int[] a = {1, 2, 3}; | ||
int[] b = {1, 2, 3}; | ||
// BUG: Diagnostic contains: Arrays.equals(a, b) | ||
if (a.equals(b)) { | ||
System.out.println("arrays are equal!"); | ||
} else { | ||
System.out.println("arrays are not equal!"); | ||
} | ||
// BUG: Diagnostic contains: Arrays.equals(a, b) | ||
if (Objects.equal(a, b)) { | ||
System.out.println("arrays are equal!"); | ||
} else { | ||
System.out.println("arrays are not equal!"); | ||
} | ||
} | ||
public void objectArray() { | ||
Object[] a = new Object[3]; | ||
Object[] b = new Object[3]; | ||
// BUG: Diagnostic contains: Arrays.equals(a, b) | ||
if (a.equals(b)) { | ||
System.out.println("arrays are equal!"); | ||
} else { | ||
System.out.println("arrays are not equal!"); | ||
} | ||
// BUG: Diagnostic contains: Arrays.equals(a, b) | ||
if (Objects.equal(a, b)) { | ||
System.out.println("arrays are equal!"); | ||
} else { | ||
System.out.println("arrays are not equal!"); | ||
} | ||
} | ||
public void firstMethodCall() { | ||
String s = "hello"; | ||
char[] b = new char[3]; | ||
// BUG: Diagnostic contains: Arrays.equals(s.toCharArray(), b) | ||
if (s.toCharArray().equals(b)) { | ||
System.out.println("arrays are equal!"); | ||
} else { | ||
System.out.println("arrays are not equal!"); | ||
} | ||
} | ||
public void secondMethodCall() { | ||
char[] a = new char[3]; | ||
String s = "hello"; | ||
// BUG: Diagnostic contains: Arrays.equals(a, s.toCharArray()) | ||
if (a.equals(s.toCharArray())) { | ||
System.out.println("arrays are equal!"); | ||
} else { | ||
System.out.println("arrays are not equal!"); | ||
} | ||
} | ||
public void bothMethodCalls() { | ||
String s1 = "hello"; | ||
String s2 = "world"; | ||
// BUG: Diagnostic contains: Arrays.equals(s1.toCharArray(), s2.toCharArray()) | ||
if (s1.toCharArray().equals(s2.toCharArray())) { | ||
System.out.println("arrays are equal!"); | ||
} else { | ||
System.out.println("arrays are not equal!"); | ||
} | ||
} | ||
}""") | ||
.doTest(); | ||
} | ||
|
||
@Test | ||
public void java7PositiveCase() { | ||
compilationHelper.addSourceFile("testdata/ArrayEqualsPositiveCases2.java").doTest(); | ||
compilationHelper | ||
.addSourceLines( | ||
"ArrayEqualsPositiveCases2.java", | ||
""" | ||
package com.google.errorprone.bugpatterns.testdata; | ||
import java.util.Objects; | ||
/** | ||
* Tests that only run with Java 7 and above. | ||
* | ||
* @author [email protected] (Eddie Aftandilian) | ||
*/ | ||
public class ArrayEqualsPositiveCases2 { | ||
public void intArray() { | ||
int[] a = {1, 2, 3}; | ||
int[] b = {1, 2, 3}; | ||
// BUG: Diagnostic contains: Arrays.equals(a, b) | ||
if (Objects.equals(a, b)) { | ||
System.out.println("arrays are equal!"); | ||
} else { | ||
System.out.println("arrays are not equal!"); | ||
} | ||
} | ||
public void objectArray() { | ||
Object[] a = new Object[3]; | ||
Object[] b = new Object[3]; | ||
// BUG: Diagnostic contains: Arrays.equals(a, b) | ||
if (Objects.equals(a, b)) { | ||
System.out.println("arrays are equal!"); | ||
} else { | ||
System.out.println("arrays are not equal!"); | ||
} | ||
} | ||
}""") | ||
.doTest(); | ||
} | ||
|
||
@Test | ||
public void negativeCase() { | ||
compilationHelper.addSourceFile("testdata/ArrayEqualsNegativeCases.java").doTest(); | ||
compilationHelper | ||
.addSourceLines( | ||
"ArrayEqualsNegativeCases.java", | ||
""" | ||
package com.google.errorprone.bugpatterns.testdata; | ||
import com.google.common.base.Objects; | ||
/** | ||
* @author [email protected] (Eddie Aftandilian) | ||
*/ | ||
public class ArrayEqualsNegativeCases { | ||
public void neitherArray() { | ||
Object a = new Object(); | ||
Object b = new Object(); | ||
if (a.equals(b)) { | ||
System.out.println("Objects are equal!"); | ||
} else { | ||
System.out.println("Objects are not equal!"); | ||
} | ||
if (Objects.equal(a, b)) { | ||
System.out.println("Objects are equal!"); | ||
} else { | ||
System.out.println("Objects are not equal!"); | ||
} | ||
} | ||
public void firstArray() { | ||
Object[] a = new Object[3]; | ||
Object b = new Object(); | ||
if (a.equals(b)) { | ||
System.out.println("arrays are equal!"); | ||
} else { | ||
System.out.println("arrays are not equal!"); | ||
} | ||
if (Objects.equal(a, b)) { | ||
System.out.println("Objects are equal!"); | ||
} else { | ||
System.out.println("Objects are not equal!"); | ||
} | ||
} | ||
public void secondArray() { | ||
Object a = new Object(); | ||
Object[] b = new Object[3]; | ||
if (a.equals(b)) { | ||
System.out.println("arrays are equal!"); | ||
} else { | ||
System.out.println("arrays are not equal!"); | ||
} | ||
if (Objects.equal(a, b)) { | ||
System.out.println("Objects are equal!"); | ||
} else { | ||
System.out.println("Objects are not equal!"); | ||
} | ||
} | ||
}""") | ||
.doTest(); | ||
} | ||
|
||
@Test | ||
public void java7NegativeCase() { | ||
compilationHelper.addSourceFile("testdata/ArrayEqualsNegativeCases2.java").doTest(); | ||
compilationHelper | ||
.addSourceLines( | ||
"ArrayEqualsNegativeCases2.java", | ||
""" | ||
package com.google.errorprone.bugpatterns.testdata; | ||
import java.util.Objects; | ||
/** | ||
* Tests that only run with Java 7 and above. | ||
* | ||
* @author [email protected] (Eddie Aftandilian) | ||
*/ | ||
public class ArrayEqualsNegativeCases2 { | ||
public void neitherArray() { | ||
Object a = new Object(); | ||
Object b = new Object(); | ||
if (Objects.equals(a, b)) { | ||
System.out.println("Objects are equal!"); | ||
} else { | ||
System.out.println("Objects are not equal!"); | ||
} | ||
} | ||
public void firstArray() { | ||
Object[] a = new Object[3]; | ||
Object b = new Object(); | ||
if (Objects.equals(a, b)) { | ||
System.out.println("arrays are equal!"); | ||
} else { | ||
System.out.println("arrays are not equal!"); | ||
} | ||
} | ||
public void secondArray() { | ||
Object a = new Object(); | ||
Object[] b = new Object[3]; | ||
if (Objects.equals(a, b)) { | ||
System.out.println("arrays are equal!"); | ||
} else { | ||
System.out.println("arrays are not equal!"); | ||
} | ||
} | ||
}""") | ||
.doTest(); | ||
} | ||
} |
Oops, something went wrong.