cuelang.org/go@v0.13.0/cue/format/testdata/comments.txtar (about) 1 #simplify 2 3 -- empty.input -- 4 -- out/format/empty.golden -- 5 6 -- comments.input -- 7 // Package line 1 group 1 8 // Package line 2 group 1 9 10 // Package line 1 - group 2 11 // Package line 2 - group 2 12 package comments 13 14 // Emit line 1 group 1 15 16 // Emit line 1 group 2 17 // Emit line 2 group 2 18 { 19 // Inside Emit 20 } 21 22 a: 3 // a line comment 23 24 b: 4 // line comment that is last in the file. 25 cc: 555 // align comments 26 27 // don't simplify 28 a: { 29 b: 2 30 } 31 32 // simplify 33 a: { 34 b: c: { 35 d: 1 36 } 37 } 38 39 // unchanged 40 a: b: [1] 41 42 // don't simplify 43 a: b: { 44 c: 2 45 } 46 47 // rewrite okay 48 a: b: c: { 49 d: 2 50 } 51 52 m: { 53 } 54 m: { 55 // empty with comment 56 } 57 58 // Issue #478 59 struct1: { 60 // This is a comment 61 62 // This is a comment 63 64 // Another comment 65 66 something: { 67 } 68 // extra comment 69 } 70 71 struct2: { 72 // This is a comment 73 74 // This is a comment 75 76 // Another comment 77 something: { 78 } 79 80 // extra comment 81 } 82 83 list1: [ 84 // Comment1 85 86 // Comment2 87 88 // Another comment 89 { 90 }, 91 92 // Comment 3 93 ] 94 95 list2: [ 96 // foo 97 ] 98 99 list3: [ 100 // foo 101 102 // bar 103 ] 104 105 list4: [ 106 1, // number 107 a.b, // selector 108 (a), // paren 109 +1, // unary 110 a[0], // index 111 a[2:3], // slice 112 strings.Sort([1, 2]), // call 113 114 a.b, 115 // under selector 116 117 a.b, 118 // multiple 119 // under 120 121 // selector 122 ] 123 124 funcArg1: foo( 125 // Comment1 126 127 // Comment2 128 3 129 130 // Comment3 131 ) 132 133 funcArg2: foo( 134 // Comment1 135 136 // Comment2 137 138 3 139 // Comment3 140 ) 141 142 funcArg3: foo( 143 2, 144 145 // Comment1 146 147 // Comment2 148 3 149 150 // Comment3 151 ) 152 153 // comment including some tabs 154 155 156 // issue #2567 157 foo: [ 158 bar["baz"], //some comment 159 ] 160 161 [ 162 if true // inline comment 163 {}] 164 165 { 166 // comments 167 ... // surrounding 168 169 // an ellipsis 170 171 foo: { 172 // some 173 [string]: _ // comment 174 } 175 } 176 -- out/format/comments.golden -- 177 // Package line 1 group 1 178 // Package line 2 group 1 179 180 // Package line 1 - group 2 181 // Package line 2 - group 2 182 package comments 183 184 // Emit line 1 group 1 185 186 // Emit line 1 group 2 187 // Emit line 2 group 2 188 { 189 // Inside Emit 190 } 191 192 a: 3 // a line comment 193 194 b: 4 // line comment that is last in the file. 195 cc: 555 // align comments 196 197 // don't simplify 198 a: { 199 b: 2 200 } 201 202 // simplify 203 a: { 204 b: c: d: 1 205 } 206 207 // unchanged 208 a: b: [1] 209 210 // don't simplify 211 a: b: c: 2 212 213 // rewrite okay 214 a: b: c: d: 2 215 216 m: {} 217 m: { 218 // empty with comment 219 } 220 221 // Issue #478 222 struct1: { 223 // This is a comment 224 225 // This is a comment 226 227 // Another comment 228 229 something: {} 230 // extra comment 231 } 232 233 struct2: { 234 // This is a comment 235 236 // This is a comment 237 238 // Another comment 239 something: {} 240 241 // extra comment 242 } 243 244 list1: [ 245 // Comment1 246 247 // Comment2 248 249 // Another comment 250 {}, 251 252 // Comment 3 253 ] 254 255 list2: [ 256 // foo 257 ] 258 259 list3: [ 260 // foo 261 262 // bar 263 ] 264 265 list4: [ 266 1, // number 267 a.b, // selector 268 (a), // paren 269 +1, // unary 270 a[0], // index 271 a[2:3], // slice 272 strings.Sort([1, 2]), // call 273 274 a.b, 275 // under selector 276 277 a.b, 278 // multiple 279 // under 280 281 // selector 282 ] 283 284 funcArg1: foo( 285 // Comment1 286 287 // Comment2 288 3, 289 290 // Comment3 291 ) 292 293 funcArg2: foo( 294 // Comment1 295 296 // Comment2 297 298 3, 299 // Comment3 300 ) 301 302 funcArg3: foo( 303 2, 304 305 // Comment1 306 307 // Comment2 308 3, 309 310 // Comment3 311 ) 312 313 // comment including some tabs 314 315 // issue #2567 316 foo: [ 317 bar["baz"], //some comment 318 ] 319 320 [ 321 if true {}, // inline comment 322 ] 323 324 { 325 326 foo: { 327 // some 328 ... // comment 329 } 330 // comments 331 ... // surrounding 332 333 // an ellipsis 334 } 335 -- comment_alone.input -- 336 // Just one comment on its own. 337 -- out/format/comment_alone.golden -- 338 // Just one comment on its own. 339 -- comment_field.input -- 340 // Just one comment on a field. 341 foo: string 342 -- out/format/comment_field.golden -- 343 // Just one comment on a field. 344 foo: string 345 -- comments_alone.input -- 346 // Just a few comments 347 // on their own. 348 -- out/format/comments_alone.golden -- 349 // Just a few comments 350 // on their own. 351 -- comments_field.input -- 352 // Just a few comments 353 // on a field. 354 foo: string 355 -- out/format/comments_field.golden -- 356 // Just a few comments 357 // on a field. 358 foo: string