github.com/AndrienkoAleksandr/go@v0.0.19/src/go/printer/testdata/comments2.golden (about)

     1  // Copyright 2012 The Go Authors. All rights reserved.
     2  // Use of this source code is governed by a BSD-style
     3  // license that can be found in the LICENSE file.
     4  
     5  // This is a package for testing comment placement by go/printer.
     6  package main
     7  
     8  // Test cases for idempotent comment formatting (was issue 1835).
     9  /*
    10  c1a
    11  */
    12  /*
    13     c1b
    14  */
    15  /* foo
    16  c1c
    17  */
    18  /* foo
    19     c1d
    20  */
    21  /*
    22  c1e
    23  foo */
    24  /*
    25     c1f
    26     foo */
    27  
    28  func f() {
    29  	/*
    30  	   c2a
    31  	*/
    32  	/*
    33  	   c2b
    34  	*/
    35  	/* foo
    36  	   c2c
    37  	*/
    38  	/* foo
    39  	   c2d
    40  	*/
    41  	/*
    42  	   c2e
    43  	   foo */
    44  	/*
    45  	   c2f
    46  	   foo */
    47  }
    48  
    49  func g() {
    50  	/*
    51  	   c3a
    52  	*/
    53  	/*
    54  	   c3b
    55  	*/
    56  	/* foo
    57  	   c3c
    58  	*/
    59  	/* foo
    60  	   c3d
    61  	*/
    62  	/*
    63  	   c3e
    64  	   foo */
    65  	/*
    66  	   c3f
    67  	   foo */
    68  }
    69  
    70  // Test case taken literally from issue 1835.
    71  func main() {
    72  	/*
    73  	   prints test 5 times
    74  	*/
    75  	for i := 0; i < 5; i++ {
    76  		println("test")
    77  	}
    78  }
    79  
    80  func issue5623() {
    81  L:
    82  	_ = yyyyyyyyyyyyyyyy			// comment - should be aligned
    83  	_ = xxxxxxxxxxxxxxxxxxxxxxxxxxxx	/* comment */
    84  
    85  	_ = yyyyyyyyyyyyyyyy			/* comment - should be aligned */
    86  	_ = xxxxxxxxxxxxxxxxxxxxxxxxxxxx	// comment
    87  
    88  LLLLLLL:
    89  	_ = yyyyyyyyyyyyyyyy			// comment - should be aligned
    90  	_ = xxxxxxxxxxxxxxxxxxxxxxxxxxxx	// comment
    91  
    92  LL:
    93  LLLLL:
    94  	_ = xxxxxxxxxxxxxxxxxxxxxxxxxxxx	/* comment */
    95  	_ = yyyyyyyyyyyyyyyy			/* comment - should be aligned */
    96  
    97  	_ = xxxxxxxxxxxxxxxxxxxxxxxxxxxx	// comment
    98  	_ = yyyyyyyyyyyyyyyy			// comment - should be aligned
    99  
   100  	// test case from issue
   101  label:
   102  	mask := uint64(1)<<c - 1		// Allocation mask
   103  	used := atomic.LoadUint64(&h.used)	// Current allocations
   104  }
   105  
   106  // Test cases for issue 18782
   107  var _ = [][]int{
   108  	/*       a, b, c, d, e */
   109  	/* a */ {0, 0, 0, 0, 0},
   110  	/* b */ {0, 5, 4, 4, 4},
   111  	/* c */ {0, 4, 5, 4, 4},
   112  	/* d */ {0, 4, 4, 5, 4},
   113  	/* e */ {0, 4, 4, 4, 5},
   114  }
   115  
   116  var _ = T{ /* a */ 0}
   117  
   118  var _ = T{ /* a */ /* b */ 0}
   119  
   120  var _ = T{	/* a */	/* b */
   121  	/* c */ 0,
   122  }
   123  
   124  var _ = T{	/* a */	/* b */
   125  	/* c */
   126  	/* d */ 0,
   127  }
   128  
   129  var _ = T{
   130  	/* a */
   131  	/* b */ 0,
   132  }
   133  
   134  var _ = T{ /* a */ {}}
   135  
   136  var _ = T{ /* a */ /* b */ {}}
   137  
   138  var _ = T{	/* a */	/* b */
   139  	/* c */ {},
   140  }
   141  
   142  var _ = T{	/* a */	/* b */
   143  	/* c */
   144  	/* d */ {},
   145  }
   146  
   147  var _ = T{
   148  	/* a */
   149  	/* b */ {},
   150  }
   151  
   152  var _ = []T{
   153  	func() {
   154  		var _ = [][]int{
   155  			/*       a, b, c, d, e */
   156  			/* a */ {0, 0, 0, 0, 0},
   157  			/* b */ {0, 5, 4, 4, 4},
   158  			/* c */ {0, 4, 5, 4, 4},
   159  			/* d */ {0, 4, 4, 5, 4},
   160  			/* e */ {0, 4, 4, 4, 5},
   161  		}
   162  	},
   163  }