Skip to content

Commit

Permalink
Merge pull request #14 from daltonclaybrook/feature/more-tests-and-cl…
Browse files Browse the repository at this point in the history
…eanup

Remove some unused code and update one test
  • Loading branch information
daltonclaybrook authored Aug 25, 2020
2 parents 927165c + b5dc989 commit d1b689d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 36 deletions.
10 changes: 0 additions & 10 deletions Sources/SettlerFramework/DataStructures/DefinitionError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,3 @@ extension DefinitionError {
Located(value: self, file: file, offset: offset)
}
}

struct AggregateError<E: Error>: Error {
let underlying: [E]
}

extension AggregateError: CustomStringConvertible where E: CustomStringConvertible {
var description: String {
underlying.map(\.description).joined(separator: "\n")
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,4 @@ extension Dictionary where Key == String, Value == SourceKitRepresentable {
var nameLength: Int64? {
self[SwiftDocKey.nameLength.rawValue] as? Int64
}

var accessibility: Accessibility? {
let accessibilityString = self[Accessibility.docKey] as? String
return accessibilityString.flatMap(Accessibility.init(rawValue:))
}
}
8 changes: 0 additions & 8 deletions Sources/SettlerFramework/Utility/Accessibility.swift

This file was deleted.

32 changes: 19 additions & 13 deletions Tests/SettlerTests/XcodeErrorDescriptionTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,26 @@ final class XcodeErrorDescriptionTests: XCTestCase {
}

func testJoinedErrorStringsAreCorrect() {
let contents = "extension TestResolver {}"
let file1 = MockFile(path: "/path/one.swift", contents: contents)
let error1 = DefinitionError.cantFindDeclarationFile
.located(in: file1, offset: 0)
let file2 = MockFile(path: "/path/two.swift", contents: contents)
let error2 = DefinitionError
let errors: [DefinitionError] = [
.keyIsNotAnEnum,
.invalidTypeAlias,
.invalidFunction,
.unexpectedSyntaxElement,
.cantFindDeclarationFile,
.circularResolverDependency(keys: ["Key.Foo", "Key.Bar"]),
.resolverFunctionCannotBeThrowingIfResultIsUsedLazily
.located(in: file2, offset: 0)
let result = [error1, error2].errorString
let expected = """
/path/one.swift:1:1: error: \(error1.value.description)
/path/two.swift:1:1: error: \(error2.value.description)
"""
XCTAssertEqual(result, expected)
]
let contents = "extension TestResolver {}"
let locatedErrors = errors.enumerated()
.map { (index, error) -> Located<DefinitionError> in
let file = MockFile(path: "/path/file\(index).swift", contents: contents)
return error.located(in: file, offset: 0)
}
let expectedErrorStrings = locatedErrors.map { located in
"\(located.filePath!):1:1: error: \(located.value.description)"
}
let expected = expectedErrorStrings.joined(separator: "\n")
XCTAssertEqual(locatedErrors.errorString, expected)
}
}

Expand Down

0 comments on commit d1b689d

Please sign in to comment.