Skip to content

Commit

Permalink
Add module for Java 16 validation tests (#1165)
Browse files Browse the repository at this point in the history
Records and Pattern Matching for instanceof are finalized in Java 16,
so no need to test them as preview features in earlier versions.
  • Loading branch information
marchof committed May 28, 2021
1 parent 49b3fe4 commit 9262844
Show file tree
Hide file tree
Showing 10 changed files with 116 additions and 39 deletions.
20 changes: 0 additions & 20 deletions org.jacoco.core.test.validation.java14/pom.xml
Expand Up @@ -36,24 +36,4 @@
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<compilerArgs>
<arg>--enable-preview</arg>
</compilerArgs>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<argLine>--enable-preview</argLine>
</configuration>
</plugin>
</plugins>
</build>
</project>
20 changes: 20 additions & 0 deletions org.jacoco.core.test.validation.java16/.classpath
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-16">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" output="target/classes" path="src">
<attributes>
<attribute name="optional" value="true"/>
<attribute name="maven.pomderived" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="target/classes"/>
</classpath>
30 changes: 30 additions & 0 deletions org.jacoco.core.test.validation.java16/.project
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.jacoco.core.test.validation.java16</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.m2e.core.maven2Builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.m2e.core.maven2Nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
<linkedResources>
<link>
<name>.settings</name>
<type>2</type>
<locationURI>PARENT-1-PROJECT_LOC/org.jacoco.core.test/.settings</locationURI>
</link>
</linkedResources>
</projectDescription>
39 changes: 39 additions & 0 deletions org.jacoco.core.test.validation.java16/pom.xml
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2009, 2021 Mountainminds GmbH & Co. KG and Contributors
This program and the accompanying materials are made available under
the terms of the Eclipse Public License 2.0 which is available at
http://www.eclipse.org/legal/epl-2.0
SPDX-License-Identifier: EPL-2.0
Contributors:
Marc R. Hoffmann - initial API and implementation
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.jacoco</groupId>
<artifactId>org.jacoco.core.test.validation</artifactId>
<version>0.8.8-SNAPSHOT</version>
<relativePath>../org.jacoco.core.test.validation</relativePath>
</parent>

<artifactId>org.jacoco.core.test.validation.java16</artifactId>

<name>JaCoCo :: Test :: Core :: Validation Java 16</name>

<properties>
<bytecode.version>16</bytecode.version>
</properties>

<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>org.jacoco.core.test</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>

</project>
Expand Up @@ -10,11 +10,10 @@
* Evgeny Mandrikov - initial API and implementation
*
*******************************************************************************/
package org.jacoco.core.test.validation.java14;
package org.jacoco.core.test.validation.java16;

import org.jacoco.core.test.validation.Source.Line;
import org.jacoco.core.test.validation.ValidationTestBase;
import org.jacoco.core.test.validation.java14.targets.InstanceofTarget;
import org.jacoco.core.test.validation.java16.targets.InstanceofTarget;

/**
* Test of code coverage in {@link InstanceofTarget}.
Expand All @@ -25,13 +24,4 @@ public InstanceofTest() {
super(InstanceofTarget.class);
}

public void assertInstanceof(final Line line) {
if (isJDKCompiler && JAVA_VERSION.isBefore("15")) {
// https://bugs.openjdk.java.net/browse/JDK-8237528
assertFullyCovered(line, 1, 3);
} else {
assertFullyCovered(line, 0, 2);
}
}

}
Expand Up @@ -10,10 +10,10 @@
* Evgeny Mandrikov - initial API and implementation
*
*******************************************************************************/
package org.jacoco.core.test.validation.java14;
package org.jacoco.core.test.validation.java16;

import org.jacoco.core.test.validation.ValidationTestBase;
import org.jacoco.core.test.validation.java14.targets.RecordsTarget;
import org.jacoco.core.test.validation.java16.targets.RecordsTarget;

/**
* Test of code coverage for records.
Expand Down
Expand Up @@ -10,17 +10,18 @@
* Evgeny Mandrikov - initial API and implementation
*
*******************************************************************************/
package org.jacoco.core.test.validation.java14.targets;
package org.jacoco.core.test.validation.java16.targets;

import static org.jacoco.core.test.validation.targets.Stubs.nop;

/**
* This target exercises pattern matching for instanceof (JEP 305).
* This target exercises pattern matching for instanceof
* (<a href="https://openjdk.java.net/jeps/394">JEP 394</a>).
*/
public class InstanceofTarget {

private static void ifInstanceof(Object e) {
if (e instanceof String s) { // assertInstanceof()
if (e instanceof String s) { // assertFullyCovered(0, 2)
nop(s);
}
}
Expand Down
Expand Up @@ -10,10 +10,11 @@
* Evgeny Mandrikov - initial API and implementation
*
*******************************************************************************/
package org.jacoco.core.test.validation.java14.targets;
package org.jacoco.core.test.validation.java16.targets;

/**
* This target exercises records.
* This target exercises records
* (<a href="https://openjdk.java.net/jeps/395">JEP 395</a>).
*/
public class RecordsTarget {

Expand Down
1 change: 1 addition & 0 deletions org.jacoco.core.test.validation/pom.xml
Expand Up @@ -307,6 +307,7 @@
<module>../org.jacoco.core.test.validation.java7</module>
<module>../org.jacoco.core.test.validation.java8</module>
<module>../org.jacoco.core.test.validation.java14</module>
<module>../org.jacoco.core.test.validation.java16</module>
<module>../org.jacoco.core.test.validation.groovy</module>
<module>../org.jacoco.core.test.validation.scala</module>
</modules>
Expand Down
15 changes: 15 additions & 0 deletions org.jacoco.doc/docroot/doc/build.html
Expand Up @@ -96,6 +96,21 @@ <h2>Compilation and testing with different JDKs</h2>
</tr>
</thead>
<tbody>
<tr>
<td>org.jacoco.core.test.validation.java16</td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td></td>
<td>16</td>
</tr>
<tr>
<td>org.jacoco.core.test.validation.java14</td>
<td></td>
Expand Down

0 comments on commit 9262844

Please sign in to comment.