...

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

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

View as plain text