mirror of
https://github.com/apple/swift-numerics
synced 2026-11-26 04:57:53 +00:00
Merge pull request #144 from stephentyrone/test-support
Factor test support out into a module
This commit is contained in:
9 files changed
+38
-10
No files matched your search
+5
-3
@@ -24,10 +24,12 @@ let package = Package(
|
||||
targets: [
|
||||
.target(name: "ComplexModule", dependencies: ["RealModule"]),
|
||||
.target(name: "Numerics", dependencies: ["ComplexModule", "RealModule"]),
|
||||
.target(name: "_NumericsShims", dependencies: []),
|
||||
.target(name: "RealModule", dependencies: ["_NumericsShims"]),
|
||||
|
||||
.testTarget(name: "ComplexTests", dependencies: ["Numerics"]),
|
||||
.testTarget(name: "RealTests", dependencies: ["RealModule"]),
|
||||
.target(name: "_NumericsShims", dependencies: []),
|
||||
.target(name: "_TestSupport", dependencies: ["Numerics"]),
|
||||
|
||||
.testTarget(name: "ComplexTests", dependencies: ["_TestSupport"]),
|
||||
.testTarget(name: "RealTests", dependencies: ["_TestSupport"]),
|
||||
]
|
||||
)
|
||||
@@ -11,3 +11,6 @@ add_subdirectory(_NumericsShims)
|
||||
add_subdirectory(ComplexModule)
|
||||
add_subdirectory(Numerics)
|
||||
add_subdirectory(RealModule)
|
||||
if(BUILD_TESTING)
|
||||
add_subdirectory(_TestSupport)
|
||||
endif()
|
||||
@@ -0,0 +1,19 @@
|
||||
#[[
|
||||
This source file is part of the Swift Numerics open source project
|
||||
|
||||
Copyright (c) 2019-2020 Apple Inc. and the Swift Numerics project authors
|
||||
Licensed under Apache License v2.0 with Runtime Library Exception
|
||||
|
||||
See https://swift.org/LICENSE.txt for license information
|
||||
#]]
|
||||
|
||||
add_library(_TestSupport
|
||||
RealTestSupport.swift)
|
||||
set_target_properties(_TestSupport PROPERTIES
|
||||
INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY})
|
||||
target_link_libraries(_TestSupport PUBLIC
|
||||
Numerics)
|
||||
|
||||
|
||||
_install_target(_TestSupport)
|
||||
set_property(GLOBAL APPEND PROPERTY SWIFT_NUMERICS_EXPORTS _TestSupport)
|
||||
@@ -13,13 +13,13 @@ import XCTest
|
||||
import RealModule
|
||||
|
||||
#if (arch(i386) || arch(x86_64)) && !os(Windows) && !os(Android)
|
||||
typealias TestLiteralType = Float80
|
||||
public typealias TestLiteralType = Float80
|
||||
#else
|
||||
typealias TestLiteralType = Double
|
||||
public typealias TestLiteralType = Double
|
||||
#endif
|
||||
|
||||
@discardableResult
|
||||
func assertClose<T>(
|
||||
public func assertClose<T>(
|
||||
_ expected: TestLiteralType,
|
||||
_ observed: T,
|
||||
allowedError: T = 16,
|
||||
@@ -69,7 +69,7 @@ func assertClose<T>(
|
||||
return ulps
|
||||
}
|
||||
|
||||
func assertClose<T>(
|
||||
public func assertClose<T>(
|
||||
_ expected: TestLiteralType,
|
||||
_ observed: T,
|
||||
allowedError: T = 16,
|
||||
@@ -82,7 +82,7 @@ func assertClose<T>(
|
||||
))
|
||||
}
|
||||
|
||||
internal protocol FixedWidthFloatingPoint: BinaryFloatingPoint
|
||||
public protocol FixedWidthFloatingPoint: BinaryFloatingPoint
|
||||
where Exponent: FixedWidthInteger,
|
||||
RawSignificand: FixedWidthInteger { }
|
||||
|
||||
@@ -20,4 +20,5 @@ target_link_libraries(ComplexTests PUBLIC
|
||||
$<$<NOT:$<PLATFORM_ID:Darwin>>:Foundation>
|
||||
ComplexModule
|
||||
Numerics
|
||||
_TestSupport
|
||||
XCTest)
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
import RealModule
|
||||
import XCTest
|
||||
import _TestSupport
|
||||
|
||||
final class ApproximateEqualityTests: XCTestCase {
|
||||
|
||||
|
||||
@@ -10,11 +10,11 @@ See https://swift.org/LICENSE.txt for license information
|
||||
add_library(RealTests
|
||||
ApproximateEqualityTests.swift
|
||||
ElementaryFunctionChecks.swift
|
||||
IntegerExponentTests.swift
|
||||
RealTestSupport.swift)
|
||||
IntegerExponentTests.swift)
|
||||
target_compile_options(RealTests PRIVATE
|
||||
-enable-testing)
|
||||
target_link_libraries(RealTests PUBLIC
|
||||
$<$<NOT:$<PLATFORM_ID:Darwin>>:Foundation>
|
||||
RealModule
|
||||
_TestSupport
|
||||
XCTest)
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
import XCTest
|
||||
import RealModule
|
||||
import _TestSupport
|
||||
|
||||
internal extension ElementaryFunctions where Self: BinaryFloatingPoint {
|
||||
static func elementaryFunctionChecks() {
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
|
||||
import XCTest
|
||||
import RealModule
|
||||
import _TestSupport
|
||||
|
||||
internal extension Real where Self: FixedWidthFloatingPoint {
|
||||
|
||||
|
||||
Reference in new issue
Block a user