Skip to content

Remove a few throws annotations that weren’t necesary in tests #994

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 21, 2022
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
2 changes: 1 addition & 1 deletion Sources/_SwiftSyntaxTestSupport/Syntax+Assertions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ public struct SubtreeMatcher {
/// The syntax tree from parsing source *with markers removed*.
private var actualTree: Syntax

public init(_ markedText: String, parse: (String) throws -> Syntax) throws {
public init(_ markedText: String, parse: (String) throws -> Syntax) rethrows {
let (markers, text) = extractMarkers(markedText)

self.markers = markers.isEmpty ? ["DEFAULT": 0] : markers
Expand Down
2 changes: 1 addition & 1 deletion Tests/PerformanceTest/ParsingPerformanceTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public class ParsingPerformanceTests: XCTestCase {
}
}

func testNativeParsingPerformance() throws {
func testNativeParsingPerformance() {
measure {
do {
let source = try String(contentsOf: inputFile)
Expand Down
12 changes: 6 additions & 6 deletions Tests/SwiftDiagnosticsTest/DiagnosticsFormatterTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ import SwiftParser

final class DiagnosticsFormatterTests: XCTestCase {

func annotate(source: String) throws -> String {
func annotate(source: String) -> String {
let tree = Parser.parse(source: source)
let diags = ParseDiagnosticsGenerator.diagnostics(for: tree)
return DiagnosticsFormatter.annotatedSource(tree: tree, diags: diags)
}

func testSingleDiagnostic() throws {
func testSingleDiagnostic() {
let source = """
var foo = bar +
"""
Expand All @@ -32,10 +32,10 @@ final class DiagnosticsFormatterTests: XCTestCase {
∣ ╰─ expected expression in variable

"""
AssertStringsEqualWithDiff(expectedOutput, try annotate(source: source))
AssertStringsEqualWithDiff(expectedOutput, annotate(source: source))
}

func testMultipleDiagnosticsInOneLine() throws {
func testMultipleDiagnosticsInOneLine() {
let source = """
foo.[].[].[]
"""
Expand All @@ -46,10 +46,10 @@ final class DiagnosticsFormatterTests: XCTestCase {
∣ ╰─ expected name in member access

"""
AssertStringsEqualWithDiff(expectedOutput, try annotate(source: source))
AssertStringsEqualWithDiff(expectedOutput, annotate(source: source))
}

func testLineSkipping() throws {
func testLineSkipping() {
let source = """
var i = 1
i = 2
Expand Down
4 changes: 2 additions & 2 deletions Tests/SwiftOperatorsTest/OperatorTableTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ public class OperatorPrecedenceTests: XCTestCase {
XCTAssertNil(foldedExpr.as(SequenceExprSyntax.self))
}

func testParseErrors() throws {
func testParseErrors() {
let sources =
"""
infix operator +
Expand Down Expand Up @@ -231,7 +231,7 @@ public class OperatorPrecedenceTests: XCTestCase {
_ = existingGroup
}

func testUnaryErrors() throws {
func testUnaryErrors() {
let sources =
"""
prefix operator +
Expand Down
4 changes: 2 additions & 2 deletions Tests/SwiftParserTest/Attributes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ final class AttributeTests: XCTestCase {
""")
}

func testImplementsAttribute() throws {
func testImplementsAttribute() {
AssertParse("""
@_implements(P, f0())
func g0() -> Int {
Expand All @@ -213,7 +213,7 @@ final class AttributeTests: XCTestCase {
""")
}

func testSemanticsAttribute() throws {
func testSemanticsAttribute() {
AssertParse(
"""
@_semantics("constant_evaluable")
Expand Down
6 changes: 3 additions & 3 deletions Tests/SwiftParserTest/Availability.swift
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import XCTest

final class AvailabilityTests: XCTestCase {
func testAvailableMember() throws {
func testAvailableMember() {
AssertParse(
"""
@available(OSX 10.0, introduced: 10.12)
Expand Down Expand Up @@ -51,7 +51,7 @@ final class AvailabilityTests: XCTestCase {
)
}

func testAvailabilityMacros() throws {
func testAvailabilityMacros() {
AssertParse(
"""
@available(_iOS9, _macOS10_11, tvOS 11.0, *)
Expand All @@ -65,7 +65,7 @@ final class AvailabilityTests: XCTestCase {
""")
}

func testSPIAvailabilityAttribute() throws {
func testSPIAvailabilityAttribute() {
AssertParse(
"""
@_spi_available(*, deprecated, renamed: "another")
Expand Down
2 changes: 1 addition & 1 deletion Tests/SwiftParserTest/Declarations.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1083,7 +1083,7 @@ final class DeclarationTests: XCTestCase {
)
}

func testReasyncFunctions() throws {
func testReasyncFunctions() {
AssertParse(
"""
class MyType {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import SwiftDiagnostics
import SwiftParser

public class DiagnosticInfrastructureTests: XCTestCase {
public func testDiagnosticID() throws {
public func testDiagnosticID() {
struct TestDiagnostic: ParserError {
let message: String = "My test diagnostic"
}
Expand Down
22 changes: 11 additions & 11 deletions Tests/SwiftParserTest/LexerTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ private func lexeme(
}

public class LexerTests: XCTestCase {
func testIdentifiers() throws {
func testIdentifiers() {
var data =
"""
Hello World
Expand All @@ -34,7 +34,7 @@ public class LexerTests: XCTestCase {
}
}

func testEscapedIdentifiers() throws {
func testEscapedIdentifiers() {
var data =
"""
`Hello` `World` `$`
Expand All @@ -50,7 +50,7 @@ public class LexerTests: XCTestCase {
}
}

func testBlockComments() throws {
func testBlockComments() {
do {
var data =
"""
Expand Down Expand Up @@ -89,7 +89,7 @@ public class LexerTests: XCTestCase {
}
}

func testDeepTupleAccess() throws {
func testDeepTupleAccess() {
var data =
#"""
x.1.0
Expand All @@ -108,7 +108,7 @@ public class LexerTests: XCTestCase {
}
}

func testUnicodeLiteral() throws {
func testUnicodeLiteral() {
do {
var data =
#"""
Expand Down Expand Up @@ -141,7 +141,7 @@ public class LexerTests: XCTestCase {
}


func testNumberLiterals() throws {
func testNumberLiterals() {
var data =
"""
1234567890
Expand Down Expand Up @@ -177,7 +177,7 @@ public class LexerTests: XCTestCase {
}
}

func testRawStringLiterals() throws {
func testRawStringLiterals() {
do {
var data =
"""
Expand Down Expand Up @@ -237,7 +237,7 @@ public class LexerTests: XCTestCase {
}
}

func testShebang() throws {
func testShebang() {
var data =
"""
#!/usr/bin/swiftc
Expand All @@ -255,7 +255,7 @@ public class LexerTests: XCTestCase {
}
}

func testDocComment() throws {
func testDocComment() {
var data =
"""
/** hello */
Expand All @@ -274,7 +274,7 @@ public class LexerTests: XCTestCase {
}
}

func testMain() throws {
func testMain() {
var data =
"""
/* TestApp */
Expand Down Expand Up @@ -309,7 +309,7 @@ public class LexerTests: XCTestCase {
}
}

func testRegexLexing() throws {
func testRegexLexing() {
let fixtures: [(String, [Lexer.Lexeme])] = [
("/abc/", [
lexeme(.regexLiteral, "/abc/"),
Expand Down
4 changes: 2 additions & 2 deletions Tests/SwiftParserTest/SyntaxTransformVisitor.swift
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import SwiftParser
import SwiftSyntax

final class SyntaxTransformVisitorTest: XCTestCase {
public func testFunctionCounter() throws {
public func testFunctionCounter() {
struct FuncCounter: SyntaxTransformVisitor {
public func visitAny(_ node: Syntax) -> Int {
visitChildren(node).reduce(0, +)
Expand Down Expand Up @@ -38,7 +38,7 @@ final class SyntaxTransformVisitorTest: XCTestCase {
}()
}

public func testPrintFunctionType() throws {
public func testPrintFunctionType() {
/// Assuming there is a single functioned declaration in the source file, print the type of that function.
struct PrintFunctionType: SyntaxTransformVisitor {
func visitAny(_ node: SwiftSyntax.Syntax) -> String {
Expand Down
8 changes: 4 additions & 4 deletions Tests/SwiftParserTest/TriviaParserTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import XCTest

final class TriviaParserTests: XCTestCase {

func testTriviaParsing() throws {
func testTriviaParsing() {

XCTAssertEqual(
TriviaParser.parseTrivia("""
Expand Down Expand Up @@ -126,7 +126,7 @@ final class TriviaParserTests: XCTestCase {
])
}

func testRawSyntaxLazyTriviaPieces() throws {
func testRawSyntaxLazyTriviaPieces() {
withParser(source: """
/// Foo.
func foo() {
Expand All @@ -153,7 +153,7 @@ final class TriviaParserTests: XCTestCase {

}

func testSyntaxLazyTrivia() throws {
func testSyntaxLazyTrivia() {
let source = """
/* comment only */

Expand All @@ -165,7 +165,7 @@ final class TriviaParserTests: XCTestCase {
])
}

func testUnexpectedSplitting() throws {
func testUnexpectedSplitting() {
XCTAssertEqual(
TriviaParser.parseTrivia("\u{fffe} ", position: .trailing),
[
Expand Down
Loading