Skip to content

Commit

Permalink
Update to SwiftSyntax 510.0.0 and fix tests (missing dependency)
Browse files Browse the repository at this point in the history
  • Loading branch information
stackotter committed May 13, 2024
1 parent 455abe4 commit 687075e
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 57 deletions.
4 changes: 2 additions & 2 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-syntax.git",
"state" : {
"revision" : "74203046135342e4a4a627476dd6caf8b28fe11b",
"version" : "509.0.0"
"revision" : "303e5c5c36d6a558407d364878df131c3546fad8",
"version" : "510.0.2"
}
},
{
Expand Down
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ let package = Package(
dependencies: [
.package(
url: "https://github.com/apple/swift-syntax.git",
from: "509.0.0"
from: "510.0.0"
),
.package(url: "https://github.com/apple/swift-docc-plugin", from: "1.3.0"),
.package(url: "https://github.com/SwiftPackageIndex/SPIManifest.git", from: "0.12.0"),
Expand Down Expand Up @@ -47,7 +47,7 @@ let package = Package(
.testTarget(
name: "MacroToolkitTests",
dependencies: [
"MacroToolkitExample",
"MacroToolkitExamplePlugin",
"MacroToolkit",
.product(name: "SwiftSyntax", package: "swift-syntax"),
.product(name: "SwiftSyntaxMacros", package: "swift-syntax"),
Expand Down
2 changes: 1 addition & 1 deletion Sources/MacroToolkitExamplePlugin/AddBlockerMacro.swift
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public struct AddBlockerMacro: ExpressionMacro {
of node: some FreestandingMacroExpansionSyntax,
in context: some MacroExpansionContext
) throws -> ExprSyntax {
guard let (argument) = destructureSingle(node.argumentList) else {
guard let (argument) = destructureSingle(node.arguments) else {
throw MacroError("#addBlocker only expects one argument")
}

Expand Down
104 changes: 52 additions & 52 deletions Tests/MacroToolkitTests/MacroToolkitTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -318,15 +318,15 @@ final class MacroToolkitTests: XCTestCase {
expandedSource: """
struct Point {
var x: Int = 1 {
var x: Int {
get {
_storage["x", default: 1] as! Int
}
set {
_storage["x"] = newValue
}
}
var y: Int = 2 {
var y: Int {
get {
_storage["y", default: 2] as! Int
}
Expand Down Expand Up @@ -562,7 +562,7 @@ final class MacroToolkitTests: XCTestCase {
XCTAssertEqual(n.initialValue?._syntax.description, "[1, 2.5]")
XCTAssertEqual(n.isLazy, true)
}

func testAsyncInterfaceMacro() throws {
assertMacroExpansion(
"""
Expand All @@ -572,17 +572,17 @@ final class MacroToolkitTests: XCTestCase {
}
""",
expandedSource:
"""
protocol API {
func request(completion: (Int) -> Void)
func request() async -> Int
}
""",
"""
protocol API {
func request(completion: (Int) -> Void)
func request() async -> Int
}
""",
macros: testMacros
)
}

func testAsyncInterfaceAllMembersMacro() throws {
assertMacroExpansion(
"""
Expand All @@ -593,16 +593,16 @@ final class MacroToolkitTests: XCTestCase {
}
""",
expandedSource:
"""
protocol API {
func request1(completion: (Int) -> Void)
func request2(completion: (String) -> Void)
func request1() async -> Int
"""
protocol API {
func request1(completion: (Int) -> Void)
func request2(completion: (String) -> Void)
func request2() async -> String
}
""",
func request1() async -> Int
func request2() async -> String
}
""",
macros: testMacros
)
}
Expand All @@ -617,21 +617,21 @@ final class MacroToolkitTests: XCTestCase {
}
""",
expandedSource:
"""
struct Client {
func request1(completion: (Int) -> Void) {
completion(0)
}
func request1() async -> Int {
await withCheckedContinuation { continuation in
request1() { returnValue in
continuation.resume(returning: returnValue)
"""
struct Client {
func request1(completion: (Int) -> Void) {
completion(0)
}
func request1() async -> Int {
await withCheckedContinuation { continuation in
request1() { returnValue in
continuation.resume(returning: returnValue)
}
}
}
}
}
""",
""",
macros: testMacros
)
}
Expand All @@ -649,32 +649,32 @@ final class MacroToolkitTests: XCTestCase {
}
""",
expandedSource:
"""
struct Client {
func request1(completion: (Int) -> Void) {
completion(0)
}
func request2(completion: (String) -> Void) {
completion("")
}
func request1() async -> Int {
await withCheckedContinuation { continuation in
request1() { returnValue in
continuation.resume(returning: returnValue)
"""
struct Client {
func request1(completion: (Int) -> Void) {
completion(0)
}
func request2(completion: (String) -> Void) {
completion("")
}
func request1() async -> Int {
await withCheckedContinuation { continuation in
request1() { returnValue in
continuation.resume(returning: returnValue)
}
}
}
}
func request2() async -> String {
await withCheckedContinuation { continuation in
request2() { returnValue in
continuation.resume(returning: returnValue)
func request2() async -> String {
await withCheckedContinuation { continuation in
request2() { returnValue in
continuation.resume(returning: returnValue)
}
}
}
}
}
""",
""",
macros: testMacros
)
}
Expand Down

0 comments on commit 687075e

Please sign in to comment.