Skip to content

Commit

Permalink
Modify isNeededAccessLevelModifier result conditions (#128)
Browse files Browse the repository at this point in the history
  • Loading branch information
nnsnodnb authored Nov 14, 2023
1 parent 65b7259 commit 73b69bd
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 0 deletions.
1 change: 1 addition & 0 deletions Sources/CasePathsMacros/CasePathableMacro.swift
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ extension DeclModifierSyntax {
var isNeededAccessLevelModifier: Bool {
switch self.name.tokenKind {
case .keyword(.public): return true
case .keyword(.package): return true
default: return false
}
}
Expand Down
31 changes: 31 additions & 0 deletions Tests/CasePathsMacrosTests/CasePathableMacroTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,37 @@ final class CasePathableMacroTests: XCTestCase {
}
"""
}
assertMacro {
"""
@CasePathable package enum Foo {
case bar(Int)
}
"""
} expansion: {
"""
package enum Foo {
case bar(Int)
package struct AllCasePaths {
package var bar: CasePaths.AnyCasePath<Foo, Int> {
CasePaths.AnyCasePath<Foo, Int>(
embed: Foo.bar,
extract: {
guard case let .bar(v0) = $0 else {
return nil
}
return v0
}
)
}
}
package static var allCasePaths: AllCasePaths { AllCasePaths() }
}
extension Foo: CasePaths.CasePathable {
}
"""
}
assertMacro {
"""
@CasePathable private enum Foo {
Expand Down

0 comments on commit 73b69bd

Please sign in to comment.