Skip to content

Commit

Permalink
Fix for #1061: improve testing support for Java 12+
Browse files Browse the repository at this point in the history
  • Loading branch information
eric-milles committed Mar 18, 2020
1 parent a7fd684 commit efb12a5
Show file tree
Hide file tree
Showing 7 changed files with 755 additions and 746 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -856,7 +856,9 @@ public void testGenericsMethodReferenceSearch() throws Exception {
List<SearchMatch> matches = searchRequestor.getMatches();

assertEquals(1, matches.size());
assertEquals(SearchMatch.A_ACCURATE, matches.get(0).getAccuracy());
// TODO: Determine why the accuracy changed between Java 11 and Java 12.
assertEquals(Integer.parseInt(System.getProperty("java.version").split("\\.")[0]) < 12
? SearchMatch.A_ACCURATE : SearchMatch.A_INACCURATE, matches.get(0).getAccuracy());
assertEquals("Baz.java", ((IJavaElement) matches.get(0).getElement()).getResource().getName());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import static org.eclipse.jdt.groovy.core.tests.GroovyBundle.isAtLeastGroovy;

import org.eclipse.jdt.core.JavaCore;
import org.junit.Ignore;
import org.junit.Test;

Expand Down Expand Up @@ -866,7 +865,8 @@ public void testInlinedStaticFinalAttributeValue() {
};
//@formatter:on

runConformTest(sources, JavaCore.compareJavaVersions(System.getProperty("java.version"), "9") < 0 ? "@Anno(value=abc)" : "@Anno(value=\"abc\")");
int release = Integer.parseInt(System.getProperty("java.version").split("\\.")[0]);
runConformTest(sources, release < 9 ? "@Anno(value=abc)" : (release < 13 ? "@Anno(value=\"abc\")" : "@Anno(\"abc\")"));
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ public abstract class GroovyCompilerTestSuite {
protected static final long JDK11 = (55L << 16) + ClassFileConstants.MINOR_VERSION_0;
protected static final long JDK12 = (56L << 16) + ClassFileConstants.MINOR_VERSION_0;
protected static final long JDK13 = (57L << 16) + ClassFileConstants.MINOR_VERSION_0;
protected static final List<Long> JDKs = Collections.unmodifiableList(Arrays.asList(JDK7, JDK8, JDK9, JDK10, JDK11, JDK12, JDK13));
protected static final long JDK14 = (58L << 16) + ClassFileConstants.MINOR_VERSION_0;
protected static final List<Long> JDKs = Collections.unmodifiableList(Arrays.asList(JDK7, JDK8, JDK9, JDK10, JDK11, JDK12, JDK13, JDK14));

@Parameters(name = "Java {1}")
public static Iterable<Object[]> params() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2009-2019 the original author or authors.
* Copyright 2009-2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -83,11 +83,10 @@ public void testAnnotationCollector3() {
"import java.lang.reflect.*\n" +
"class Book {\n" +
" @ISBN String isbn\n" +
" public static void main(String[] argv) {\n" +
" Field f = Book.class.getDeclaredField('isbn')\n" +
" Object[] os = f.getDeclaredAnnotations()\n" +
" for (Object o: os) {\n" +
" println(o)\n" +
" static void main(args) {\n" +
" Field f = this.getDeclaredField('isbn')\n" +
" for (a in f.getDeclaredAnnotations()) {\n" +
" print(a)\n" +
" }\n" +
" }\n" +
"}\n",
Expand All @@ -110,6 +109,7 @@ public void testAnnotationCollector3() {
};
//@formatter:on

runConformTest(sources, "@NotNull()\n@Length(value=0)");
int release = Integer.parseInt(System.getProperty("java.version").split("\\.")[0]);
runConformTest(sources, release > 13 ? "@NotNull()@Length(0)" : "@NotNull()@Length(value=0)");
}
}
Loading

0 comments on commit efb12a5

Please sign in to comment.