Skip to content

Commit 88cc5b6

Browse files
committed
Remove outdating parsing tests
1 parent a822ff5 commit 88cc5b6

File tree

6 files changed

+16
-550
lines changed

6 files changed

+16
-550
lines changed

Package.swift

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -162,13 +162,6 @@ let package = Package(
162162
name: "LiveViewNativeStylesheetTests",
163163
dependencies: ["LiveViewNativeStylesheet", "LiveViewNative"]
164164
),
165-
.testTarget(
166-
name: "LiveViewNativeStylesheetMacrosTests",
167-
dependencies: [
168-
"LiveViewNativeStylesheetMacros",
169-
.product(name: "SwiftSyntaxMacrosTestSupport", package: "swift-syntax"),
170-
]
171-
),
172165

173166
// Helpers
174167
.target(

Tests/LiveViewNativeStylesheetMacrosTests/MacroTests.swift

Lines changed: 0 additions & 202 deletions
This file was deleted.

Tests/LiveViewNativeStylesheetTests/ExternalTests.swift

Lines changed: 9 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -12,54 +12,19 @@ import SwiftUI
1212
final class ExternalTests: XCTestCase {
1313
func testASTNode() throws {
1414
XCTAssertEqual(
15-
try ASTNode("node") {
16-
StringLiteral()
17-
}
18-
.parse(#"{:node, [], "Hello, world!"}"#)
19-
.value,
20-
"Hello, world!"
15+
try JSONDecoder().decode(ASTNode.self, from: Data(#"["node", {}, ["Hello, world!"]]"#.utf8)),
16+
ASTNode(identifier: "node", annotations: .init(), arguments: [.unlabeled(.string("Hello, world!"))])
2117
)
2218
}
2319

24-
func testChainedMemberExpression() throws {
25-
let value = try ChainedMemberExpression {
26-
AtomLiteral()
27-
} member: {
28-
AtomLiteral()
29-
}
30-
.parse(#"{:., [], [nil, {:., [], [:a, :b]}]}"#)
31-
XCTAssertEqual(value.base, "a")
32-
XCTAssertEqual(value.members, ["b"])
33-
}
34-
35-
func testImplicitStaticMember() throws {
36-
let parser = ImplicitStaticMember([
37-
"a": "A",
38-
"b": "B",
39-
"c": "C"
40-
])
41-
XCTAssertEqual(try parser.parse("{:., [], [nil, :a]}"), "A")
42-
XCTAssertEqual(try parser.parse("{:., [], [nil, :b]}"), "B")
43-
XCTAssertEqual(try parser.parse("{:., [], [nil, :c]}"), "C")
44-
}
45-
46-
func testMemberExpression() throws {
47-
let value = try MemberExpression {
48-
AtomLiteral()
49-
} member: {
50-
AtomLiteral()
51-
}.parse("{:., [], [:a, :b]}")
52-
XCTAssertEqual(value.base, "a")
53-
XCTAssertEqual(value.member, "b")
54-
}
55-
56-
func testMetadata() throws {
57-
XCTAssertEqual(try Metadata.parser().parse("[]"), Metadata(file: "", line: 0, module: "", source: ""))
20+
func testAnnotations() throws {
21+
XCTAssertEqual(
22+
try JSONDecoder().decode(Annotations.self, from: Data("{}".utf8)),
23+
Annotations()
24+
)
5825
XCTAssertEqual(
59-
try Metadata.parser().parse(
60-
#"[file: "test.ex", line: 5, module: MyApp.Module, source: "source code"]"#
61-
),
62-
Metadata(file: "test.ex", line: 5, module: "MyApp.Module", source: "source code")
26+
try JSONDecoder().decode(Annotations.self, from: Data(#"{ "file": "file", "line": 1, "module": "module", "source": "source" }"#.utf8)),
27+
Annotations(file: "file", line: 1, module: "module", source: "source")
6328
)
6429
}
6530
}

Tests/LiveViewNativeStylesheetTests/LiteralTests.swift

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -11,32 +11,13 @@ import SwiftUI
1111

1212
final class LiteralTests: XCTestCase {
1313
func testAtomLiteral() throws {
14-
XCTAssertEqual(try AtomLiteral().parse(":value"), "value")
15-
XCTAssertEqual(try AtomLiteral().parse(#":"my-value""#), "my-value")
16-
}
17-
18-
func testListLiteral() throws {
19-
XCTAssertEqual(try ListLiteral { StringLiteral() }.parse(#"["a", "b"]"#), ["a", "b"])
20-
XCTAssertEqual(try ListLiteral { AtomLiteral() }.parse("[:a, :b]"), ["a", "b"])
2114
XCTAssertEqual(
22-
try ListLiteral {
23-
ListLiteral {
24-
StringLiteral()
25-
}
26-
}.parse(#"[["a", "b"], ["c"]]"#),
27-
[["a", "b"], ["c"]]
15+
try JSONDecoder().decode(AtomLiteral.self, from: Data(#"[":", {}, "value"]"#.utf8)).value,
16+
AtomLiteral("value").value
17+
)
18+
XCTAssertEqual(
19+
try JSONDecoder().decode(AtomLiteral.self, from: Data(#"[":", {}, "my-value"]"#.utf8)).value,
20+
AtomLiteral("my-value").value
2821
)
29-
}
30-
31-
func testNilLiteral() throws {
32-
XCTAssertNoThrow(try NilLiteral().parse("nil"))
33-
XCTAssertThrowsError(try NilLiteral().parse("null"))
34-
}
35-
36-
func testStringLiteral() throws {
37-
XCTAssertEqual(try StringLiteral().parse(#""Hello, world!""#), "Hello, world!")
38-
XCTAssertEqual(try StringLiteral().parse(#""\"Hello, world!\"""#), "\"Hello, world!\"")
39-
XCTAssertEqual(try StringLiteral().parse(#""\\n""#), "\\n")
40-
XCTAssertEqual(try StringLiteral().parse(#""\/\b\f\n\r\t""#), "/\u{8}\u{c}\n\r\t")
4122
}
4223
}

Tests/LiveViewNativeStylesheetTests/LiveViewNativeStylesheetTests.swift

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,5 @@ import SwiftUI
55

66
@MainActor
77
final class LiveViewNativeStylesheetTests: XCTestCase {
8-
func testAlignment() throws {
9-
XCTAssertEqual(try Alignment.parser(in: .init()).parse("{:., [], [nil, :topLeading]}"), Alignment.topLeading)
10-
XCTAssertEqual(try Alignment.parser(in: .init()).parse("{:., [], [nil, :top]}"), Alignment.top)
11-
XCTAssertEqual(try Alignment.parser(in: .init()).parse("{:., [], [nil, :centerFirstTextBaseline]}"), Alignment.centerFirstTextBaseline)
12-
XCTAssertEqual(try Alignment.parser(in: .init()).parse("{:., [], [nil, :centerLastTextBaseline]}"), Alignment.centerLastTextBaseline)
13-
XCTAssertEqual(try Alignment.parser(in: .init()).parse("{:., [], [nil, :leadingFirstTextBaseline]}"), Alignment.leadingFirstTextBaseline)
14-
XCTAssertEqual(try Alignment.parser(in: .init()).parse("{:., [], [nil, :leadingLastTextBaseline]}"), Alignment.leadingLastTextBaseline)
15-
XCTAssertEqual(try Alignment.parser(in: .init()).parse("{:., [], [nil, :trailingFirstTextBaseline]}"), Alignment.trailingFirstTextBaseline)
16-
XCTAssertEqual(try Alignment.parser(in: .init()).parse("{:., [], [nil, :trailingLastTextBaseline]}"), Alignment.trailingLastTextBaseline)
17-
XCTAssertEqual(try Alignment.parser(in: .init()).parse("{:., [], [nil, :topLeading]}"), Alignment.topLeading)
18-
XCTAssertEqual(try Alignment.parser(in: .init()).parse("{:., [], [nil, :topTrailing]}"), Alignment.topTrailing)
19-
XCTAssertEqual(try Alignment.parser(in: .init()).parse("{:., [], [nil, :bottomLeading]}"), Alignment.bottomLeading)
20-
XCTAssertEqual(try Alignment.parser(in: .init()).parse("{:., [], [nil, :bottomTrailing]}"), Alignment.bottomTrailing)
21-
XCTAssertEqual(try Alignment.parser(in: .init()).parse("{:., [], [nil, :top]}"), Alignment.top)
22-
XCTAssertEqual(try Alignment.parser(in: .init()).parse("{:., [], [nil, :bottom]}"), Alignment.bottom)
23-
XCTAssertEqual(try Alignment.parser(in: .init()).parse("{:., [], [nil, :center]}"), Alignment.center)
24-
XCTAssertEqual(try Alignment.parser(in: .init()).parse("{:., [], [nil, :leading]}"), Alignment.leading)
25-
XCTAssertEqual(try Alignment.parser(in: .init()).parse("{:., [], [nil, :trailing]}"), Alignment.trailing)
26-
}
8+
279
}

0 commit comments

Comments
 (0)