From eec98b11b528ec4c9e7b1e78ec4ad04e9cd699e9 Mon Sep 17 00:00:00 2001 From: Yusuke Hosonuma Date: Fri, 13 Mar 2020 11:44:25 +0900 Subject: [PATCH] fix: @available annotation --- Sources/DSL/BasicDSL.swift | 31 ++++++++++++++++++++++++ Sources/DSL/FunctionBuilderDSL.swift | 36 ---------------------------- 2 files changed, 31 insertions(+), 36 deletions(-) diff --git a/Sources/DSL/BasicDSL.swift b/Sources/DSL/BasicDSL.swift index 853e0b6..92fe6dc 100644 --- a/Sources/DSL/BasicDSL.swift +++ b/Sources/DSL/BasicDSL.swift @@ -5,6 +5,8 @@ // Created by Yusuke Hosonuma on 2020/03/12. // +// MARK: - Basic API + /// Assert to `target` function with `rows` parameters. /// - Parameters: /// - target: test target function or operator @@ -30,3 +32,32 @@ public func args(_ args: T, line: UInt = #line) -> Row { Row(args: args, expect: expect, file: file, line: line) } + +// MARK: - Operator based API + +precedencegroup ExpectRowPrecedence { + lowerThan: FunctionArrowPrecedence +} + +infix operator ==>: ExpectRowPrecedence + +/// Create expectation row. +/// - Parameters: +/// - lhs: parameters of test target function +/// - rhs: expected value +public func ==> (lhs: T, rhs: R) -> ExpectRow { + ExpectRow(args: lhs, expect: rhs) +} + +public struct ExpectRow { + var args: T + var expect: R +} + +public func expect( + _ row: ExpectRow, + file: StaticString = #file, + line: UInt = #line +) -> Row { + Row(args: row.args, expect: row.expect, file: file, line: line) +} diff --git a/Sources/DSL/FunctionBuilderDSL.swift b/Sources/DSL/FunctionBuilderDSL.swift index 2d065f8..3c74131 100644 --- a/Sources/DSL/FunctionBuilderDSL.swift +++ b/Sources/DSL/FunctionBuilderDSL.swift @@ -9,31 +9,6 @@ // Note: // Function Builder is supported by Swift 5.1 or later. -// MARK: - Operators - -precedencegroup ExpectRowPrecedence { - lowerThan: FunctionArrowPrecedence -} - -infix operator ==>: ExpectRowPrecedence - -/// Create expectation row. -/// - Parameters: -/// - lhs: parameters of test target function -/// - rhs: expected value -@available(swift 5.1) -public func ==> (lhs: T, rhs: R) -> ExpectRow { - ExpectRow(args: lhs, expect: rhs) -} - -@available(swift 5.1) -public struct ExpectRow { - var args: T - var expect: R -} - -// MARK: - Function Builders - @available(swift 5.1) @_functionBuilder public struct ParameterBuilder { @@ -42,8 +17,6 @@ public struct ParameterBuilder { } } -// MARK: - DSL - /// Create `Expect` for start parameterized-test. /// - Parameters: /// - targetFunction: test target function @@ -56,12 +29,3 @@ public func assert( ) { ParameterizedTest(target: targetFunction, customAssertion: customAssertion).execute(with: rows()) } - -@available(swift 5.1) -public func expect( - _ row: ExpectRow, - file: StaticString = #file, - line: UInt = #line -) -> Row { - Row(args: row.args, expect: row.expect, file: file, line: line) -}