@@ -127,24 +127,24 @@ var tests = []test{
127
127
`type T1 = T2` , // Type alias
128
128
},
129
129
[]string {
130
- `const internalConstant = 2` , // No internal constants.
131
- `var internalVariable = 2` , // No internal variables.
132
- `func internalFunc(a int) bool` , // No internal functions.
133
- `Comment about exported constant` , // No comment for single constant.
134
- `Comment about exported variable` , // No comment for single variable.
135
- `Comment about block of constants. ` , // No comment for constant block.
136
- `Comment about block of variables. ` , // No comment for variable block.
137
- `Comment before ConstOne` , // No comment for first entry in constant block.
138
- `Comment before VarOne` , // No comment for first entry in variable block.
139
- `ConstTwo = 2` , // No second entry in constant block.
140
- `VarTwo = 2` , // No second entry in variable block.
141
- `VarFive = 5` , // From block starting with unexported variable.
142
- `type unexportedType` , // No unexported type.
143
- `unexportedTypedConstant` , // No unexported typed constant.
144
- `\bField` , // No fields.
145
- `Method` , // No methods.
146
- `someArgument[5-8]` , // No truncated arguments.
147
- `type T1 T2` , // Type alias does not display as type declaration.
130
+ `const internalConstant = 2` , // No internal constants.
131
+ `var internalVariable = 2` , // No internal variables.
132
+ `func internalFunc(a int) bool` , // No internal functions.
133
+ `Comment about exported constant` , // No comment for single constant.
134
+ `Comment about exported variable` , // No comment for single variable.
135
+ `Comment about block of constants` , // No comment for constant block.
136
+ `Comment about block of variables` , // No comment for variable block.
137
+ `Comment before ConstOne` , // No comment for first entry in constant block.
138
+ `Comment before VarOne` , // No comment for first entry in variable block.
139
+ `ConstTwo = 2` , // No second entry in constant block.
140
+ `VarTwo = 2` , // No second entry in variable block.
141
+ `VarFive = 5` , // From block starting with unexported variable.
142
+ `type unexportedType` , // No unexported type.
143
+ `unexportedTypedConstant` , // No unexported typed constant.
144
+ `\bField` , // No fields.
145
+ `Method` , // No methods.
146
+ `someArgument[5-8]` , // No truncated arguments.
147
+ `type T1 T2` , // Type alias does not display as type declaration.
148
148
},
149
149
},
150
150
// Package dump -u
@@ -207,6 +207,18 @@ var tests = []test{
207
207
},
208
208
nil ,
209
209
},
210
+ // Block of constants -src.
211
+ {
212
+ "block of constants with -src" ,
213
+ []string {"-src" , p , `ConstTwo` },
214
+ []string {
215
+ `Comment about block of constants` , // Top comment.
216
+ `ConstOne.*=.*1` , // Each constant seen.
217
+ `ConstTwo.*=.*2.*Comment on line with ConstTwo` ,
218
+ `constThree` , // Even unexported constants.
219
+ },
220
+ nil ,
221
+ },
210
222
// Block of constants with carryover type from unexported field.
211
223
{
212
224
"block of constants with carryover type" ,
@@ -295,6 +307,17 @@ var tests = []test{
295
307
},
296
308
nil ,
297
309
},
310
+ // Function with -src.
311
+ {
312
+ "function with -src" ,
313
+ []string {"-src" , p , `ExportedFunc` },
314
+ []string {
315
+ `Comment about exported function` , // Include comment.
316
+ `func ExportedFunc\(a int\) bool` ,
317
+ `return true != false` , // Include body.
318
+ },
319
+ nil ,
320
+ },
298
321
299
322
// Type.
300
323
{
@@ -304,21 +327,44 @@ var tests = []test{
304
327
`Comment about exported type` , // Include comment.
305
328
`type ExportedType struct` , // Type definition.
306
329
`Comment before exported field.*\n.*ExportedField +int` +
307
- `.*Comment on line with exported field. ` ,
308
- `ExportedEmbeddedType.*Comment on line with exported embedded field. ` ,
330
+ `.*Comment on line with exported field` ,
331
+ `ExportedEmbeddedType.*Comment on line with exported embedded field` ,
309
332
`Has unexported fields` ,
310
333
`func \(ExportedType\) ExportedMethod\(a int\) bool` ,
311
334
`const ExportedTypedConstant ExportedType = iota` , // Must include associated constant.
312
335
`func ExportedTypeConstructor\(\) \*ExportedType` , // Must include constructor.
313
- `io.Reader.*Comment on line with embedded Reader. ` ,
336
+ `io.Reader.*Comment on line with embedded Reader` ,
314
337
},
315
338
[]string {
316
- `unexportedField` , // No unexported field.
317
- `int.*embedded` , // No unexported embedded field.
318
- `Comment about exported method.` , // No comment about exported method.
319
- `unexportedMethod` , // No unexported method.
320
- `unexportedTypedConstant` , // No unexported constant.
321
- `error` , // No embedded error.
339
+ `unexportedField` , // No unexported field.
340
+ `int.*embedded` , // No unexported embedded field.
341
+ `Comment about exported method` , // No comment about exported method.
342
+ `unexportedMethod` , // No unexported method.
343
+ `unexportedTypedConstant` , // No unexported constant.
344
+ `error` , // No embedded error.
345
+ },
346
+ },
347
+ // Type with -src. Will see unexported fields.
348
+ {
349
+ "type" ,
350
+ []string {"-src" , p , `ExportedType` },
351
+ []string {
352
+ `Comment about exported type` , // Include comment.
353
+ `type ExportedType struct` , // Type definition.
354
+ `Comment before exported field.*\n.*ExportedField +int` +
355
+ `.*Comment on line with exported field` ,
356
+ `ExportedEmbeddedType.*Comment on line with exported embedded field` ,
357
+ `unexportedType.*Comment on line with unexported embedded field` ,
358
+ `func \(ExportedType\) ExportedMethod\(a int\) bool` ,
359
+ `const ExportedTypedConstant ExportedType = iota` , // Must include associated constant.
360
+ `func ExportedTypeConstructor\(\) \*ExportedType` , // Must include constructor.
361
+ `io.Reader.*Comment on line with embedded Reader` ,
362
+ },
363
+ []string {
364
+ `int.*embedded` , // No unexported embedded field.
365
+ `Comment about exported method` , // No comment about exported method.
366
+ `unexportedMethod` , // No unexported method.
367
+ `unexportedTypedConstant` , // No unexported constant.
322
368
},
323
369
},
324
370
// Type T1 dump (alias).
@@ -341,14 +387,14 @@ var tests = []test{
341
387
`Comment about exported type` , // Include comment.
342
388
`type ExportedType struct` , // Type definition.
343
389
`Comment before exported field.*\n.*ExportedField +int` ,
344
- `unexportedField.*int.*Comment on line with unexported field. ` ,
345
- `ExportedEmbeddedType.*Comment on line with exported embedded field. ` ,
346
- `\*ExportedEmbeddedType.*Comment on line with exported embedded \*field. ` ,
347
- `\*qualified.ExportedEmbeddedType.*Comment on line with exported embedded \*selector.field. ` ,
348
- `unexportedType.*Comment on line with unexported embedded field. ` ,
349
- `\*unexportedType.*Comment on line with unexported embedded \*field. ` ,
350
- `io.Reader.*Comment on line with embedded Reader. ` ,
351
- `error.*Comment on line with embedded error. ` ,
390
+ `unexportedField.*int.*Comment on line with unexported field` ,
391
+ `ExportedEmbeddedType.*Comment on line with exported embedded field` ,
392
+ `\*ExportedEmbeddedType.*Comment on line with exported embedded \*field` ,
393
+ `\*qualified.ExportedEmbeddedType.*Comment on line with exported embedded \*selector.field` ,
394
+ `unexportedType.*Comment on line with unexported embedded field` ,
395
+ `\*unexportedType.*Comment on line with unexported embedded \*field` ,
396
+ `io.Reader.*Comment on line with embedded Reader` ,
397
+ `error.*Comment on line with embedded error` ,
352
398
`func \(ExportedType\) unexportedMethod\(a int\) bool` ,
353
399
`unexportedTypedConstant` ,
354
400
},
@@ -380,8 +426,8 @@ var tests = []test{
380
426
`type ExportedInterface interface` , // Interface definition.
381
427
`Comment before exported method.*\n.*ExportedMethod\(\)` +
382
428
`.*Comment on line with exported method` ,
383
- `io.Reader.*Comment on line with embedded Reader. ` ,
384
- `error.*Comment on line with embedded error. ` ,
429
+ `io.Reader.*Comment on line with embedded Reader` ,
430
+ `error.*Comment on line with embedded error` ,
385
431
`Has unexported methods` ,
386
432
},
387
433
[]string {
@@ -400,9 +446,9 @@ var tests = []test{
400
446
`type ExportedInterface interface` , // Interface definition.
401
447
`Comment before exported method.*\n.*ExportedMethod\(\)` +
402
448
`.*Comment on line with exported method` ,
403
- `unexportedMethod\(\).*Comment on line with unexported method. ` ,
404
- `io.Reader.*Comment on line with embedded Reader. ` ,
405
- `error.*Comment on line with embedded error. ` ,
449
+ `unexportedMethod\(\).*Comment on line with unexported method` ,
450
+ `io.Reader.*Comment on line with embedded Reader` ,
451
+ `error.*Comment on line with embedded error` ,
406
452
},
407
453
[]string {
408
454
`Has unexported methods` ,
@@ -418,7 +464,7 @@ var tests = []test{
418
464
`.*Comment on line with exported method` ,
419
465
},
420
466
[]string {
421
- `Comment about exported interface. ` ,
467
+ `Comment about exported interface` ,
422
468
},
423
469
},
424
470
@@ -428,7 +474,7 @@ var tests = []test{
428
474
[]string {p , `ExportedType.ExportedMethod` },
429
475
[]string {
430
476
`func \(ExportedType\) ExportedMethod\(a int\) bool` ,
431
- `Comment about exported method. ` ,
477
+ `Comment about exported method` ,
432
478
},
433
479
nil ,
434
480
},
@@ -438,7 +484,18 @@ var tests = []test{
438
484
[]string {"-u" , p , `ExportedType.unexportedMethod` },
439
485
[]string {
440
486
`func \(ExportedType\) unexportedMethod\(a int\) bool` ,
441
- `Comment about unexported method.` ,
487
+ `Comment about unexported method` ,
488
+ },
489
+ nil ,
490
+ },
491
+ // Method with -src.
492
+ {
493
+ "method with -src" ,
494
+ []string {"-src" , p , `ExportedType.ExportedMethod` },
495
+ []string {
496
+ `func \(ExportedType\) ExportedMethod\(a int\) bool` ,
497
+ `Comment about exported method` ,
498
+ `return true != true` ,
442
499
},
443
500
nil ,
444
501
},
@@ -450,8 +507,8 @@ var tests = []test{
450
507
[]string {
451
508
`type ExportedType struct` ,
452
509
`ExportedField int` ,
453
- `Comment before exported field. ` ,
454
- `Comment on line with exported field. ` ,
510
+ `Comment before exported field` ,
511
+ `Comment on line with exported field` ,
455
512
`other fields elided` ,
456
513
},
457
514
nil ,
@@ -463,7 +520,7 @@ var tests = []test{
463
520
[]string {"-u" , p , `ExportedType.unexportedField` },
464
521
[]string {
465
522
`unexportedField int` ,
466
- `Comment on line with unexported field. ` ,
523
+ `Comment on line with unexported field` ,
467
524
},
468
525
nil ,
469
526
},
0 commit comments