Source file src/cmd/cover/testdata/ranges/ranges.go

     1  package main
     2  
     3  import "fmt"
     4  
     5  func main() {
     6  «	fmt.Println("Start")
     7  	x := 42
     8  »
     9  	// This is a regular comment
    10  «	y := 0
    11  	fmt.Println("After comment")
    12  »
    13  	// Multiple comment lines
    14  	// fmt.Println("commented code")
    15  	// TODO: implement this later
    16  
    17  «	fmt.Println("After multiple comments")
    18  »
    19  	/* block comment */
    20  
    21  «	fmt.Println("After block comment")
    22  	z := 0
    23  »
    24  	«if x > 0 {»
    25  «		y = x * 2
    26  »	} else {
    27  «		y = x - 2
    28  »	}
    29  
    30  «	z = 5
    31  »
    32  	/* Multiline block
    33  	comment spanning
    34  	several lines */
    35  
    36  «	z1 := 0
    37  »
    38  «	z1 = 1 /* inline comment
    39  »	spanning lines
    40  «	end */ z1 = 2
    41  »
    42  «	z1 = 3; /* // */ z1 = 4
    43  »
    44  «	z1 = 5 /* //
    45  »	//
    46  «	// */ z1 = 6
    47  »
    48  	/*
    49  «	*/ z1 = 7 /*
    50  »	*/
    51  
    52  «	z1 = 8/*
    53  »	*/ /* comment
    54  «	*/z1 = 9
    55  »
    56  «	/* before */ z1 = 10
    57  	/* before */ z1 = 10 /* after */
    58  	             z1 = 10 /* after */
    59  »
    60  «	fmt.Printf("Result: %d\n", z)
    61  	fmt.Printf("Result: %d\n", z1)
    62  »
    63  «	s := `This is a multi-line raw string
    64  	// fake comment on line 2
    65  	/* and fake comment on line 3 */
    66  	and other`
    67  »
    68  «	s = `another multiline string
    69  	` // another trap
    70  »
    71  «	fmt.Printf("%s", s)
    72  »
    73  	// More comments to exclude
    74  	// for i := 0; i < 10; i++ {
    75  	//   fmt.Printf("Loop %d", i)
    76  	// }
    77  
    78  «	fmt.Printf("Result: %d\n", y)»
    79  	// end comment
    80  }
    81  
    82  func empty() {
    83  
    84  }
    85  
    86  func singleBlock() {
    87  «	fmt.Printf("ResultSomething")
    88  »}
    89  
    90  func justComment() {
    91  	// comment
    92  }
    93  
    94  func justMultilineComment() {
    95  	/* comment
    96  	again
    97  	until here */
    98  }
    99  
   100  func constBlock() {
   101  «	const (
   102  		A = 1
   103  
   104  		B = 2
   105  	)
   106  	fmt.Printf("A=%d B=%d", A, B)
   107  »}
   108  
   109  func compositeLit() {
   110  «	m := map[string]int{
   111  		"a": 1,
   112  »	}
   113  «	fmt.Println(m)
   114  »}
   115  

View as plain text