Skip to content

Commit

Permalink
Add validation test for JEP 305: Pattern Matching for instanceof (baz…
Browse files Browse the repository at this point in the history
  • Loading branch information
Godin authored and marchof committed Jan 21, 2020
1 parent b5f1b5d commit 66acd84
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*******************************************************************************
* Copyright (c) 2009, 2020 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.java14;

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

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

public InstanceofTest() {
super(InstanceofTarget.class);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*******************************************************************************
* Copyright (c) 2009, 2020 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.java14.targets;

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

/**
* This target exercises pattern matching for instanceof (JEP 305).
*/
public class InstanceofTarget {

private static void ifInstanceof(Object e) {
/* See https://bugs.openjdk.java.net/browse/JDK-8237528 */
if (e instanceof String s) { // assertFullyCovered(1, 3)
nop(s);
}
}

public static void main(String[] args) {
ifInstanceof(new Object());
ifInstanceof("string");
}

}

0 comments on commit 66acd84

Please sign in to comment.