Skip to content

Commit 9d74656

Browse files
committed
Fix tests for paragraph tracking
1 parent 5026bc0 commit 9d74656

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

v2/parser/parse.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -392,14 +392,14 @@ func minimize(lines []string) []string {
392392
inDeprecated := false // paragraph tracking
393393
prevWasBlank := false
394394
for _, line := range lines {
395-
if inDeprecated {
396-
continue
397-
}
398395
if len(strings.TrimSpace(line)) == 0 {
399396
prevWasBlank = true
400397
inDeprecated = false
401398
continue
402399
}
400+
if inDeprecated {
401+
continue
402+
}
403403
if prevWasBlank && strings.HasPrefix(strings.TrimSpace(line), "Deprecated:") {
404404
prevWasBlank = false
405405
inDeprecated = true

v2/parser/parse_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,7 +1120,7 @@ func TestStructParse(t *testing.T) {
11201120
"k8s.io/gengo/v2/parser/testdata/type-alias/v2",
11211121
},
11221122
expected: func() *types.Type {
1123-
expectedTypeComments := []string{"Blah is a test.", "A test, I tell you."}
1123+
expectedTypeComments := []string{"Blah is a test.", "A test, I tell you.", "", "Another paragraph of comments."}
11241124
if !typeAliasEnabled {
11251125
// Comments from the last processed package wins.
11261126
expectedTypeComments = []string{"This is an alias for v1.Blah."}
@@ -1230,7 +1230,7 @@ func TestCommentsWithAliasedType(t *testing.T) {
12301230
continue
12311231
}
12321232

1233-
expectedTypeComments := []string{"Blah is a test.", "A test, I tell you."}
1233+
expectedTypeComments := []string{"Blah is a test.", "A test, I tell you.", "", "Another paragraph of comments."}
12341234
if !typeAliasEnabled {
12351235
// Comments from the last processed package wins.
12361236
expectedTypeComments = []string{"This is an alias for v1.Blah."}

v2/parser/testdata/type-alias/v1/file.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@ type LocalBlahAlias = Blah
66

77
// Blah is a test.
88
// A test, I tell you.
9+
//
10+
// Another paragraph of comments.
911
type Blah struct {
1012
// A is the first field.
1113
A int64 `json:"a"`
@@ -19,11 +21,15 @@ type Blah struct {
1921
// A test, I tell you.
2022
//
2123
// Deprecated: use Blah instead. This is another alias within the same package.
24+
//
25+
// Another paragraph of comments.
2226
type LocalBlahAliasDeprecated = Blah
2327

2428
// Blah is a test.
2529
// A test, I tell you.
2630
//
2731
// Deprecated: use Blah instead. This is a third alias within the same package.
2832
// It's a whole paragraph of deprecated notes
33+
//
34+
// Another paragraph of comments.
2935
type LocalBlahAliasDeprecatedLong = Blah

0 commit comments

Comments
 (0)