Java cvprof Coverage Report for
MultiLineStatements.java

    1   
    2   package uk.co.badgersinfoil.cvprof.example;
    3   
    4   /**
    5    * When an expression-statement spans multiple lines, all generated bytecode
    6    * is typically attributed to the location of the statement's first line by
    7    * the Java compiler.  cvprof doesn't determine what lines of the source
    8    * file are indicated as 'executable', this is a product of the Java compiler's
    9    * implementation.
   10    */
   11   public class MultiLineStatements {
   12   	public void test() {
   13   		// method call with arguments spread over multiple lines
   14   		String a = "foo".substring(
   15   			0,
   16   			2
   17   		);
   18   
   19   		// for-loop
   20   		for (
   21   			// init,
   22   			int i
   23   				=
   24   					0
   25   						;
   26   			// test,
   27   			Math.abs(i)
   28   				<
   29   					10
   30   						;
   31   			// update,
   32   			i
   33   				++
   34   		    ); // empty statement as loop body
   35   
   36   		// conditional expression
   37   		int b = a.length()<2
   38   				? 5
   39   				: 6;
   40   
   41   		// conditional statement
   42   		if (
   43   			a.length()
   44   			==
   45   			b
   46   		   ); // empty statement as conditional body
   47   
   48   		switch
   49   		(
   50   			b
   51   		)
   52   		{
   53   			case 1:
   54 > 				break;
   55   			case 2:
   56 > 				break;
   57   			default: {
   58   					 break;
   59   				 }
   60   		}
   61   	}
   62   }