Skip to content

Commit 66acd84

Browse files
Godinmarchof
authored andcommitted
Add validation test for JEP 305: Pattern Matching for instanceof (bazel-contrib#999)
1 parent b5f1b5d commit 66acd84

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2009, 2020 Mountainminds GmbH & Co. KG and Contributors
3+
* This program and the accompanying materials are made available under
4+
* the terms of the Eclipse Public License 2.0 which is available at
5+
* http://www.eclipse.org/legal/epl-2.0
6+
*
7+
* SPDX-License-Identifier: EPL-2.0
8+
*
9+
* Contributors:
10+
* Evgeny Mandrikov - initial API and implementation
11+
*
12+
*******************************************************************************/
13+
package org.jacoco.core.test.validation.java14;
14+
15+
import org.jacoco.core.test.validation.ValidationTestBase;
16+
import org.jacoco.core.test.validation.java14.targets.InstanceofTarget;
17+
18+
/**
19+
* Test of code coverage in {@link InstanceofTarget}.
20+
*/
21+
public class InstanceofTest extends ValidationTestBase {
22+
23+
public InstanceofTest() {
24+
super(InstanceofTarget.class);
25+
}
26+
27+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*******************************************************************************
2+
* Copyright (c) 2009, 2020 Mountainminds GmbH & Co. KG and Contributors
3+
* This program and the accompanying materials are made available under
4+
* the terms of the Eclipse Public License 2.0 which is available at
5+
* http://www.eclipse.org/legal/epl-2.0
6+
*
7+
* SPDX-License-Identifier: EPL-2.0
8+
*
9+
* Contributors:
10+
* Evgeny Mandrikov - initial API and implementation
11+
*
12+
*******************************************************************************/
13+
package org.jacoco.core.test.validation.java14.targets;
14+
15+
import static org.jacoco.core.test.validation.targets.Stubs.nop;
16+
17+
/**
18+
* This target exercises pattern matching for instanceof (JEP 305).
19+
*/
20+
public class InstanceofTarget {
21+
22+
private static void ifInstanceof(Object e) {
23+
/* See https://bugs.openjdk.java.net/browse/JDK-8237528 */
24+
if (e instanceof String s) { // assertFullyCovered(1, 3)
25+
nop(s);
26+
}
27+
}
28+
29+
public static void main(String[] args) {
30+
ifInstanceof(new Object());
31+
ifInstanceof("string");
32+
}
33+
34+
}

0 commit comments

Comments
 (0)