aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--org.jacoco.core.test.validation.java14/.classpath20
-rw-r--r--org.jacoco.core.test.validation.java14/.project30
-rw-r--r--org.jacoco.core.test.validation.java14/pom.xml38
-rw-r--r--org.jacoco.core.test.validation.java14/src/org/jacoco/core/test/validation/java14/SwitchExpressionsTest.java27
-rw-r--r--org.jacoco.core.test.validation.java14/src/org/jacoco/core/test/validation/java14/targets/SwitchExpressionsTarget.java110
-rw-r--r--org.jacoco.core.test.validation/pom.xml1
-rw-r--r--org.jacoco.core.test/src/org/jacoco/core/test/validation/targets/Stubs.java14
7 files changed, 240 insertions, 0 deletions
diff --git a/org.jacoco.core.test.validation.java14/.classpath b/org.jacoco.core.test.validation.java14/.classpath
new file mode 100644
index 00000000..8521cd5e
--- /dev/null
+++ b/org.jacoco.core.test.validation.java14/.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-14">
+ <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>
diff --git a/org.jacoco.core.test.validation.java14/.project b/org.jacoco.core.test.validation.java14/.project
new file mode 100644
index 00000000..fd583c68
--- /dev/null
+++ b/org.jacoco.core.test.validation.java14/.project
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+ <name>org.jacoco.core.test.validation.java14</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>
diff --git a/org.jacoco.core.test.validation.java14/pom.xml b/org.jacoco.core.test.validation.java14/pom.xml
new file mode 100644
index 00000000..42e97d93
--- /dev/null
+++ b/org.jacoco.core.test.validation.java14/pom.xml
@@ -0,0 +1,38 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Copyright (c) 2009, 2019 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.6-SNAPSHOT</version>
+ <relativePath>../org.jacoco.core.test.validation</relativePath>
+ </parent>
+
+ <artifactId>org.jacoco.core.test.validation.java14</artifactId>
+
+ <name>JaCoCo :: Test :: Core :: Validation Java 14</name>
+
+ <properties>
+ <bytecode.version>14</bytecode.version>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>org.jacoco.core.test</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
+</project>
diff --git a/org.jacoco.core.test.validation.java14/src/org/jacoco/core/test/validation/java14/SwitchExpressionsTest.java b/org.jacoco.core.test.validation.java14/src/org/jacoco/core/test/validation/java14/SwitchExpressionsTest.java
new file mode 100644
index 00000000..a5dde3be
--- /dev/null
+++ b/org.jacoco.core.test.validation.java14/src/org/jacoco/core/test/validation/java14/SwitchExpressionsTest.java
@@ -0,0 +1,27 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2019 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
+ *
+ *******************************************************************************/
+package org.jacoco.core.test.validation.java14;
+
+import org.jacoco.core.test.validation.ValidationTestBase;
+import org.jacoco.core.test.validation.java14.targets.SwitchExpressionsTarget;
+
+/**
+ * Test of code coverage for switch expressions.
+ */
+public class SwitchExpressionsTest extends ValidationTestBase {
+
+ public SwitchExpressionsTest() {
+ super(SwitchExpressionsTarget.class);
+ }
+
+}
diff --git a/org.jacoco.core.test.validation.java14/src/org/jacoco/core/test/validation/java14/targets/SwitchExpressionsTarget.java b/org.jacoco.core.test.validation.java14/src/org/jacoco/core/test/validation/java14/targets/SwitchExpressionsTarget.java
new file mode 100644
index 00000000..01430373
--- /dev/null
+++ b/org.jacoco.core.test.validation.java14/src/org/jacoco/core/test/validation/java14/targets/SwitchExpressionsTarget.java
@@ -0,0 +1,110 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2019 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
+ *
+ *******************************************************************************/
+package org.jacoco.core.test.validation.java14.targets;
+
+import static org.jacoco.core.test.validation.targets.Stubs.Enum.A;
+import static org.jacoco.core.test.validation.targets.Stubs.Enum.B;
+import static org.jacoco.core.test.validation.targets.Stubs.Enum.C;
+import static org.jacoco.core.test.validation.targets.Stubs.enumA;
+import static org.jacoco.core.test.validation.targets.Stubs.i1;
+import static org.jacoco.core.test.validation.targets.Stubs.i2;
+import static org.jacoco.core.test.validation.targets.Stubs.nop;
+
+/**
+ * This target exercises switch expressions.
+ */
+public class SwitchExpressionsTarget {
+
+ public static void main(String[] args) {
+
+ switchExpressionWithArrows();
+ multiValueSwitchExpressionWithArrows();
+ switchExpressionWithArrowsAndYield();
+ switchExpressionWithYield();
+ exhaustiveSwitchExpression();
+
+ }
+
+ private static void switchExpressionWithArrows() {
+
+ nop(switch (i2()) { // assertFullyCovered(3, 1)
+ case 1 -> i1(); // assertNotCovered()
+ case 2 -> i1(); // assertFullyCovered()
+ case 3 -> i1(); // assertNotCovered()
+ default -> i1(); // assertNotCovered()
+ });
+
+ }
+
+ private static void multiValueSwitchExpressionWithArrows() {
+
+ nop(switch (i2()) { // assertFullyCovered(2, 1)
+ case 1, 2 -> i1(); // assertFullyCovered()
+ case 3, 4 -> i1(); // assertNotCovered()
+ default -> i1(); // assertNotCovered()
+ });
+
+ }
+
+ private static void switchExpressionWithArrowsAndYield() {
+
+ nop(switch (i2()) { // assertFullyCovered(3, 1)
+ case 1 -> {
+ nop(); // assertNotCovered()
+ yield i1(); // assertNotCovered()
+ }
+ case 2 -> {
+ nop(); // assertFullyCovered()
+ yield i1(); // assertFullyCovered()
+ }
+ case 3 -> {
+ nop(); // assertNotCovered()
+ yield i1(); // assertNotCovered()
+ }
+ default -> {
+ nop(); // assertNotCovered()
+ yield i1(); // assertNotCovered()
+ }
+ });
+
+ }
+
+ private static void switchExpressionWithYield() {
+
+ nop(switch (i2()) { // assertFullyCovered(3, 1)
+ case 1:
+ nop(); // assertNotCovered()
+ yield i1(); // assertNotCovered()
+ case 2:
+ nop(); // assertFullyCovered()
+ yield i1(); // assertFullyCovered()
+ case 3:
+ nop(); // assertNotCovered()
+ yield i1(); // assertNotCovered()
+ default:
+ nop(); // assertNotCovered()
+ yield i1(); // assertNotCovered()
+ });
+
+ }
+
+ private static void exhaustiveSwitchExpression() {
+
+ nop(switch (enumA()) { // assertPartlyCovered(3, 1)
+ case A -> i1(); // assertFullyCovered()
+ case B -> i1(); // assertNotCovered()
+ case C -> i1(); // assertNotCovered()
+ });
+
+ }
+}
diff --git a/org.jacoco.core.test.validation/pom.xml b/org.jacoco.core.test.validation/pom.xml
index 7892506e..7c18ce49 100644
--- a/org.jacoco.core.test.validation/pom.xml
+++ b/org.jacoco.core.test.validation/pom.xml
@@ -214,6 +214,7 @@
<module>../org.jacoco.core.test.validation.kotlin</module>
<module>../org.jacoco.core.test.validation.java7</module>
<module>../org.jacoco.core.test.validation.java8</module>
+ <module>../org.jacoco.core.test.validation.java14</module>
<!-- Groovy 2.5.8 doesn't support bytecode version 14
<module>../org.jacoco.core.test.validation.groovy</module>
-->
diff --git a/org.jacoco.core.test/src/org/jacoco/core/test/validation/targets/Stubs.java b/org.jacoco.core.test/src/org/jacoco/core/test/validation/targets/Stubs.java
index 89034377..93f07747 100644
--- a/org.jacoco.core.test/src/org/jacoco/core/test/validation/targets/Stubs.java
+++ b/org.jacoco.core.test/src/org/jacoco/core/test/validation/targets/Stubs.java
@@ -40,6 +40,13 @@ public class Stubs {
}
/**
+ * Enum stub.
+ */
+ public static enum Enum {
+ A, B, C
+ }
+
+ /**
* Dummy method.
*/
public static void nop() {
@@ -99,6 +106,13 @@ public class Stubs {
}
/**
+ * @return always <code>A</code>
+ */
+ public static Enum enumA() {
+ return Enum.A;
+ }
+
+ /**
* Always throws a {@link RuntimeException}.
*
* @throws StubException