Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 9 additions & 12 deletions Tests/MacroTests/AssociatedValuesMacroTests.swift
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#if canImport(Macros)
import SwiftSyntaxMacros
import SwiftSyntaxMacrosTestSupport
import XCTest
import Testing

final class AssociatedValuesMacroTests: XCTestCase {
func testGenerateVarForAssociatedValues() throws {
#if canImport(Macros)
@Suite("Associated Values Macro")
struct AssociatedValuesMacroTests {
@Test
func generateVarForAssociatedValues() {
assertMacroExpansion(
"""
@AssociatedValues
Expand Down Expand Up @@ -66,13 +68,10 @@ final class AssociatedValuesMacroTests: XCTestCase {
macros: testMacros,
indentationWidth: .spaces(2)
)
#else
throw XCTSkip("macros are only supported when running tests for the host platform")
#endif
}

func testMacroIsOnlySupportEnum() throws {
#if canImport(Macros)
@Test
func macroIsOnlySupportEnum() {
assertMacroExpansion(
#"""
@AssociatedValues
Expand All @@ -91,8 +90,6 @@ final class AssociatedValuesMacroTests: XCTestCase {
],
macros: testMacros
)
#else
throw XCTSkip("macros are only supported when running tests for the host platform")
#endif
}
}
#endif
28 changes: 11 additions & 17 deletions Tests/MacroTests/SingletonMacroTests.swift
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#if canImport(Macros)
import SwiftSyntaxMacros
import SwiftSyntaxMacrosTestSupport
import XCTest
import Testing

final class SingletonMacroTests: XCTestCase {
func testGenerateAPublicSignletonProperty() throws {
#if canImport(Macros)
@Suite("Singleton Macro")
struct SingletonMacroTests {
@Test
func generateAPublicSignletonProperty() {
assertMacroExpansion(
"""
@Singleton
Expand All @@ -24,13 +26,10 @@ final class SingletonMacroTests: XCTestCase {
macros: testMacros,
indentationWidth: .spaces(2)
)
#else
throw XCTSkip("macros are only supported when running tests for the host platform")
#endif
}

func testGenerateASignletonProperty() throws {
#if canImport(Macros)
@Test
func generateASignletonProperty() {
assertMacroExpansion(
"""
@Singleton
Expand All @@ -50,13 +49,10 @@ final class SingletonMacroTests: XCTestCase {
macros: testMacros,
indentationWidth: .spaces(2)
)
#else
throw XCTSkip("macros are only supported when running tests for the host platform")
#endif
}

func testMacroIsOnlySupportClassOrStruct() throws {
#if canImport(Macros)
@Test
func macroIsOnlySupportClassOrStruct() {
assertMacroExpansion(
"""
@Singleton
Expand All @@ -73,8 +69,6 @@ final class SingletonMacroTests: XCTestCase {
],
macros: testMacros
)
#else
throw XCTSkip("macros are only supported when running tests for the host platform")
#endif
}
}
#endif
28 changes: 11 additions & 17 deletions Tests/MacroTests/SymbolMacroTests.swift
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#if canImport(Macros)
import SwiftSyntaxMacros
import SwiftSyntaxMacrosTestSupport
import XCTest
import Testing

final class SymbolMacroTests: XCTestCase {
func testValidSymbol() throws {
#if canImport(Macros)
@Suite("Symbol Macro")
struct SymbolMacroTests {
@Test
func validSymbol() {
assertMacroExpansion(
"""
#symbol("swift")
Expand All @@ -15,13 +17,10 @@ final class SymbolMacroTests: XCTestCase {
""",
macros: testMacros
)
#else
throw XCTSkip("macros are only supported when running tests for the host platform")
#endif
}

func testInvalidSymbol() throws {
#if canImport(Macros)
@Test
func invalidSymbol() {
assertMacroExpansion(
"""
#symbol("test")
Expand All @@ -35,13 +34,10 @@ final class SymbolMacroTests: XCTestCase {
],
macros: testMacros
)
#else
throw XCTSkip("macros are only supported when running tests for the host platform")
#endif
}

func testParseNameError() throws {
#if canImport(Macros)
@Test
func parseSymbolNameWithError() {
assertMacroExpansion(
#"""
#symbol("\("swift")")
Expand All @@ -55,8 +51,6 @@ final class SymbolMacroTests: XCTestCase {
],
macros: testMacros
)
#else
throw XCTSkip("macros are only supported when running tests for the host platform")
#endif
}
}
#endif
28 changes: 11 additions & 17 deletions Tests/MacroTests/URLMacroTests.swift
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
#if canImport(Macros)
import SwiftSyntaxMacros
import SwiftSyntaxMacrosTestSupport
import XCTest
import Testing

final class URLMacroTests: XCTestCase {
func testValidURL() throws {
#if canImport(Macros)
@Suite("URL Macro")
struct URLMacroTests {
@Test
func validURL() {
assertMacroExpansion(
"""
#URL("https://www.apple.com")
Expand All @@ -15,13 +17,10 @@ final class URLMacroTests: XCTestCase {
""",
macros: testMacros
)
#else
throw XCTSkip("macros are only supported when running tests for the host platform")
#endif
}

func testURLStringLiteralError() throws {
#if canImport(Macros)
@Test
func UrlStringLiteralError() {
assertMacroExpansion(
#"""
#URL("https://www.apple.com\(Int.random())")
Expand All @@ -35,13 +34,10 @@ final class URLMacroTests: XCTestCase {
],
macros: testMacros
)
#else
throw XCTSkip("macros are only supported when running tests for the host platform")
#endif
}

func testMalformedURLError() throws {
#if canImport(Macros)
@Test
func malformedURLError() {
assertMacroExpansion(
"""
#URL("https://www. apple.com")
Expand All @@ -55,8 +51,6 @@ final class URLMacroTests: XCTestCase {
],
macros: testMacros
)
#else
throw XCTSkip("macros are only supported when running tests for the host platform")
#endif
}
}
#endif