aboutsummaryrefslogtreecommitdiff
path: root/org.jacoco.core.test
diff options
context:
space:
mode:
authorMarc R. Hoffmann <hoffmann@mountainminds.com>2015-10-30 09:34:48 +0100
committerMarc R. Hoffmann <hoffmann@mountainminds.com>2015-10-30 09:36:03 +0100
commit0638deda4eb4907dd8067a524dc915b484d2c22a (patch)
tree78bbca05dbaab6eafa82d5a60c5ed322e1f032b6 /org.jacoco.core.test
parent46c167a494c8864fb6a5f4d33f12b1c5ede8cf46 (diff)
downloadjacoco-0638deda4eb4907dd8067a524dc915b484d2c22a.tar.gz
Verify that constants with lambda values in interfaces do work.
Diffstat (limited to 'org.jacoco.core.test')
-rw-r--r--org.jacoco.core.test/src/org/jacoco/core/test/validation/java8/LambdaExpressionsTest.java2
-rw-r--r--org.jacoco.core.test/src/org/jacoco/core/test/validation/java8/LambdaInInterfaceTarget.java25
-rw-r--r--org.jacoco.core.test/src/org/jacoco/core/test/validation/java8/LambdaInInterfaceTest.java40
3 files changed, 66 insertions, 1 deletions
diff --git a/org.jacoco.core.test/src/org/jacoco/core/test/validation/java8/LambdaExpressionsTest.java b/org.jacoco.core.test/src/org/jacoco/core/test/validation/java8/LambdaExpressionsTest.java
index deb2d493..3a290551 100644
--- a/org.jacoco.core.test/src/org/jacoco/core/test/validation/java8/LambdaExpressionsTest.java
+++ b/org.jacoco.core.test/src/org/jacoco/core/test/validation/java8/LambdaExpressionsTest.java
@@ -16,7 +16,7 @@ import org.jacoco.core.test.validation.ValidationTestBase;
import org.junit.Test;
/**
- * Tests of basic Java control structures.
+ * Tests for different lambda expressions.
*/
public class LambdaExpressionsTest extends ValidationTestBase {
diff --git a/org.jacoco.core.test/src/org/jacoco/core/test/validation/java8/LambdaInInterfaceTarget.java b/org.jacoco.core.test/src/org/jacoco/core/test/validation/java8/LambdaInInterfaceTarget.java
new file mode 100644
index 00000000..733e59ad
--- /dev/null
+++ b/org.jacoco.core.test/src/org/jacoco/core/test/validation/java8/LambdaInInterfaceTarget.java
@@ -0,0 +1,25 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2015 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.nop;
+
+/**
+ * This test target builds a constant with a lambda value in an interface.
+ */
+public interface LambdaInInterfaceTarget {
+
+ public static final Runnable RUN = () -> {
+ nop(); // $line-lambdabody$
+ };
+
+}
diff --git a/org.jacoco.core.test/src/org/jacoco/core/test/validation/java8/LambdaInInterfaceTest.java b/org.jacoco.core.test/src/org/jacoco/core/test/validation/java8/LambdaInInterfaceTest.java
new file mode 100644
index 00000000..895884c5
--- /dev/null
+++ b/org.jacoco.core.test/src/org/jacoco/core/test/validation/java8/LambdaInInterfaceTest.java
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2015 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 a constant with a lambda value in an interface.
+ */
+public class LambdaInInterfaceTest extends ValidationTestBase {
+
+ public LambdaInInterfaceTest() {
+ super(LambdaInInterfaceTarget.class);
+ }
+
+ @Override
+ protected void run(final Class<?> targetClass) throws Exception {
+ ((Runnable) targetClass.getField("RUN").get(null)).run();
+ }
+
+ @Test
+ public void testCoverageResult() {
+
+ // Coverage of lambda body
+ assertLine("lambdabody", ICounter.FULLY_COVERED);
+
+ }
+
+}