...
Run Format

Text file src/go/printer/testdata/comments2.golden

Documentation: go/printer/testdata

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

View as plain text