diff options
Diffstat (limited to 'org.jacoco.core.test/src/org/jacoco/core/test/validation/targets')
3 files changed, 447 insertions, 447 deletions
diff --git a/org.jacoco.core.test/src/org/jacoco/core/test/validation/targets/Stubs.java b/org.jacoco.core.test/src/org/jacoco/core/test/validation/targets/Stubs.java index 110664b5..15889173 100644 --- a/org.jacoco.core.test/src/org/jacoco/core/test/validation/targets/Stubs.java +++ b/org.jacoco.core.test/src/org/jacoco/core/test/validation/targets/Stubs.java @@ -1,107 +1,107 @@ -/*******************************************************************************
- * Copyright (c) 2009, 2012 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.targets;
-
-/**
- * Collection of stub methods that are called from the coverage targets. *
- */
-public class Stubs {
-
- /**
- * Exception stub.
- */
- public static class StubException extends RuntimeException {
-
- static final long serialVersionUID = 0L;
-
- }
-
- /**
- * Superclass stub.
- */
- public static class SuperClass {
-
- public SuperClass(boolean arg) {
- }
-
- }
-
- /**
- * Dummy method.
- */
- public static void nop() {
- }
-
- /**
- * Dummy method.
- */
- public static void nop(int i) {
- }
-
- /**
- * Dummy method.
- */
- public static void nop(boolean b) {
- }
-
- /**
- * Dummy method.
- */
- public static void nop(Object o) {
- }
-
- /**
- * @return always <code>true</code>
- */
- public static boolean t() {
- return true;
- }
-
- /**
- * @return always <code>false</code>
- */
- public static boolean f() {
- return false;
- }
-
- /**
- * @return always <code>1</code>
- */
- public static int i1() {
- return 1;
- }
-
- /**
- * @return always <code>3</code>
- */
- public static int i2() {
- return 2;
- }
-
- /**
- * @return always <code>3</code>
- */
- public static int i3() {
- return 3;
- }
-
- /**
- * Always throws a {@link RuntimeException}.
- *
- * @throws StubException
- * always thrown
- */
- public static void ex() throws StubException {
- throw new StubException();
- }
-
-}
+/******************************************************************************* + * Copyright (c) 2009, 2012 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.targets; + +/** + * Collection of stub methods that are called from the coverage targets. * + */ +public class Stubs { + + /** + * Exception stub. + */ + public static class StubException extends RuntimeException { + + static final long serialVersionUID = 0L; + + } + + /** + * Superclass stub. + */ + public static class SuperClass { + + public SuperClass(boolean arg) { + } + + } + + /** + * Dummy method. + */ + public static void nop() { + } + + /** + * Dummy method. + */ + public static void nop(int i) { + } + + /** + * Dummy method. + */ + public static void nop(boolean b) { + } + + /** + * Dummy method. + */ + public static void nop(Object o) { + } + + /** + * @return always <code>true</code> + */ + public static boolean t() { + return true; + } + + /** + * @return always <code>false</code> + */ + public static boolean f() { + return false; + } + + /** + * @return always <code>1</code> + */ + public static int i1() { + return 1; + } + + /** + * @return always <code>3</code> + */ + public static int i2() { + return 2; + } + + /** + * @return always <code>3</code> + */ + public static int i3() { + return 3; + } + + /** + * Always throws a {@link RuntimeException}. + * + * @throws StubException + * always thrown + */ + public static void ex() throws StubException { + throw new StubException(); + } + +} diff --git a/org.jacoco.core.test/src/org/jacoco/core/test/validation/targets/Target01.java b/org.jacoco.core.test/src/org/jacoco/core/test/validation/targets/Target01.java index f26b4805..4ad3e493 100644 --- a/org.jacoco.core.test/src/org/jacoco/core/test/validation/targets/Target01.java +++ b/org.jacoco.core.test/src/org/jacoco/core/test/validation/targets/Target01.java @@ -1,216 +1,216 @@ -/*******************************************************************************
- * Copyright (c) 2009, 2012 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.targets;
-
-import static org.jacoco.core.test.validation.targets.Stubs.f;
-import static org.jacoco.core.test.validation.targets.Stubs.i2;
-import static org.jacoco.core.test.validation.targets.Stubs.nop;
-import static org.jacoco.core.test.validation.targets.Stubs.t;
-
-import java.util.Collections;
-
-/**
- * This target exercises a set of common Java control structures.
- */
-public class Target01 implements Runnable {
-
- public void run() {
-
- // 1. Unconditional execution
- nop(); // $line-unconditional$
-
- // 2. Missed if block
- if (f()) { // $line-iffalse$
- nop(); // $line-missedif$
- } else {
- nop(); // $line-executedelse$
- }
-
- // 3. Executed if block
- if (t()) { // $line-iftrue$
- nop(); // $line-executedif$
- } else {
- nop(); // $line-missedelse$
- }
-
- // 4. Missed while block
- while (f()) { // $line-whilefalse$
- nop(); // $line-missedwhile$
- }
-
- // 5. Always executed while block
- while (t()) { // $line-whiletrue$
- if (t()) {
- break;
- }
- }
-
- // 6. Executed while block
- int i = 0;
- while (i++ < 3) { // $line-whiletruefalse$
- nop(); // $line-executedwhile$
- }
-
- // 7. Executed do while block
- do {
- nop(); // $line-executeddowhile$
- } while (f());
-
- // 8. Missed for block
- for (nop(); f(); nop()) { // $line-missedforincrementer$
- nop(); // $line-missedfor$
- }
-
- // 9. Executed for block
- for (int j = 0; j < 1; j++) { // $line-executedforincrementer$
- nop(); // $line-executedfor$
- }
-
- // 10. Missed for each block
- for (Object o : Collections.emptyList()) { // $line-missedforeachincrementer$
- nop(o); // $line-missedforeach$
- }
-
- // 11. Executed for each block
- for (Object o : Collections.singleton(new Object())) { // $line-executedforeachincrementer$
- nop(o); // $line-executedforeach$
- }
-
- // 12. Table switch with hit
- switch (i2()) { // $line-tswitch1$
- case 1:
- nop(); // $line-tswitch1case1$
- break;
- case 2:
- nop(); // $line-tswitch1case2$
- break;
- case 3:
- nop(); // $line-tswitch1case3$
- break;
- default:
- nop(); // $line-tswitch1default$
- break;
- }
-
- // 13. Continued table switch with hit
- switch (i2()) { // $line-tswitch2$
- case 1:
- nop(); // $line-tswitch2case1$
- case 2:
- nop(); // $line-tswitch2case2$
- case 3:
- nop(); // $line-tswitch2case3$
- default:
- nop(); // $line-tswitch2default$
- }
-
- // 14. Table switch without hit
- switch (i2()) { // $line-tswitch3$
- case 3:
- nop(); // $line-tswitch3case1$
- break;
- case 4:
- nop(); // $line-tswitch3case2$
- break;
- case 5:
- nop(); // $line-tswitch3case3$
- break;
- default:
- nop(); // $line-tswitch3default$
- break;
- }
-
- // 15. Lookup switch with hit
- switch (i2()) { // $line-lswitch1$
- case -123:
- nop(); // $line-lswitch1case1$
- break;
- case 2:
- nop(); // $line-lswitch1case2$
- break;
- case 456:
- nop(); // $line-lswitch1case3$
- break;
- default:
- nop(); // $line-lswitch1default$
- break;
- }
-
- // 16. Continued lookup switch with hit
- switch (i2()) { // $line-lswitch2$
- case -123:
- nop(); // $line-lswitch2case1$
- case 2:
- nop(); // $line-lswitch2case2$
- case 456:
- nop(); // $line-lswitch2case3$
- default:
- nop(); // $line-lswitch2default$
- }
-
- // 17. Lookup switch without hit
- switch (i2()) { // $line-lswitch3$
- case -123:
- nop(); // $line-lswitch3case1$
- break;
- case 456:
- nop(); // $line-lswitch3case2$
- break;
- case 789:
- nop(); // $line-lswitch3case3$
- break;
- default:
- nop(); // $line-lswitch3default$
- break;
- }
-
- // 18. Break statement
- while (true) {
- if (t()) {
- break; // $line-executedbreak$
- }
- nop(); // $line-missedafterbreak$
- }
-
- // 19. Continue statement
- for (int j = 0; j < 1; j++) {
- if (t()) {
- continue; // $line-executedcontinue$
- }
- nop(); // $line-missedaftercontinue$
- }
-
- runReturn();
- runImplicitReturn();
-
- }
-
- private void runReturn() {
-
- // 20. Return statement
- if (t()) {
- return; // $line-return$
- }
- nop(); // $line-afterreturn$
-
- }
-
- private void runImplicitReturn() {
-
- // 21. Implicit return
- } // $line-implicitreturn$
-
- public static void main(String[] args) {
- new Target01().run();
- }
-
-}
+/******************************************************************************* + * Copyright (c) 2009, 2012 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.targets; + +import static org.jacoco.core.test.validation.targets.Stubs.f; +import static org.jacoco.core.test.validation.targets.Stubs.i2; +import static org.jacoco.core.test.validation.targets.Stubs.nop; +import static org.jacoco.core.test.validation.targets.Stubs.t; + +import java.util.Collections; + +/** + * This target exercises a set of common Java control structures. + */ +public class Target01 implements Runnable { + + public void run() { + + // 1. Unconditional execution + nop(); // $line-unconditional$ + + // 2. Missed if block + if (f()) { // $line-iffalse$ + nop(); // $line-missedif$ + } else { + nop(); // $line-executedelse$ + } + + // 3. Executed if block + if (t()) { // $line-iftrue$ + nop(); // $line-executedif$ + } else { + nop(); // $line-missedelse$ + } + + // 4. Missed while block + while (f()) { // $line-whilefalse$ + nop(); // $line-missedwhile$ + } + + // 5. Always executed while block + while (t()) { // $line-whiletrue$ + if (t()) { + break; + } + } + + // 6. Executed while block + int i = 0; + while (i++ < 3) { // $line-whiletruefalse$ + nop(); // $line-executedwhile$ + } + + // 7. Executed do while block + do { + nop(); // $line-executeddowhile$ + } while (f()); + + // 8. Missed for block + for (nop(); f(); nop()) { // $line-missedforincrementer$ + nop(); // $line-missedfor$ + } + + // 9. Executed for block + for (int j = 0; j < 1; j++) { // $line-executedforincrementer$ + nop(); // $line-executedfor$ + } + + // 10. Missed for each block + for (Object o : Collections.emptyList()) { // $line-missedforeachincrementer$ + nop(o); // $line-missedforeach$ + } + + // 11. Executed for each block + for (Object o : Collections.singleton(new Object())) { // $line-executedforeachincrementer$ + nop(o); // $line-executedforeach$ + } + + // 12. Table switch with hit + switch (i2()) { // $line-tswitch1$ + case 1: + nop(); // $line-tswitch1case1$ + break; + case 2: + nop(); // $line-tswitch1case2$ + break; + case 3: + nop(); // $line-tswitch1case3$ + break; + default: + nop(); // $line-tswitch1default$ + break; + } + + // 13. Continued table switch with hit + switch (i2()) { // $line-tswitch2$ + case 1: + nop(); // $line-tswitch2case1$ + case 2: + nop(); // $line-tswitch2case2$ + case 3: + nop(); // $line-tswitch2case3$ + default: + nop(); // $line-tswitch2default$ + } + + // 14. Table switch without hit + switch (i2()) { // $line-tswitch3$ + case 3: + nop(); // $line-tswitch3case1$ + break; + case 4: + nop(); // $line-tswitch3case2$ + break; + case 5: + nop(); // $line-tswitch3case3$ + break; + default: + nop(); // $line-tswitch3default$ + break; + } + + // 15. Lookup switch with hit + switch (i2()) { // $line-lswitch1$ + case -123: + nop(); // $line-lswitch1case1$ + break; + case 2: + nop(); // $line-lswitch1case2$ + break; + case 456: + nop(); // $line-lswitch1case3$ + break; + default: + nop(); // $line-lswitch1default$ + break; + } + + // 16. Continued lookup switch with hit + switch (i2()) { // $line-lswitch2$ + case -123: + nop(); // $line-lswitch2case1$ + case 2: + nop(); // $line-lswitch2case2$ + case 456: + nop(); // $line-lswitch2case3$ + default: + nop(); // $line-lswitch2default$ + } + + // 17. Lookup switch without hit + switch (i2()) { // $line-lswitch3$ + case -123: + nop(); // $line-lswitch3case1$ + break; + case 456: + nop(); // $line-lswitch3case2$ + break; + case 789: + nop(); // $line-lswitch3case3$ + break; + default: + nop(); // $line-lswitch3default$ + break; + } + + // 18. Break statement + while (true) { + if (t()) { + break; // $line-executedbreak$ + } + nop(); // $line-missedafterbreak$ + } + + // 19. Continue statement + for (int j = 0; j < 1; j++) { + if (t()) { + continue; // $line-executedcontinue$ + } + nop(); // $line-missedaftercontinue$ + } + + runReturn(); + runImplicitReturn(); + + } + + private void runReturn() { + + // 20. Return statement + if (t()) { + return; // $line-return$ + } + nop(); // $line-afterreturn$ + + } + + private void runImplicitReturn() { + + // 21. Implicit return + } // $line-implicitreturn$ + + public static void main(String[] args) { + new Target01().run(); + } + +} diff --git a/org.jacoco.core.test/src/org/jacoco/core/test/validation/targets/Target02.java b/org.jacoco.core.test/src/org/jacoco/core/test/validation/targets/Target02.java index fb626b37..1725f4a5 100644 --- a/org.jacoco.core.test/src/org/jacoco/core/test/validation/targets/Target02.java +++ b/org.jacoco.core.test/src/org/jacoco/core/test/validation/targets/Target02.java @@ -1,124 +1,124 @@ -/*******************************************************************************
- * Copyright (c) 2009, 2012 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.targets;
-
-import static org.jacoco.core.test.validation.targets.Stubs.f;
-import static org.jacoco.core.test.validation.targets.Stubs.i1;
-import static org.jacoco.core.test.validation.targets.Stubs.i2;
-import static org.jacoco.core.test.validation.targets.Stubs.nop;
-import static org.jacoco.core.test.validation.targets.Stubs.t;
-
-/**
- * This target exercises boolean expressions.
- */
-public class Target02 implements Runnable {
-
- public void run() {
-
- // 1. Boolean comparison result (one case)
- nop(i2() > 3); // $line-booleancmp1$
-
- // 2. Boolean comparison result (both cases)
- for (int i = 0; i < 2; i++) {
- nop(i < 1); // $line-booleancmp2$
- }
-
- // 3. And
- if (f() & f()) { // $line-andFF$
- nop();
- }
- if (f() & t()) { // $line-andFT$
- nop();
- }
- if (t() & f()) { // $line-andTF$
- nop();
- }
- if (t() & t()) { // $line-andTT$
- nop();
- }
-
- // 4. Conditional And
- if (f() && f()) { // $line-conditionalandFF$
- nop();
- }
- if (f() && t()) { // $line-conditionalandFT$
- nop();
- }
- if (t() && f()) { // $line-conditionalandTF$
- nop();
- }
- if (t() && t()) { // $line-conditionalandTT$
- nop();
- }
-
- // 5. Or
- if (f() | f()) { // $line-orFF$
- nop();
- }
- if (f() | t()) { // $line-orFT$
- nop();
- }
- if (t() | f()) { // $line-orTF$
- nop();
- }
- if (t() | t()) { // $line-orTT$
- nop();
- }
-
- // 6. Conditional Or
- if (f() || f()) { // $line-conditionalorFF$
- nop();
- }
- if (f() || t()) { // $line-conditionalorFT$
- nop();
- }
- if (t() || f()) { // $line-conditionalorTF$
- nop();
- }
- if (t() || t()) { // $line-conditionalorTT$
- nop();
- }
-
- // 7. Exclusive Or
- if (f() ^ f()) { // $line-xorFF$
- nop();
- }
- if (f() ^ t()) { // $line-xorFT$
- nop();
- }
- if (t() ^ f()) { // $line-xorTF$
- nop();
- }
- if (t() ^ t()) { // $line-xorTT$
- nop();
- }
-
- // 8. Conditional Operator
- nop(t() ? i1() : i2()); // $line-condT$
- nop(f() ? i1() : i2()); // $line-condF$
-
- // 9. Not (one case)
- nop(!t()); // $line-notT$
- nop(!f()); // $line-notF$
-
- // 10. Not (both cases)
- for (boolean b : new boolean[] { true, false }) {
- nop(!b); // $line-notTF$
- }
-
- }
-
- public static void main(String[] args) {
- new Target02().run();
- }
-
-}
+/******************************************************************************* + * Copyright (c) 2009, 2012 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.targets; + +import static org.jacoco.core.test.validation.targets.Stubs.f; +import static org.jacoco.core.test.validation.targets.Stubs.i1; +import static org.jacoco.core.test.validation.targets.Stubs.i2; +import static org.jacoco.core.test.validation.targets.Stubs.nop; +import static org.jacoco.core.test.validation.targets.Stubs.t; + +/** + * This target exercises boolean expressions. + */ +public class Target02 implements Runnable { + + public void run() { + + // 1. Boolean comparison result (one case) + nop(i2() > 3); // $line-booleancmp1$ + + // 2. Boolean comparison result (both cases) + for (int i = 0; i < 2; i++) { + nop(i < 1); // $line-booleancmp2$ + } + + // 3. And + if (f() & f()) { // $line-andFF$ + nop(); + } + if (f() & t()) { // $line-andFT$ + nop(); + } + if (t() & f()) { // $line-andTF$ + nop(); + } + if (t() & t()) { // $line-andTT$ + nop(); + } + + // 4. Conditional And + if (f() && f()) { // $line-conditionalandFF$ + nop(); + } + if (f() && t()) { // $line-conditionalandFT$ + nop(); + } + if (t() && f()) { // $line-conditionalandTF$ + nop(); + } + if (t() && t()) { // $line-conditionalandTT$ + nop(); + } + + // 5. Or + if (f() | f()) { // $line-orFF$ + nop(); + } + if (f() | t()) { // $line-orFT$ + nop(); + } + if (t() | f()) { // $line-orTF$ + nop(); + } + if (t() | t()) { // $line-orTT$ + nop(); + } + + // 6. Conditional Or + if (f() || f()) { // $line-conditionalorFF$ + nop(); + } + if (f() || t()) { // $line-conditionalorFT$ + nop(); + } + if (t() || f()) { // $line-conditionalorTF$ + nop(); + } + if (t() || t()) { // $line-conditionalorTT$ + nop(); + } + + // 7. Exclusive Or + if (f() ^ f()) { // $line-xorFF$ + nop(); + } + if (f() ^ t()) { // $line-xorFT$ + nop(); + } + if (t() ^ f()) { // $line-xorTF$ + nop(); + } + if (t() ^ t()) { // $line-xorTT$ + nop(); + } + + // 8. Conditional Operator + nop(t() ? i1() : i2()); // $line-condT$ + nop(f() ? i1() : i2()); // $line-condF$ + + // 9. Not (one case) + nop(!t()); // $line-notT$ + nop(!f()); // $line-notF$ + + // 10. Not (both cases) + for (boolean b : new boolean[] { true, false }) { + nop(!b); // $line-notTF$ + } + + } + + public static void main(String[] args) { + new Target02().run(); + } + +} |