aboutsummaryrefslogtreecommitdiff
path: root/org.jacoco.core.test/src/org
diff options
context:
space:
mode:
authorMarc R. Hoffmann <hoffmann@mountainminds.com>2013-06-01 12:19:09 +0200
committerMarc R. Hoffmann <hoffmann@mountainminds.com>2013-06-01 12:19:09 +0200
commite048201f115d862e1b99e78249ef9e720212c201 (patch)
treee127902553a8c7b40e8c1a847b619ffcfba1482b /org.jacoco.core.test/src/org
parent73a2235e02b93b114b2dee69b05ab07ae5a0693a (diff)
downloadjacoco-e048201f115d862e1b99e78249ef9e720212c201.tar.gz
Issue error when analyzing instrumented classes (GitHub #108)
Diffstat (limited to 'org.jacoco.core.test/src/org')
-rw-r--r--org.jacoco.core.test/src/org/jacoco/core/internal/analysis/ClassAnalyzerTest.java47
-rw-r--r--org.jacoco.core.test/src/org/jacoco/core/internal/instr/InstrSupportTest.java15
2 files changed, 62 insertions, 0 deletions
diff --git a/org.jacoco.core.test/src/org/jacoco/core/internal/analysis/ClassAnalyzerTest.java b/org.jacoco.core.test/src/org/jacoco/core/internal/analysis/ClassAnalyzerTest.java
new file mode 100644
index 00000000..c60901c2
--- /dev/null
+++ b/org.jacoco.core.test/src/org/jacoco/core/internal/analysis/ClassAnalyzerTest.java
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2009, 2013 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.internal.analysis;
+
+import org.jacoco.core.internal.instr.InstrSupport;
+import org.junit.Before;
+import org.junit.Test;
+import org.objectweb.asm.Opcodes;
+
+/**
+ * Unit tests for {@link ClassAnalyzer}.
+ */
+public class ClassAnalyzerTest {
+
+ private ClassAnalyzer analyzer;
+
+ @Before
+ public void setup() {
+ analyzer = new ClassAnalyzer(0x0000, null, new StringPool());
+ analyzer.visit(Opcodes.V1_5, Opcodes.ACC_PUBLIC, "Foo", null,
+ "java/lang/Object", null);
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testAnalyzeInstrumentedClass1() {
+ analyzer.visitField(InstrSupport.DATAFIELD_ACC,
+ InstrSupport.DATAFIELD_NAME, InstrSupport.DATAFIELD_DESC, null,
+ null);
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testAnalyzeInstrumentedClass2() {
+ analyzer.visitMethod(InstrSupport.INITMETHOD_ACC,
+ InstrSupport.INITMETHOD_NAME, InstrSupport.INITMETHOD_DESC,
+ null, null);
+ }
+
+}
diff --git a/org.jacoco.core.test/src/org/jacoco/core/internal/instr/InstrSupportTest.java b/org.jacoco.core.test/src/org/jacoco/core/internal/instr/InstrSupportTest.java
index f10fe6fb..1d8004a4 100644
--- a/org.jacoco.core.test/src/org/jacoco/core/internal/instr/InstrSupportTest.java
+++ b/org.jacoco.core.test/src/org/jacoco/core/internal/instr/InstrSupportTest.java
@@ -34,6 +34,21 @@ public class InstrSupportTest {
}
@Test
+ public void testAssertNotIntrumentedPositive() {
+ InstrSupport.assertNotInstrumented("run", "Foo");
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testAssertNotIntrumentedField() {
+ InstrSupport.assertNotInstrumented("$jacocoData", "Foo");
+ }
+
+ @Test(expected = IllegalStateException.class)
+ public void testAssertNotIntrumentedMethod() {
+ InstrSupport.assertNotInstrumented("$jacocoInit", "Foo");
+ }
+
+ @Test
public void testPushIntM2147483648() {
InstrSupport.push(trace, -2147483648);
assertInstruction("LDC -2147483648");