Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add validation test for JEP 433: Pattern Matching for switch #1191

Merged
merged 1 commit into from Feb 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 20 additions & 0 deletions org.jacoco.core.test.validation.java20/.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-20">
<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.java20/.project
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.jacoco.core.test.validation.java20</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>
59 changes: 59 additions & 0 deletions org.jacoco.core.test.validation.java20/pom.xml
@@ -0,0 +1,59 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright (c) 2009, 2022 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:
Evgeny Mandrikov - 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.9-SNAPSHOT</version>
<relativePath>../org.jacoco.core.test.validation</relativePath>
</parent>

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

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

<properties>
<bytecode.version>20</bytecode.version>
</properties>

<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>org.jacoco.core.test</artifactId>
<version>${project.version}</version>
</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>
@@ -0,0 +1,27 @@
/*******************************************************************************
* Copyright (c) 2009, 2022 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:
* Evgeny Mandrikov - initial API and implementation
*
*******************************************************************************/
package org.jacoco.core.test.validation.java20;

import org.jacoco.core.test.validation.ValidationTestBase;
import org.jacoco.core.test.validation.java20.targets.SwitchPatternMatchingTarget;

/**
* Test of code coverage in {@link SwitchPatternMatchingTarget}.
*/
public class SwitchPatternMatchingTest extends ValidationTestBase {

public SwitchPatternMatchingTest() {
super(SwitchPatternMatchingTarget.class);
}

}
@@ -0,0 +1,39 @@
/*******************************************************************************
* Copyright (c) 2009, 2022 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:
* Evgeny Mandrikov - initial API and implementation
*
*******************************************************************************/
package org.jacoco.core.test.validation.java20.targets;

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

/**
* This target exercises pattern matching for switch
* (<a href="https://openjdk.org/jeps/433">JEP 433</a>).
*/
public class SwitchPatternMatchingTarget {

private static void example(Object o) {
switch (o) { // assertFullyCovered(1, 2)
case String s when s.length() == 0 -> // assertFullyCovered(0, 2)
nop(s); // assertFullyCovered()
case String s -> // assertFullyCovered()
nop(s); // assertFullyCovered()
default -> // assertEmpty()
nop(); // assertNotCovered()
}
}

public static void main(String[] args) {
example("");
example("a");
}

}
2 changes: 2 additions & 0 deletions org.jacoco.core.test.validation/pom.xml
Expand Up @@ -419,6 +419,7 @@
<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.java20</module>
<module>../org.jacoco.core.test.validation.groovy</module>
<module>../org.jacoco.core.test.validation.scala</module>
</modules>
Expand Down Expand Up @@ -447,6 +448,7 @@
<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.java20</module>
<!-- Groovy 3.0.15 does not support Java 21
<module>../org.jacoco.core.test.validation.groovy</module>
-->
Expand Down