@@ -127,24 +127,24 @@ var tests = []test{
127127 `type T1 = T2` , // Type alias
128128 },
129129 []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.
148148 },
149149 },
150150 // Package dump -u
@@ -207,6 +207,18 @@ var tests = []test{
207207 },
208208 nil ,
209209 },
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+ },
210222 // Block of constants with carryover type from unexported field.
211223 {
212224 "block of constants with carryover type" ,
@@ -295,6 +307,17 @@ var tests = []test{
295307 },
296308 nil ,
297309 },
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+ },
298321
299322 // Type.
300323 {
@@ -304,21 +327,44 @@ var tests = []test{
304327 `Comment about exported type` , // Include comment.
305328 `type ExportedType struct` , // Type definition.
306329 `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` ,
309332 `Has unexported fields` ,
310333 `func \(ExportedType\) ExportedMethod\(a int\) bool` ,
311334 `const ExportedTypedConstant ExportedType = iota` , // Must include associated constant.
312335 `func ExportedTypeConstructor\(\) \*ExportedType` , // Must include constructor.
313- `io.Reader.*Comment on line with embedded Reader. ` ,
336+ `io.Reader.*Comment on line with embedded Reader` ,
314337 },
315338 []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.
322368 },
323369 },
324370 // Type T1 dump (alias).
@@ -341,14 +387,14 @@ var tests = []test{
341387 `Comment about exported type` , // Include comment.
342388 `type ExportedType struct` , // Type definition.
343389 `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` ,
352398 `func \(ExportedType\) unexportedMethod\(a int\) bool` ,
353399 `unexportedTypedConstant` ,
354400 },
@@ -380,8 +426,8 @@ var tests = []test{
380426 `type ExportedInterface interface` , // Interface definition.
381427 `Comment before exported method.*\n.*ExportedMethod\(\)` +
382428 `.*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` ,
385431 `Has unexported methods` ,
386432 },
387433 []string {
@@ -400,9 +446,9 @@ var tests = []test{
400446 `type ExportedInterface interface` , // Interface definition.
401447 `Comment before exported method.*\n.*ExportedMethod\(\)` +
402448 `.*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` ,
406452 },
407453 []string {
408454 `Has unexported methods` ,
@@ -418,7 +464,7 @@ var tests = []test{
418464 `.*Comment on line with exported method` ,
419465 },
420466 []string {
421- `Comment about exported interface. ` ,
467+ `Comment about exported interface` ,
422468 },
423469 },
424470
@@ -428,7 +474,7 @@ var tests = []test{
428474 []string {p , `ExportedType.ExportedMethod` },
429475 []string {
430476 `func \(ExportedType\) ExportedMethod\(a int\) bool` ,
431- `Comment about exported method. ` ,
477+ `Comment about exported method` ,
432478 },
433479 nil ,
434480 },
@@ -438,7 +484,18 @@ var tests = []test{
438484 []string {"-u" , p , `ExportedType.unexportedMethod` },
439485 []string {
440486 `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` ,
442499 },
443500 nil ,
444501 },
@@ -450,8 +507,8 @@ var tests = []test{
450507 []string {
451508 `type ExportedType struct` ,
452509 `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` ,
455512 `other fields elided` ,
456513 },
457514 nil ,
@@ -463,7 +520,7 @@ var tests = []test{
463520 []string {"-u" , p , `ExportedType.unexportedField` },
464521 []string {
465522 `unexportedField int` ,
466- `Comment on line with unexported field. ` ,
523+ `Comment on line with unexported field` ,
467524 },
468525 nil ,
469526 },
0 commit comments