Skip to content

Commit

Permalink
Capture test cases from hohwille
Browse files Browse the repository at this point in the history
Prepare tests with run.javac capturing the current differences
  • Loading branch information
stephan-herrmann committed May 28, 2024
1 parent 0ecae64 commit c985110
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -837,6 +837,19 @@ public boolean clears(int mismatch) {
Excuse excuseFor(JavacCompiler compiler) {
return null;
}
/** Difference were we're not sure which is correct, but want to be informed if either compiler changes. */
public static class DubiousOutcome extends Excuse {
DubiousOutcome(int mismatchType) {
super(mismatchType);
}
public static DubiousOutcome
EclipseErrorsJavacNone = RUN_JAVAC ?
new DubiousOutcome(MismatchType.EclipseErrorsJavacNone) : null,
JavacErrorsEclipseNone = RUN_JAVAC ?
new DubiousOutcome(MismatchType.JavacErrorsEclipseNone) : null,
JDK8319461 = RUN_JAVAC ? // https://bugs.openjdk.org/browse/JDK-8319461
new DubiousOutcome(MismatchType.JavacErrorsEclipseNone) : null;
}
public static class EclipseHasABug extends Excuse {
EclipseHasABug(int mismatchType) {
super(mismatchType);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
*******************************************************************************/
package org.eclipse.jdt.core.tests.compiler.regression;

import org.eclipse.jdt.core.tests.compiler.regression.AbstractRegressionTest.JavacTestOptions.DubiousOutcome;

import junit.framework.Test;

/**
Expand Down Expand Up @@ -45,8 +47,8 @@ public static Test suite() {

public void testGH1591() {
// javac accepts
runNegativeTest(
new String[] {
Runner runner = new Runner();
runner.testFiles = new String[] {
"Outer.java",
"""
import java.io.Serializable;
Expand All @@ -63,13 +65,16 @@ public <T, V extends Serializable> void error(List<V> v2, T t) {}
}
"""
},
};
runner.expectedCompilerLog =
"----------\n" +
"1. ERROR in Outer.java (at line 8)\n" +
" error(supplier.get(), \"\");\n" +
" ^^^^^\n" +
"The method error(List<V>, T) in the type Outer is not applicable for the arguments (capture#1-of ? extends List<? extends Serializable>, String)\n" +
"----------\n");
"----------\n";
runner.javacTestOptions = DubiousOutcome.EclipseErrorsJavacNone;
runner.runNegativeTest();
}

public void testHohwille_20160104() {
Expand All @@ -83,8 +88,8 @@ both method setValue(Boolean) in TypedInterface and method setValue(V) in Generi
V extends Object declared in interface GenericInterface
1 error
*/
runConformTest(
new String[] {
Runner runner = new Runner();
runner.testFiles = new String[] {
"CombinedInterface.java",
"""
interface GenericInterface<V> {
Expand All @@ -99,7 +104,9 @@ default void set(boolean value) {
}
}
"""
});
};
runner.javacTestOptions = DubiousOutcome.JavacErrorsEclipseNone;
runner.runConformTest();
}

public void testHohwille_20180606() {
Expand All @@ -119,8 +126,8 @@ public GenericTest(GenericTest<? super A, ? super B> parent) {
A extends Object declared in class GenericTest
2 errors
*/
runConformTest(
new String[] {
Runner runner = new Runner();
runner.testFiles = new String[] {
"GenericTest.java",
"""
public class GenericTest<A, B extends A> {
Expand All @@ -133,7 +140,9 @@ public GenericTest(GenericTest<? super A, ? super B> parent) {
}
}
"""
});
};
runner.javacTestOptions = DubiousOutcome.JavacErrorsEclipseNone;
runner.runConformTest();
}
public void testHohwille_20231104() {
/* see https://github.com/m-m-m/util/issues/166#issuecomment-1793234294
Expand Down Expand Up @@ -162,8 +171,8 @@ public void testHohwille_20231104() {
V#2 extends Object declared in method <V#2,P#2>create(Class<P#2>,PropertyTypeInfo<V#2>)
2 errors
*/
runConformTest(
new String[] {
Runner runner = new Runner();
runner.testFiles = new String[] {
"PropertyFactoryManager.java",
"""
interface WritableObservableValue<V> { }
Expand Down Expand Up @@ -196,7 +205,9 @@ default <V, P extends ReadableProperty<V>> P create(Class<P> propertyType, Prope
}
}
"""
});
};
runner.javacTestOptions = DubiousOutcome.JDK8319461;
runner.runConformTest();
}
public void testJDK8319461() {
/* Hohwille's reduction of the above
Expand All @@ -221,8 +232,8 @@ missing type arguments for generic class Factory<V,P>
1 error
1 warning
*/
runConformTest(
new String[] {
Runner runner = new Runner();
runner.testFiles = new String[] {
"JDK8319461.java",
"""
public class JDK8319461 {
Expand All @@ -239,6 +250,8 @@ public interface WritableProperty<V> extends ReadableProperty<V> { }
public interface Factory<V, P extends WritableProperty<V>> { }
}
"""
});
};
runner.javacTestOptions = DubiousOutcome.JDK8319461;
runner.runConformTest();
}
}

0 comments on commit c985110

Please sign in to comment.