Skip to content

Commit 04dc929

Browse files
committed
Migrated from XCTest to Swift Testing
1 parent 6790d95 commit 04dc929

6 files changed

Lines changed: 219 additions & 227 deletions

File tree

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,45 @@
1-
import XCTest
1+
import Testing
22

33
@testable import SyntaxKit
44

5-
final class BasicTests: XCTestCase {
6-
func testBlackjackCardExample() throws {
7-
let blackjackCard = Struct("BlackjackCard") {
8-
Enum("Suit") {
9-
EnumCase("spades").equals("")
10-
EnumCase("hearts").equals("")
11-
EnumCase("diamonds").equals("")
12-
EnumCase("clubs").equals("")
13-
}.inherits("Character")
14-
}
5+
struct BasicTests {
6+
@Test func testBlackjackCardExample() throws {
7+
let blackjackCard = Struct("BlackjackCard") {
8+
Enum("Suit") {
9+
EnumCase("spades").equals("")
10+
EnumCase("hearts").equals("")
11+
EnumCase("diamonds").equals("")
12+
EnumCase("clubs").equals("")
13+
}.inherits("Character")
14+
}
1515

16-
let expected = """
17-
struct BlackjackCard {
18-
enum Suit: Character {
19-
case spades = ""
20-
case hearts = ""
21-
case diamonds = ""
22-
case clubs = ""
16+
let expected = """
17+
struct BlackjackCard {
18+
enum Suit: Character {
19+
case spades = ""
20+
case hearts = ""
21+
case diamonds = ""
22+
case clubs = ""
23+
}
2324
}
24-
}
25-
"""
25+
"""
2626

27-
// Normalize whitespace, remove comments and modifiers, and normalize colon spacing
28-
let normalizedGenerated = blackjackCard.syntax.description
29-
.replacingOccurrences(of: "//.*$", with: "", options: .regularExpression) // Remove comments
30-
.replacingOccurrences(of: "public\\s+", with: "", options: .regularExpression) // Remove public modifier
31-
.replacingOccurrences(of: "\\s*:\\s*", with: ": ", options: .regularExpression) // Normalize colon spacing
32-
.replacingOccurrences(of: "\\s+", with: " ", options: .regularExpression) // Normalize whitespace
33-
.trimmingCharacters(in: .whitespacesAndNewlines)
27+
// Normalize whitespace, remove comments and modifiers, and normalize colon spacing
28+
let normalizedGenerated = blackjackCard.syntax.description
29+
.replacingOccurrences(of: "//.*$", with: "", options: .regularExpression)
30+
.replacingOccurrences(of: "public\\s+", with: "", options: .regularExpression)
31+
.replacingOccurrences(of: "\\s*:\\s*", with: ": ", options: .regularExpression)
32+
.replacingOccurrences(of: "\\s+", with: " ", options: .regularExpression)
33+
.trimmingCharacters(in: .whitespacesAndNewlines)
3434

35-
let normalizedExpected =
36-
expected
37-
.replacingOccurrences(of: "//.*$", with: "", options: .regularExpression) // Remove comments
38-
.replacingOccurrences(of: "public\\s+", with: "", options: .regularExpression) // Remove public modifier
39-
.replacingOccurrences(of: "\\s*:\\s*", with: ": ", options: .regularExpression) // Normalize colon spacing
40-
.replacingOccurrences(of: "\\s+", with: " ", options: .regularExpression) // Normalize whitespace
41-
.trimmingCharacters(in: .whitespacesAndNewlines)
35+
let normalizedExpected =
36+
expected
37+
.replacingOccurrences(of: "//.*$", with: "", options: .regularExpression)
38+
.replacingOccurrences(of: "public\\s+", with: "", options: .regularExpression)
39+
.replacingOccurrences(of: "\\s*:\\s*", with: ": ", options: .regularExpression)
40+
.replacingOccurrences(of: "\\s+", with: " ", options: .regularExpression)
41+
.trimmingCharacters(in: .whitespacesAndNewlines)
4242

43-
XCTAssertEqual(normalizedGenerated, normalizedExpected)
44-
}
43+
#expect(normalizedGenerated == normalizedExpected)
44+
}
4545
}

0 commit comments

Comments
 (0)