Skip to content

Commit 6de29d5

Browse files
committed
Use 2 indent width
1 parent 4607a52 commit 6de29d5

File tree

1 file changed

+45
-45
lines changed

1 file changed

+45
-45
lines changed

Tests/SwiftSyntaxTest/CustomReflecatbleTests.swift

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -3,50 +3,50 @@ import SwiftSyntax
33

44

55
public class CustomReflectableTests: XCTestCase {
6-
public static let allTests = [
7-
("testConformanceToCustomReflectable", testConformanceToCustomReflectable),
8-
]
9-
10-
11-
public func testConformanceToCustomReflectable() {
12-
XCTAssertNoThrow(try {
13-
let parsed = try SyntaxParser.parse(getInput("near-empty.swift"))
14-
XCTAssertEqual(collectSyntaxNotConformedCustomReflectable(from: parsed), [])
15-
}())
16-
XCTAssertNoThrow(try {
17-
let parsed = try SyntaxParser.parse(getInput("closure.swift"))
18-
XCTAssertEqual(collectSyntaxNotConformedCustomReflectable(from: parsed), [])
19-
}())
20-
XCTAssertNoThrow(try {
21-
let parsed = try SyntaxParser.parse(getInput("nested-blocks.swift"))
22-
XCTAssertEqual(collectSyntaxNotConformedCustomReflectable(from: parsed), [])
23-
}())
24-
XCTAssertNoThrow(try {
25-
let parsed = try SyntaxParser.parse(getInput("visitor.swift"))
26-
XCTAssertEqual(collectSyntaxNotConformedCustomReflectable(from: parsed), [])
27-
}())
28-
}
29-
30-
31-
public func collectSyntaxNotConformedCustomReflectable<S: Any>(from object: S) -> [String] {
32-
var paths = [String]()
33-
collectSyntaxNotConformedCustomReflectable(from: object, ancestors: ["root"], foundPaths: &paths)
34-
return paths
35-
}
36-
37-
38-
public func collectSyntaxNotConformedCustomReflectable<S: Any>(from object: S, ancestors: [String], foundPaths: inout [String]) {
39-
Mirror(reflecting: object).children.forEach { child in
40-
let (label: label, value: value) = child
41-
42-
var currentPathComponents = ancestors
43-
currentPathComponents.append(label ?? "(nil)")
44-
45-
if let syntax = value as? Syntax, !(syntax is CustomReflectable) {
46-
foundPaths.append("\(currentPathComponents.joined(separator: ".")): \(type(of: value as Any))")
47-
}
48-
49-
collectSyntaxNotConformedCustomReflectable(from: value, ancestors: currentPathComponents, foundPaths: &foundPaths)
50-
}
6+
public static let allTests = [
7+
("testConformanceToCustomReflectable", testConformanceToCustomReflectable),
8+
]
9+
10+
11+
public func testConformanceToCustomReflectable() {
12+
XCTAssertNoThrow(try {
13+
let parsed = try SyntaxParser.parse(getInput("near-empty.swift"))
14+
XCTAssertEqual(collectSyntaxNotConformedCustomReflectable(from: parsed), [])
15+
}())
16+
XCTAssertNoThrow(try {
17+
let parsed = try SyntaxParser.parse(getInput("closure.swift"))
18+
XCTAssertEqual(collectSyntaxNotConformedCustomReflectable(from: parsed), [])
19+
}())
20+
XCTAssertNoThrow(try {
21+
let parsed = try SyntaxParser.parse(getInput("nested-blocks.swift"))
22+
XCTAssertEqual(collectSyntaxNotConformedCustomReflectable(from: parsed), [])
23+
}())
24+
XCTAssertNoThrow(try {
25+
let parsed = try SyntaxParser.parse(getInput("visitor.swift"))
26+
XCTAssertEqual(collectSyntaxNotConformedCustomReflectable(from: parsed), [])
27+
}())
28+
}
29+
30+
31+
public func collectSyntaxNotConformedCustomReflectable<S: Any>(from object: S) -> [String] {
32+
var paths = [String]()
33+
collectSyntaxNotConformedCustomReflectable(from: object, ancestors: ["root"], foundPaths: &paths)
34+
return paths
35+
}
36+
37+
38+
public func collectSyntaxNotConformedCustomReflectable<S: Any>(from object: S, ancestors: [String], foundPaths: inout [String]) {
39+
Mirror(reflecting: object).children.forEach { child in
40+
let (label: label, value: value) = child
41+
42+
var currentPathComponents = ancestors
43+
currentPathComponents.append(label ?? "(nil)")
44+
45+
if let syntax = value as? Syntax, !(syntax is CustomReflectable) {
46+
foundPaths.append("\(currentPathComponents.joined(separator: ".")): \(type(of: value as Any))")
47+
}
48+
49+
collectSyntaxNotConformedCustomReflectable(from: value, ancestors: currentPathComponents, foundPaths: &foundPaths)
5150
}
51+
}
5252
}

0 commit comments

Comments
 (0)