Skip to content

Commit 3c6184a

Browse files
committed
Adding tests
1 parent a1f0f93 commit 3c6184a

17 files changed

+204
-87
lines changed

Package.resolved

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Sources/PublicModules/PADSwiftInterfaceDiff/SwiftInterfaceParser/SwiftInterfaceElement+Declaration/SwiftInterfaceElement+Actor.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,12 @@ private extension SwiftInterfaceActor {
7979

8080
func compileDescription(incl tokens: Set<SwiftInterfaceElementDescriptionToken>) -> String {
8181
var description = ""
82-
if tokens.contains(.attributes) {
83-
description.append(attributes.joined(separator: "\n"), with: "")
84-
}
85-
if tokens.contains(.modifiers) {
86-
description.append(modifiers.joined(separator: " "), with: "\n")
87-
}
82+
var modifiers = modifiers
83+
if !tokens.contains(.modifiers) { modifiers = [] }
84+
var attributes = attributes
85+
if !tokens.contains(.attributes) { attributes = [] }
86+
description.append(attributes.joined(separator: "\n"), with: "")
87+
description.append(modifiers.joined(separator: " "), with: "\n")
8888
if modifiers.isEmpty && !attributes.isEmpty { description.append("\n") }
8989
description.append("actor", with: modifiers.isEmpty ? "" : " ")
9090
description.append(name, with: " ")

Sources/PublicModules/PADSwiftInterfaceDiff/SwiftInterfaceParser/SwiftInterfaceElement+Declaration/SwiftInterfaceElement+AssociatedType.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -76,12 +76,12 @@ private extension SwiftInterfaceAssociatedType {
7676

7777
func compileDescription(incl tokens: Set<SwiftInterfaceElementDescriptionToken>) -> String {
7878
var description = ""
79-
if tokens.contains(.attributes) {
80-
description.append(attributes.joined(separator: "\n"), with: "")
81-
}
82-
if tokens.contains(.modifiers) {
83-
description.append(modifiers.joined(separator: " "), with: "\n")
84-
}
79+
var modifiers = modifiers
80+
if !tokens.contains(.modifiers) { modifiers = [] }
81+
var attributes = attributes
82+
if !tokens.contains(.attributes) { attributes = [] }
83+
description.append(attributes.joined(separator: "\n"), with: "")
84+
description.append(modifiers.joined(separator: " "), with: "\n")
8585
if modifiers.isEmpty && !attributes.isEmpty { description.append("\n") }
8686
description.append("associatedtype", with: modifiers.isEmpty ? "" : " ")
8787
description.append(name, with: " ")

Sources/PublicModules/PADSwiftInterfaceDiff/SwiftInterfaceParser/SwiftInterfaceElement+Declaration/SwiftInterfaceElement+Class.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,12 @@ private extension SwiftInterfaceClass {
7979

8080
func compileDescription(incl tokens: Set<SwiftInterfaceElementDescriptionToken>) -> String {
8181
var description = ""
82-
if tokens.contains(.attributes) {
83-
description.append(attributes.joined(separator: "\n"), with: "")
84-
}
85-
if tokens.contains(.modifiers) {
86-
description.append(modifiers.joined(separator: " "), with: "\n")
87-
}
82+
var modifiers = modifiers
83+
if !tokens.contains(.modifiers) { modifiers = [] }
84+
var attributes = attributes
85+
if !tokens.contains(.attributes) { attributes = [] }
86+
description.append(attributes.joined(separator: "\n"), with: "")
87+
description.append(modifiers.joined(separator: " "), with: "\n")
8888
if modifiers.isEmpty && !attributes.isEmpty { description.append("\n") }
8989
description.append("class", with: modifiers.isEmpty ? "" : " ")
9090
description.append(name, with: " ")

Sources/PublicModules/PADSwiftInterfaceDiff/SwiftInterfaceParser/SwiftInterfaceElement+Declaration/SwiftInterfaceElement+Enum.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,12 @@ private extension SwiftInterfaceEnum {
7777

7878
func compileDescription(incl tokens: Set<SwiftInterfaceElementDescriptionToken>) -> String {
7979
var description = ""
80-
if tokens.contains(.attributes) {
81-
description.append(attributes.joined(separator: "\n"), with: "")
82-
}
83-
if tokens.contains(.modifiers) {
84-
description.append(modifiers.joined(separator: " "), with: "\n")
85-
}
80+
var modifiers = modifiers
81+
if !tokens.contains(.modifiers) { modifiers = [] }
82+
var attributes = attributes
83+
if !tokens.contains(.attributes) { attributes = [] }
84+
description.append(attributes.joined(separator: "\n"), with: "")
85+
description.append(modifiers.joined(separator: " "), with: "\n")
8686
if modifiers.isEmpty && !attributes.isEmpty { description.append("\n") }
8787
description.append("enum", with: modifiers.isEmpty ? "" : " ")
8888
description.append(name, with: " ")

Sources/PublicModules/PADSwiftInterfaceDiff/SwiftInterfaceParser/SwiftInterfaceElement+Declaration/SwiftInterfaceElement+EnumCase.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,12 @@ private extension SwiftInterfaceEnumCase {
105105

106106
func compileDescription(incl tokens: Set<SwiftInterfaceElementDescriptionToken>) -> String {
107107
var description = ""
108-
if tokens.contains(.attributes) {
109-
description.append(attributes.joined(separator: "\n"), with: "")
110-
}
111-
if tokens.contains(.modifiers) {
112-
description.append(modifiers.joined(separator: " "), with: "\n")
113-
}
108+
var modifiers = modifiers
109+
if !tokens.contains(.modifiers) { modifiers = [] }
110+
var attributes = attributes
111+
if !tokens.contains(.attributes) { attributes = [] }
112+
description.append(attributes.joined(separator: "\n"), with: "")
113+
description.append(modifiers.joined(separator: " "), with: "\n")
114114
if modifiers.isEmpty && !attributes.isEmpty { description.append("\n") }
115115
description.append("case", with: modifiers.isEmpty ? "" : " ")
116116
description.append(name, with: " ")

Sources/PublicModules/PADSwiftInterfaceDiff/SwiftInterfaceParser/SwiftInterfaceElement+Declaration/SwiftInterfaceElement+Extension.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,12 +72,12 @@ private extension SwiftInterfaceExtension {
7272

7373
func compileDescription(incl tokens: Set<SwiftInterfaceElementDescriptionToken>) -> String {
7474
var description = ""
75-
if tokens.contains(.attributes) {
76-
description.append(attributes.joined(separator: "\n"), with: "")
77-
}
78-
if tokens.contains(.modifiers) {
79-
description.append(modifiers.joined(separator: " "), with: "\n")
80-
}
75+
var modifiers = modifiers
76+
if !tokens.contains(.modifiers) { modifiers = [] }
77+
var attributes = attributes
78+
if !tokens.contains(.attributes) { attributes = [] }
79+
description.append(attributes.joined(separator: "\n"), with: "")
80+
description.append(modifiers.joined(separator: " "), with: "\n")
8181
if modifiers.isEmpty && !attributes.isEmpty { description.append("\n") }
8282
description.append("extension", with: modifiers.isEmpty ? "" : " ")
8383
description.append(extendedType, with: " ")

Sources/PublicModules/PADSwiftInterfaceDiff/SwiftInterfaceParser/SwiftInterfaceElement+Declaration/SwiftInterfaceElement+Function.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -130,12 +130,12 @@ private extension SwiftInterfaceFunction {
130130

131131
func compileDescription(incl tokens: Set<SwiftInterfaceElementDescriptionToken>) -> String {
132132
var description = ""
133-
if tokens.contains(.attributes) {
134-
description.append(attributes.joined(separator: "\n"), with: "")
135-
}
136-
if tokens.contains(.modifiers) {
137-
description.append(modifiers.joined(separator: " "), with: "\n")
138-
}
133+
var modifiers = modifiers
134+
if !tokens.contains(.modifiers) { modifiers = [] }
135+
var attributes = attributes
136+
if !tokens.contains(.attributes) { attributes = [] }
137+
description.append(attributes.joined(separator: "\n"), with: "")
138+
description.append(modifiers.joined(separator: " "), with: "\n")
139139
if modifiers.isEmpty && !attributes.isEmpty { description.append("\n") }
140140
description.append("func", with: modifiers.isEmpty ? "" : " ")
141141
description.append(name, with: " ")

Sources/PublicModules/PADSwiftInterfaceDiff/SwiftInterfaceParser/SwiftInterfaceElement+Declaration/SwiftInterfaceElement+Initializer.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,12 +87,12 @@ private extension SwiftInterfaceInitializer {
8787

8888
func compileDescription(incl tokens: Set<SwiftInterfaceElementDescriptionToken>) -> String {
8989
var description = ""
90-
if tokens.contains(.attributes) {
91-
description.append(attributes.joined(separator: "\n"), with: "")
92-
}
93-
if tokens.contains(.modifiers) {
94-
description.append(modifiers.joined(separator: " "), with: "\n")
95-
}
90+
var modifiers = modifiers
91+
if !tokens.contains(.modifiers) { modifiers = [] }
92+
var attributes = attributes
93+
if !tokens.contains(.attributes) { attributes = [] }
94+
description.append(attributes.joined(separator: "\n"), with: "")
95+
description.append(modifiers.joined(separator: " "), with: "\n")
9696
if modifiers.isEmpty && !attributes.isEmpty { description.append("\n") }
9797
description.append("init", with: modifiers.isEmpty ? "" : " ")
9898
description.append(optionalMark, with: "")

Sources/PublicModules/PADSwiftInterfaceDiff/SwiftInterfaceParser/SwiftInterfaceElement+Declaration/SwiftInterfaceElement+Protocol.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,12 +77,12 @@ private extension SwiftInterfaceProtocol {
7777

7878
func compileDescription(incl tokens: Set<SwiftInterfaceElementDescriptionToken>) -> String {
7979
var description = ""
80-
if tokens.contains(.attributes) {
81-
description.append(attributes.joined(separator: "\n"), with: "")
82-
}
83-
if tokens.contains(.modifiers) {
84-
description.append(modifiers.joined(separator: " "), with: "\n")
85-
}
80+
var modifiers = modifiers
81+
if !tokens.contains(.modifiers) { modifiers = [] }
82+
var attributes = attributes
83+
if !tokens.contains(.attributes) { attributes = [] }
84+
description.append(attributes.joined(separator: "\n"), with: "")
85+
description.append(modifiers.joined(separator: " "), with: "\n")
8686
if modifiers.isEmpty && !attributes.isEmpty { description.append("\n") }
8787
description.append("protocol", with: modifiers.isEmpty ? "" : " ")
8888
description.append(name, with: " ")

0 commit comments

Comments
 (0)