aboutsummaryrefslogtreecommitdiff
path: root/org.jacoco.core.test/src/org/jacoco/core/test/validation
diff options
context:
space:
mode:
authorMarc R. Hoffmann <hoffmann@mountainminds.com>2014-05-05 17:08:50 +0200
committerMarc R. Hoffmann <hoffmann@mountainminds.com>2014-05-05 17:08:50 +0200
commit26386ea6b2ba1869b02b1980263d08a1955ebec6 (patch)
tree3aacc806e836b32f5fdb6e320add1062b301e326 /org.jacoco.core.test/src/org/jacoco/core/test/validation
parent72793f84314a393b86c5dc344499888b7113d20b (diff)
downloadjacoco-26386ea6b2ba1869b02b1980263d08a1955ebec6.tar.gz
GitHub #210: Add Java 8 validation tests.
Diffstat (limited to 'org.jacoco.core.test/src/org/jacoco/core/test/validation')
-rw-r--r--org.jacoco.core.test/src/org/jacoco/core/test/validation/java8/InterfaceDefaultMethodsTarget.java38
-rw-r--r--org.jacoco.core.test/src/org/jacoco/core/test/validation/java8/InterfaceDefaultMethodsTest.java39
2 files changed, 77 insertions, 0 deletions
diff --git a/org.jacoco.core.test/src/org/jacoco/core/test/validation/java8/InterfaceDefaultMethodsTarget.java b/org.jacoco.core.test/src/org/jacoco/core/test/validation/java8/InterfaceDefaultMethodsTarget.java
new file mode 100644
index 00000000..4e44d6f7
--- /dev/null
+++ b/org.jacoco.core.test/src/org/jacoco/core/test/validation/java8/InterfaceDefaultMethodsTarget.java
@@ -0,0 +1,38 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2014 Mountainminds GmbH & Co. KG and Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Marc R. Hoffmann - initial API and implementation
+ *
+ *******************************************************************************/
+package org.jacoco.core.test.validation.java8;
+
+import static org.jacoco.core.test.validation.targets.Stubs.i1;
+
+/**
+ * This test target is an interface with a class initializer.
+ */
+public interface InterfaceDefaultMethodsTarget {
+
+ public static final int CONST = i1(); // $line-clinit$
+
+ default void m1() {
+ return; // $line-m1$
+ }
+
+ default void m2() {
+ return; // $line-m2$
+ }
+
+ public class Impl implements InterfaceDefaultMethodsTarget {
+
+ public Impl() {
+ m1();
+ }
+ }
+
+}
diff --git a/org.jacoco.core.test/src/org/jacoco/core/test/validation/java8/InterfaceDefaultMethodsTest.java b/org.jacoco.core.test/src/org/jacoco/core/test/validation/java8/InterfaceDefaultMethodsTest.java
new file mode 100644
index 00000000..1bf67444
--- /dev/null
+++ b/org.jacoco.core.test/src/org/jacoco/core/test/validation/java8/InterfaceDefaultMethodsTest.java
@@ -0,0 +1,39 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2014 Mountainminds GmbH & Co. KG and Contributors
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Marc R. Hoffmann - initial API and implementation
+ *
+ *******************************************************************************/
+package org.jacoco.core.test.validation.java8;
+
+import org.jacoco.core.analysis.ICounter;
+import org.jacoco.core.test.validation.ValidationTestBase;
+import org.junit.Test;
+
+/**
+ * Tests of static initializer in interfaces.
+ */
+public class InterfaceDefaultMethodsTest extends ValidationTestBase {
+
+ public InterfaceDefaultMethodsTest() {
+ super(InterfaceDefaultMethodsTarget.class);
+ }
+
+ @Override
+ protected void run(final Class<?> targetClass) throws Exception {
+ loader.add(InterfaceDefaultMethodsTarget.Impl.class).newInstance();
+ }
+
+ @Test
+ public void testCoverageResult() {
+ assertLine("clinit", ICounter.FULLY_COVERED);
+ assertLine("m1", ICounter.FULLY_COVERED);
+ assertLine("m2", ICounter.NOT_COVERED);
+ }
+
+}