Skip to content

Commit

Permalink
Merge pull request #42 from p-x9/feature/swift-syntax-510
Browse files Browse the repository at this point in the history
Support `swift-syntax` version 510.0.0
  • Loading branch information
p-x9 committed May 5, 2024
2 parents 7988b0e + e8f2247 commit 01d6e85
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 47 deletions.
16 changes: 8 additions & 8 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/p-x9/swift-literal-type-inference.git",
"state" : {
"revision" : "d4c97a7e48d3fab0c4575641c9a257602c1d17b7",
"version" : "0.1.0"
"revision" : "4de2706aee972bc87e1723578b75fa403fc779dd",
"version" : "0.2.0"
}
},
{
"identity" : "swift-macro-testing",
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/swift-macro-testing.git",
"state" : {
"revision" : "10dcef36314ddfea6f60442169b0b320204cbd35",
"version" : "0.2.2"
"revision" : "5c4a1b9d7c23cd5c08ea50677d8e89080365cb00",
"version" : "0.4.0"
}
},
{
Expand All @@ -32,17 +32,17 @@
"kind" : "remoteSourceControl",
"location" : "https://github.com/pointfreeco/swift-snapshot-testing",
"state" : {
"revision" : "8e68404f641300bfd0e37d478683bb275926760c",
"version" : "1.15.2"
"revision" : "625ccca8570773dd84a34ee51a81aa2bc5a4f97a",
"version" : "1.16.0"
}
},
{
"identity" : "swift-syntax",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-syntax.git",
"state" : {
"revision" : "74203046135342e4a4a627476dd6caf8b28fe11b",
"version" : "509.0.0"
"revision" : "fa8f95c2d536d6620cc2f504ebe8a6167c9fc2dd",
"version" : "510.0.1"
}
}
],
Expand Down
6 changes: 3 additions & 3 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,19 +18,19 @@ let package = Package(
dependencies: [
.package(
url: "https://github.com/apple/swift-syntax.git",
from: "509.0.0"
"509.0.0"..<"511.0.0"
),
.package(
url: "https://github.com/p-x9/swift-literal-type-inference.git",
from: "0.1.0"
from: "0.2.0"
),
.package(
url: "https://github.com/p-x9/swift-object-association.git",
from: "0.5.0"
),
.package(
url: "https://github.com/pointfreeco/swift-macro-testing.git",
from: "0.2.2"
from: "0.3.0"
)

],
Expand Down
37 changes: 20 additions & 17 deletions Tests/AssociatedObjectTests/AssociatedObjectTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import SwiftSyntaxMacros
import SwiftSyntaxMacrosTestSupport
import MacroTesting

#if canImport(AssociatedObjectPlugin)
// Note:
// Prior to version 510, if an initial value was set in AccessorMacro, it was left in place and expanded.
// Therefore, the following test will always fail when run on version 509. Therefore, the following tests are excluded from execution.
#if canImport(AssociatedObjectPlugin) && canImport(SwiftSyntax510)
@testable import AssociatedObjectPlugin
@testable import AssociatedObject

Expand All @@ -26,7 +29,7 @@ final class AssociatedObjectTests: XCTestCase {
"""
} expansion: {
"""
var string: String = "text" {
var string: String {
get {
if let value = getAssociatedObject(
self,
Expand Down Expand Up @@ -71,7 +74,7 @@ final class AssociatedObjectTests: XCTestCase {
"""
} expansion: {
"""
var int: Int = 5 {
var int: Int {
get {
if let value = getAssociatedObject(
self,
Expand Down Expand Up @@ -116,7 +119,7 @@ final class AssociatedObjectTests: XCTestCase {
"""
} expansion: {
"""
var float: Float = 5.0 {
var float: Float {
get {
if let value = getAssociatedObject(
self,
Expand Down Expand Up @@ -161,7 +164,7 @@ final class AssociatedObjectTests: XCTestCase {
"""
} expansion: {
"""
var double: Double = 5.0 {
var double: Double {
get {
if let value = getAssociatedObject(
self,
Expand Down Expand Up @@ -206,7 +209,7 @@ final class AssociatedObjectTests: XCTestCase {
"""
} expansion: {
"""
var string: String = "text" {
var string: String {
get {
if let value = getAssociatedObject(
self,
Expand Down Expand Up @@ -356,7 +359,7 @@ final class AssociatedObjectTests: XCTestCase {
"""
} expansion: {
"""
var string: String? = "hello" {
var string: String? {
get {
if !self.__associated_stringIsSet {
let value: String? = "hello"
Expand Down Expand Up @@ -410,7 +413,7 @@ final class AssociatedObjectTests: XCTestCase {
"""
} expansion: {
"""
var bool: Bool = false {
var bool: Bool {
get {
if let value = getAssociatedObject(
self,
Expand Down Expand Up @@ -455,7 +458,7 @@ final class AssociatedObjectTests: XCTestCase {
"""
} expansion: {
"""
var intArray: [Int] = [1, 2, 3] {
var intArray: [Int] {
get {
if let value = getAssociatedObject(
self,
Expand Down Expand Up @@ -535,7 +538,7 @@ final class AssociatedObjectTests: XCTestCase {
"""
} expansion: {
"""
var dic: [String: String] = ["t": "a"] {
var dic: [String: String] {
get {
if let value = getAssociatedObject(
self,
Expand Down Expand Up @@ -585,7 +588,7 @@ final class AssociatedObjectTests: XCTestCase {
"""
} expansion: {
"""
var string: String = "text" {
var string: String {
willSet {
print("willSet: old", string)
print("willSet: new", newValue)
Expand Down Expand Up @@ -645,7 +648,7 @@ final class AssociatedObjectTests: XCTestCase {
"""
} expansion: {
"""
var string: String = "text" {
var string: String {
didSet {
print("didSet: old", oldValue)
}
Expand Down Expand Up @@ -708,7 +711,7 @@ final class AssociatedObjectTests: XCTestCase {
"""
} expansion: {
"""
var string: String = "text" {
var string: String {
willSet {
print("willSet: old", string)
print("willSet: new", newValue)
Expand Down Expand Up @@ -778,7 +781,7 @@ final class AssociatedObjectTests: XCTestCase {
"""
} expansion: {
"""
var string: String = "text" {
var string: String {
willSet(new) {
print("willSet: old", string)
print("willSet: new", new)
Expand Down Expand Up @@ -838,7 +841,7 @@ final class AssociatedObjectTests: XCTestCase {
"""
} expansion: {
"""
var string: String = "text" {
var string: String {
didSet(old) {
print("didSet: old", old)
}
Expand Down Expand Up @@ -893,7 +896,7 @@ final class AssociatedObjectTests: XCTestCase {
"""
} expansion: {
"""
var string: String = "text" {
var string: String {
get {
if let value = getAssociatedObject(
self,
Expand Down Expand Up @@ -1026,7 +1029,7 @@ extension AssociatedObjectTests {
"""
} expansion: {
"""
var string: String = "text" {
var string: String {
get {
if let value = getAssociatedObject(
self,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import SwiftSyntaxMacros
import SwiftSyntaxMacrosTestSupport
import MacroTesting

#if canImport(AssociatedObjectPlugin)
#if canImport(AssociatedObjectPlugin) && canImport(SwiftSyntax510)
@testable import AssociatedObjectPlugin
@testable import AssociatedObject

Expand All @@ -38,7 +38,7 @@ extension AssociatedTypeDetectionObjectTests {
"""
} expansion: {
"""
var int = 10 {
var int {
get {
if let value = getAssociatedObject(
self,
Expand Down Expand Up @@ -83,7 +83,7 @@ extension AssociatedTypeDetectionObjectTests {
"""
} expansion: {
"""
var double = 10.0 {
var double {
get {
if let value = getAssociatedObject(
self,
Expand Down Expand Up @@ -128,7 +128,7 @@ extension AssociatedTypeDetectionObjectTests {
"""
} expansion: {
"""
var string = "text" {
var string {
get {
if let value = getAssociatedObject(
self,
Expand Down Expand Up @@ -173,7 +173,7 @@ extension AssociatedTypeDetectionObjectTests {
"""
} expansion: {
"""
var bool = false {
var bool {
get {
if let value = getAssociatedObject(
self,
Expand Down Expand Up @@ -221,7 +221,7 @@ extension AssociatedTypeDetectionObjectTests {
"""
} expansion: {
"""
var intArray = [1, 2, 3] {
var intArray {
get {
if let value = getAssociatedObject(
self,
Expand Down Expand Up @@ -266,7 +266,7 @@ extension AssociatedTypeDetectionObjectTests {
"""
} expansion: {
"""
var doubleArray = [1.0, 2.0, 3.0] {
var doubleArray {
get {
if let value = getAssociatedObject(
self,
Expand Down Expand Up @@ -311,7 +311,7 @@ extension AssociatedTypeDetectionObjectTests {
"""
} expansion: {
"""
var doubleArray = [1, 1.0, 2, 2.0, 3, 3.0] {
var doubleArray {
get {
if let value = getAssociatedObject(
self,
Expand Down Expand Up @@ -356,7 +356,7 @@ extension AssociatedTypeDetectionObjectTests {
"""
} expansion: {
"""
var boolArray = [true, false] {
var boolArray {
get {
if let value = getAssociatedObject(
self,
Expand Down Expand Up @@ -401,7 +401,7 @@ extension AssociatedTypeDetectionObjectTests {
"""
} expansion: {
"""
var stringArray = ["1.0", "2.0", "3.0"] {
var stringArray {
get {
if let value = getAssociatedObject(
self,
Expand Down Expand Up @@ -449,7 +449,7 @@ extension AssociatedTypeDetectionObjectTests {
"""
} expansion: {
"""
var optionalIntArray = [1, 1, nil, 2, 3, nil] {
var optionalIntArray {
get {
if let value = getAssociatedObject(
self,
Expand Down Expand Up @@ -494,7 +494,7 @@ extension AssociatedTypeDetectionObjectTests {
"""
} expansion: {
"""
var optionalDoubleArray = [1.0, 2.0, 3.0, nil] {
var optionalDoubleArray {
get {
if let value = getAssociatedObject(
self,
Expand Down Expand Up @@ -539,7 +539,7 @@ extension AssociatedTypeDetectionObjectTests {
"""
} expansion: {
"""
var doubleArray = [nil, 1, 1.0, nil, 2, 2.0, nil, 3, 3.0] {
var doubleArray {
get {
if let value = getAssociatedObject(
self,
Expand Down Expand Up @@ -585,7 +585,7 @@ extension AssociatedTypeDetectionObjectTests {
"""
} expansion: {
"""
var optionalBoolArray = [true, false, nil] {
var optionalBoolArray {
get {
if let value = getAssociatedObject(
self,
Expand Down Expand Up @@ -630,7 +630,7 @@ extension AssociatedTypeDetectionObjectTests {
"""
} expansion: {
"""
var optionalStringArray = [nil, "true", "false", nil] {
var optionalStringArray {
get {
if let value = getAssociatedObject(
self,
Expand Down Expand Up @@ -678,7 +678,7 @@ extension AssociatedTypeDetectionObjectTests {
"""
} expansion: {
"""
var dic = ["t": "a", "s": "b"] {
var dic {
get {
if let value = getAssociatedObject(
self,
Expand Down Expand Up @@ -723,7 +723,7 @@ extension AssociatedTypeDetectionObjectTests {
"""
} expansion: {
"""
var dic = [1: 3, 2: 4] {
var dic {
get {
if let value = getAssociatedObject(
self,
Expand Down Expand Up @@ -768,7 +768,7 @@ extension AssociatedTypeDetectionObjectTests {
"""
} expansion: {
"""
var dic = [1.0: 3.0, 2.0: 4.0] {
var dic {
get {
if let value = getAssociatedObject(
self,
Expand Down Expand Up @@ -817,7 +817,7 @@ extension AssociatedTypeDetectionObjectTests {
"""
} expansion: {
"""
var array = [[1.0], [2.0], [3.0, 4.0]] {
var array {
get {
if let value = getAssociatedObject(
self,
Expand Down

0 comments on commit 01d6e85

Please sign in to comment.