Skip to content

Commit

Permalink
The tests pass!
Browse files Browse the repository at this point in the history
  • Loading branch information
griotspeak committed Nov 2, 2024
1 parent be0da33 commit 40aade2
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 43 deletions.
6 changes: 3 additions & 3 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"originHash" : "99d91c19240d69188427b3369e2f8d6c77ff744ee6fe9da52573b26817d1b336",
"originHash" : "d502d5b1730deb4397dbba44a7ed003c144b2d5d06e71af6927884bf8afe429d",
"pins" : [
{
"identity" : "swift-syntax",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-syntax.git",
"state" : {
"revision" : "4c6cc0a3b9e8f14b3ae2307c5ccae4de6167ac2c",
"version" : "600.0.0-prerelease-2024-06-12"
"revision" : "91444aa84639349d8a02304b24cca598500b4466",
"version" : "601.0.0-prerelease-2024-10-30"
}
}
],
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ let package = Package(
// Depend on the Swift 5.9 release of SwiftSyntax
.package(
url: "https://github.com/apple/swift-syntax.git",
from: "600.0.0-latest"
from: "601.0.0-prerelease-2024-10-09"
),
],
targets: [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ extension DiscriminatedUnionMacro: MemberMacro {
try EnumDeclSyntax("public enum Discriminant: DiscriminantType") {
for singleCase in childCases {
EnumCaseDeclSyntax(
leadingTrivia: .carriageReturn) {
leadingTrivia: .newline) {
EnumCaseElementSyntax(
leadingTrivia: .space,
name: singleCase.name)
Expand All @@ -88,9 +88,9 @@ extension DiscriminatedUnionMacro: MemberMacro {
return "case .\(singleCase.name): \(singleCase.parameterClause != nil) // \(String(describing: myTrivia))"
}
let theSwitch = """
switch self {
\(theCases.joined(separator: "\n"))
}
switch self {
\(theCases.joined(separator: "\n"))
}
"""
return DeclSyntax(stringLiteral:"""
Expand Down
70 changes: 35 additions & 35 deletions Tests/DiscriminatedUnionTests/DiscriminatedUnionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,53 +19,53 @@ final class DiscriminatedUnionTests: XCTestCase {
"""
@discriminatedUnion
enum Pet {
case dog
case cat(curious: Bool)
case parrot
case snake
case dog
case cat(curious: Bool)
case parrot
case snake
}
""",

expandedSource:
"""
enum Pet {
case dog
case cat(curious: Bool)
case parrot
case snake
case dog
case cat(curious: Bool)
case parrot
case snake
public enum Discriminant: DiscriminantType {
case dog
case cat
case parrot
case snake
case dog
case cat
case parrot
case snake
public var hasAssociatedType: Bool {
switch self {
case .dog:
false // nil
case .cat:
true // Optional("curious: Bool")
case .parrot:
false // nil
case .snake:
false // nil
}
public var hasAssociatedType: Bool {
switch self {
case .dog:
false // nil
case .cat:
true // Optional("curious: Bool")
case .parrot:
false // nil
case .snake:
false // nil
}
}
}
}
public var discriminant: Discriminant {
switch self {
case .dog:
return .dog
case .cat:
return .cat
case .parrot:
return .parrot
case .snake:
return .snake
public var discriminant: Discriminant {
switch self {
case .dog:
return .dog
case .cat:
return .cat
case .parrot:
return .parrot
case .snake:
return .snake
}
}
}
}
""",
Expand Down

0 comments on commit 40aade2

Please sign in to comment.