Enable opt-in SwiftLint rules

Lint all schemes
This commit is contained in:
Alejandro Isaza 2017-11-25 12:17:56 -08:00
parent d893bff5cf
commit e5445f0db8
27 changed files with 189 additions and 67 deletions

View File

@ -5,5 +5,61 @@ disabled_rules:
- trailing_comma
opt_in_rules:
- array_init
- attributes
- closure_end_indentation
- closure_spacing
- conditional_returns_on_newline
- contains_over_first_not_nil
- empty_count
- explicit_enum_raw_value
- explicit_init
- extension_access_modifier
- fatal_error_message
- file_header
- first_where
- implicit_return
- implicitly_unwrapped_optional
- joined_default_parameter
- let_var_whitespace
- literal_expression_end_indentation
- multiline_arguments
- multiline_parameters
- nimble_operator
- no_extension_access_modifier
- number_separator
- object_literal
- overridden_super_call
- pattern_matching_keywords
- private_outlet
- prohibited_super_call
- quick_discouraged_call
- redundant_nil_coalescing
- single_test_class
- sorted_imports
- strict_fileprivate
- switch_case_on_newline
- unneeded_parentheses_in_closure_argument
- vertical_parameter_alignment_on_call
file_header:
required_pattern: |
\/\/ Copyright © .*
\/\/
\/\/ Permission is hereby granted, free of charge, to any person obtaining a copy
\/\/ of this software and associated documentation files \(the "Software"\), to deal
\/\/ in the Software without restriction, including without limitation the rights
\/\/ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
\/\/ copies of the Software, and to permit persons to whom the Software is
\/\/ furnished to do so, subject to the following conditions:
\/\/
\/\/ The above copyright notice and this permission notice shall be included in
\/\/ all copies or substantial portions of the Software\.
\/\/
\/\/ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
\/\/ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
\/\/ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
\/\/ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
\/\/ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
\/\/ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
\/\/ THE SOFTWARE\.

View File

@ -1,4 +1,4 @@
Copyright (c) 2014 Mattt Thompson (http://mattt.me/)
Copyright © 2014 Mattt Thompson (http://mattt.me/)
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal

View File

@ -1,6 +1,6 @@
// swift-tools-version:4.0
//
// Copyright (c) 20142015 Mattt Thompson (http://mattt.me)
// Copyright © 20142015 Mattt Thompson (http://mattt.me)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@ -1,4 +1,4 @@
// Copyright (c) 20142015 Mattt Thompson (http://mattt.me)
// Copyright © 20142015 Mattt Thompson (http://mattt.me)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@ -1,4 +1,4 @@
// Copyright (c) 20142015 Mattt Thompson (http://mattt.me)
// Copyright © 20142015 Mattt Thompson (http://mattt.me)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@ -1,4 +1,4 @@
// Copyright (c) 2017 Alejandro Isaza
// Copyright © 2017 Alejandro Isaza
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@ -1,5 +1,5 @@
// Copyright (c) 20142015 Mattt Thompson (http://mattt.me)
// Copyright (c) 2015-2016 Remy Prechelt
// Copyright © 20142015 Mattt Thompson (http://mattt.me)
// Copyright © 2015-2016 Remy Prechelt
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@ -1,4 +1,4 @@
// Copyright (c) 20142015 Mattt Thompson (http://mattt.me)
// Copyright © 20142015 Mattt Thompson (http://mattt.me)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@ -1,4 +1,4 @@
// Copyright (c) 20142015 Mattt Thompson (http://mattt.me)
// Copyright © 20142015 Mattt Thompson (http://mattt.me)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@ -1,4 +1,4 @@
// Copyright (c) 20142015 Mattt Thompson (http://mattt.me)
// Copyright © 20142015 Mattt Thompson (http://mattt.me)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@ -1,4 +1,4 @@
// Copyright (c) 20142015 Mattt Thompson (http://mattt.me)
// Copyright © 20142015 Mattt Thompson (http://mattt.me)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@ -95,7 +95,7 @@ public struct Matrix<Scalar> where Scalar: FloatingPoint, Scalar: ExpressibleByF
}
}
fileprivate func indexIsValidForRow(_ row: Int, column: Int) -> Bool {
private func indexIsValidForRow(_ row: Int, column: Int) -> Bool {
return row >= 0 && row < rows && column >= 0 && column < columns
}
}

View File

@ -1,4 +1,4 @@
// Copyright (c) 2017 Alejandro Isaza
// Copyright © 2017 Alejandro Isaza
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@ -26,7 +26,7 @@
@discardableResult
public func withUnsafeBufferPointersTo<A: ContinuousCollection, Result>(_ a: A, body: (UnsafeBufferPointer<A.Element>) throws -> Result) rethrows -> Result {
return try a.withUnsafeBufferPointer { (a: UnsafeBufferPointer<A.Element>) throws -> Result in
return try body(a)
try body(a)
}
}
@ -84,8 +84,8 @@ public func withUnsafeMutablePointersTo<A, B, Result>(_ a: inout A, _ b: inout B
@discardableResult
public func withUnsafeBufferPointersTo<A: ContinuousCollection, B: ContinuousCollection, Result>(_ a: A, _ b: B, body: (UnsafeBufferPointer<A.Element>, UnsafeBufferPointer<B.Element>) throws -> Result) rethrows -> Result {
return try a.withUnsafeBufferPointer { (a: UnsafeBufferPointer<A.Element>) throws -> Result in
return try b.withUnsafeBufferPointer { (b: UnsafeBufferPointer<B.Element>) throws -> Result in
return try body(a, b)
try b.withUnsafeBufferPointer { (b: UnsafeBufferPointer<B.Element>) throws -> Result in
try body(a, b)
}
}
}
@ -96,8 +96,8 @@ public func withUnsafeBufferPointersTo<A: ContinuousCollection, B: ContinuousCol
@discardableResult
public func withUnsafeMutableBufferPointersTo<A: ContinuousMutableCollection, B: ContinuousMutableCollection, Result>(_ a: inout A, _ b: inout B, body: (UnsafeMutableBufferPointer<A.Element>, UnsafeMutableBufferPointer<B.Element>) throws -> Result) rethrows -> Result {
return try a.withUnsafeMutableBufferPointer { (a: inout UnsafeMutableBufferPointer<A.Element>) throws -> Result in
return try b.withUnsafeMutableBufferPointer { (b: inout UnsafeMutableBufferPointer<B.Element>) throws -> Result in
return try body(a, b)
try b.withUnsafeMutableBufferPointer { (b: inout UnsafeMutableBufferPointer<B.Element>) throws -> Result in
try body(a, b)
}
}
}
@ -164,9 +164,9 @@ public func withUnsafeMutablePointersTo<A, B, C, Result>(_ a: inout A, _ b: inou
@discardableResult
public func withUnsafeBufferPointersTo<A: ContinuousCollection, B: ContinuousCollection, C: ContinuousCollection, Result>(_ a: A, _ b: B, _ c: inout C, body: (UnsafeBufferPointer<A.Element>, UnsafeBufferPointer<B.Element>, UnsafeBufferPointer<C.Element>) throws -> Result) rethrows -> Result {
return try a.withUnsafeBufferPointer { (a: UnsafeBufferPointer<A.Element>) throws -> Result in
return try b.withUnsafeBufferPointer { (b: UnsafeBufferPointer<B.Element>) throws -> Result in
return try c.withUnsafeBufferPointer { (c: UnsafeBufferPointer<C.Element>) throws -> Result in
return try body(a, b, c)
try b.withUnsafeBufferPointer { (b: UnsafeBufferPointer<B.Element>) throws -> Result in
try c.withUnsafeBufferPointer { (c: UnsafeBufferPointer<C.Element>) throws -> Result in
try body(a, b, c)
}
}
}
@ -178,9 +178,9 @@ public func withUnsafeBufferPointersTo<A: ContinuousCollection, B: ContinuousCol
@discardableResult
public func withUnsafeMutableBufferPointersTo<A: ContinuousMutableCollection, B: ContinuousMutableCollection, C: ContinuousMutableCollection, Result>(_ a: inout A, _ b: inout B, _ c: inout C, body: (UnsafeMutableBufferPointer<A.Element>, UnsafeMutableBufferPointer<B.Element>, UnsafeMutableBufferPointer<C.Element>) throws -> Result) rethrows -> Result {
return try a.withUnsafeMutableBufferPointer { (a: inout UnsafeMutableBufferPointer<A.Element>) throws -> Result in
return try b.withUnsafeMutableBufferPointer { (b: inout UnsafeMutableBufferPointer<B.Element>) throws -> Result in
return try c.withUnsafeMutableBufferPointer { (c: inout UnsafeMutableBufferPointer<C.Element>) throws -> Result in
return try body(a, b, c)
try b.withUnsafeMutableBufferPointer { (b: inout UnsafeMutableBufferPointer<B.Element>) throws -> Result in
try c.withUnsafeMutableBufferPointer { (c: inout UnsafeMutableBufferPointer<C.Element>) throws -> Result in
try body(a, b, c)
}
}
}

View File

@ -1,4 +1,4 @@
// Copyright (c) 20142015 Mattt Thompson (http://mattt.me)
// Copyright © 20142015 Mattt Thompson (http://mattt.me)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@ -1,4 +1,4 @@
// Copyright (c) 20142015 Mattt Thompson (http://mattt.me)
// Copyright © 20142015 Mattt Thompson (http://mattt.me)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@ -1,4 +1,4 @@
// Copyright (c) 20142015 Mattt Thompson (http://mattt.me)
// Copyright © 20142015 Mattt Thompson (http://mattt.me)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal

View File

@ -1,6 +1,26 @@
// Copyright © 20142015 Mattt Thompson (http://mattt.me)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
import Foundation
import Surge
import PlaygroundSupport
import Surge
// MARK: - Arithmetic

View File

@ -352,6 +352,7 @@
614AD31B1FC0AD99002BFE1C /* Frameworks */,
614AD31C1FC0AD99002BFE1C /* Headers */,
614AD31D1FC0AD99002BFE1C /* Resources */,
614294D91FCA01310036B903 /* Lint */,
);
buildRules = (
);
@ -388,6 +389,7 @@
614AD34D1FC0B001002BFE1C /* Frameworks */,
614AD34E1FC0B001002BFE1C /* Headers */,
614AD34F1FC0B001002BFE1C /* Resources */,
614294DA1FCA01440036B903 /* Lint */,
);
buildRules = (
);
@ -424,6 +426,7 @@
614AD37E1FC0B125002BFE1C /* Frameworks */,
614AD37F1FC0B125002BFE1C /* Headers */,
614AD3801FC0B125002BFE1C /* Resources */,
614294DB1FCA01520036B903 /* Lint */,
);
buildRules = (
);
@ -589,6 +592,51 @@
/* End PBXResourcesBuildPhase section */
/* Begin PBXShellScriptBuildPhase section */
614294D91FCA01310036B903 /* Lint */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = Lint;
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if which swiftlint >/dev/null; then\n swiftlint\nelse\n echo \"warning: SwiftLint not installed, `brew install swiftlint` or download from https://github.com/realm/SwiftLint\"\nfi";
showEnvVarsInLog = 0;
};
614294DA1FCA01440036B903 /* Lint */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = Lint;
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if which swiftlint >/dev/null; then\n swiftlint\nelse\n echo \"warning: SwiftLint not installed, `brew install swiftlint` or download from https://github.com/realm/SwiftLint\"\nfi";
showEnvVarsInLog = 0;
};
614294DB1FCA01520036B903 /* Lint */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;
files = (
);
inputPaths = (
);
name = Lint;
outputPaths = (
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "if which swiftlint >/dev/null; then\n swiftlint\nelse\n echo \"warning: SwiftLint not installed, `brew install swiftlint` or download from https://github.com/realm/SwiftLint\"\nfi";
showEnvVarsInLog = 0;
};
61AA2D731F78CF4E00B28C43 /* Lint */ = {
isa = PBXShellScriptBuildPhase;
buildActionMask = 2147483647;

View File

@ -15,7 +15,7 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "614AD3811FC0B125002BFE1C"
BuildableName = "Surge_watchOS.framework"
BuildableName = "Surge.framework"
BlueprintName = "Surge-watchOS"
ReferencedContainer = "container:Surge.xcodeproj">
</BuildableReference>
@ -48,7 +48,7 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "614AD3811FC0B125002BFE1C"
BuildableName = "Surge_watchOS.framework"
BuildableName = "Surge.framework"
BlueprintName = "Surge-watchOS"
ReferencedContainer = "container:Surge.xcodeproj">
</BuildableReference>
@ -66,7 +66,7 @@
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "614AD3811FC0B125002BFE1C"
BuildableName = "Surge_watchOS.framework"
BuildableName = "Surge.framework"
BlueprintName = "Surge-watchOS"
ReferencedContainer = "container:Surge.xcodeproj">
</BuildableReference>

View File

@ -1,4 +1,4 @@
// Copyright (c) 20142015 Mattt Thompson (http://mattt.me)
// Copyright © 20142015 Mattt Thompson (http://mattt.me)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@ -23,7 +23,7 @@ import Surge
import XCTest
class ArithmeticTests: XCTestCase {
let n = 100000
let n = 100_000
func test_sum() {
let values = (0...n).map { _ in Double(arc4random()) / Double(UInt32.max) }
@ -57,7 +57,7 @@ class ArithmeticTests: XCTestCase {
func test_sqrt() {
let values = (0...n).map { _ in Double(arc4random()) }
measureAndValidateMappedFunctionWithAccuracy(source: values, member: sqrt, mapped: sqrt, accuracy: 0.0001)
measureAndValidateMappedFunctionWithAccuracy(source: values, member: sqrt, mapped: sqrt, accuracy: 1e-4)
}
func test_sqrt_empty() {

View File

@ -1,4 +1,4 @@
// Copyright (c) 20142015 Mattt Thompson (http://mattt.me)
// Copyright © 20142015 Mattt Thompson (http://mattt.me)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@ -23,7 +23,7 @@ import Surge
import XCTest
class AuxiliaryTests: XCTestCase {
let n = 10000
let n = 10_000
func test_copysign() {
let signs = Array((0..<n).map({ $0 % 2 == 0 ? 1.0 : -1.0 }))

View File

@ -1,5 +1,4 @@
// Copyright (c) 20142015 Mattt Thompson (http://mattt.me)
// Copyright (c) 2015-2016 Remy Prechelt
// Copyright © 2016 Remy Prechelt, Mattt Thompson (http://mattt.me)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@ -24,8 +23,8 @@ import Surge
import XCTest
class ConvolutionTests: XCTestCase {
let floatAccuracy: Float = 0.00000001
let doubleAccuracy: Double = 0.00000000001
let floatAccuracy: Float = 1e-8
let doubleAccuracy: Double = 1e-11
// MARK: Test Arrays - Float
let a1f: [Float] = [0, 0, 1, 0, 0]

View File

@ -1,4 +1,4 @@
// Copyright (c) 20142015 Mattt Thompson (http://mattt.me)
// Copyright © 20142015 Mattt Thompson (http://mattt.me)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@ -23,15 +23,15 @@ import Surge
import XCTest
class ExponentialTests: XCTestCase {
let n = 10000
let n = 10_000
func test_exp() {
let values = (0...n).map { _ in Double(arc4random_uniform(10)) }
measureAndValidateMappedFunctionWithAccuracy(source: values, member: exp, mapped: exp, accuracy: 0.0001)
measureAndValidateMappedFunctionWithAccuracy(source: values, member: exp, mapped: exp, accuracy: 1e-4)
}
func test_exp2() {
let values = (0...n).map { _ in Double(arc4random_uniform(10)) }
measureAndValidateMappedFunctionWithAccuracy(source: values, member: exp2, mapped: exp2, accuracy: 0.0001)
measureAndValidateMappedFunctionWithAccuracy(source: values, member: exp2, mapped: exp2, accuracy: 1e-4)
}
}

View File

@ -1,4 +1,4 @@
// Copyright (c) 20142015 Mattt Thompson (http://mattt.me)
// Copyright © 20142015 Mattt Thompson (http://mattt.me)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@ -23,35 +23,35 @@ import Surge
import XCTest
class HyperbolicTests: XCTestCase {
let n = 10000
let n = 10_000
func test_sinh() {
let values = (0...n).map { _ in drand48() * Double.pi }
measureAndValidateMappedFunctionWithAccuracy(source: values, member: sinh, mapped: sinh, accuracy: 0.0001)
measureAndValidateMappedFunctionWithAccuracy(source: values, member: sinh, mapped: sinh, accuracy: 1e-4)
}
func test_cosh() {
let values = (0...n).map { _ in drand48() * Double.pi }
measureAndValidateMappedFunctionWithAccuracy(source: values, member: cosh, mapped: cosh, accuracy: 0.0001)
measureAndValidateMappedFunctionWithAccuracy(source: values, member: cosh, mapped: cosh, accuracy: 1e-4)
}
func test_tanh() {
let values = (0...n).map { _ in drand48() * Double.pi }
measureAndValidateMappedFunctionWithAccuracy(source: values, member: tanh, mapped: tanh, accuracy: 0.0001)
measureAndValidateMappedFunctionWithAccuracy(source: values, member: tanh, mapped: tanh, accuracy: 1e-4)
}
func test_asinh() {
let values = (0...n).map { _ in drand48() }
measureAndValidateMappedFunctionWithAccuracy(source: values, member: asinh, mapped: asinh, accuracy: 0.0001)
measureAndValidateMappedFunctionWithAccuracy(source: values, member: asinh, mapped: asinh, accuracy: 1e-4)
}
func test_acosh() {
let values = (0...n).map { _ in 1 + drand48() }
measureAndValidateMappedFunctionWithAccuracy(source: values, member: acosh, mapped: acosh, accuracy: 0.0001)
measureAndValidateMappedFunctionWithAccuracy(source: values, member: acosh, mapped: acosh, accuracy: 1e-4)
}
func test_atanh() {
let values = (0...n).map { _ in drand48() }
measureAndValidateMappedFunctionWithAccuracy(source: values, member: atanh, mapped: atanh, accuracy: 0.0001)
measureAndValidateMappedFunctionWithAccuracy(source: values, member: atanh, mapped: atanh, accuracy: 1e-4)
}
}

View File

@ -1,5 +1,4 @@
// Created by Wenbin Zhang on 2/13/16.
// Copyright (c) 20142015 Mattt Thompson (http://mattt.me)
// Copyright © 2016 Wenbin Zhang, Mattt Thompson (http://mattt.me)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@ -19,8 +18,8 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
import XCTest
@testable import Surge
import XCTest
class MatrixTests: XCTestCase {
@ -46,7 +45,7 @@ class MatrixTests: XCTestCase {
func testSetRow() {
matrix[row: 0] = [13.0, 14.0, 15.0, 16.0]
XCTAssertTrue(matrix==Matrix<Double>([[13, 14, 15, 16], [5, 6, 7, 8], [9, 10, 11, 12]]))
XCTAssertTrue(matrix == Matrix<Double>([[13, 14, 15, 16], [5, 6, 7, 8], [9, 10, 11, 12]]))
}
func testSetColumn() {

View File

@ -1,5 +1,5 @@
// Created by Wenbin Zhang on 2/13/16.
// Copyright (c) 20142015 Mattt Thompson (http://mattt.me)
// Copyright © 20142015 Mattt Thompson (http://mattt.me)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@ -19,8 +19,8 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
import XCTest
import Surge
import XCTest
class PowerTests: XCTestCase {

View File

@ -1,4 +1,4 @@
// Copyright (c) 20142015 Mattt Thompson (http://mattt.me)
// Copyright © 20142015 Mattt Thompson (http://mattt.me)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
@ -23,35 +23,35 @@ import Surge
import XCTest
class TrigonometricTests: XCTestCase {
let n = 10000
let n = 10_000
func test_sin() {
let values = (0...n).map { _ in drand48() * Double.pi }
measureAndValidateMappedFunctionWithAccuracy(source: values, member: sin, mapped: sin, accuracy: 0.0001)
measureAndValidateMappedFunctionWithAccuracy(source: values, member: sin, mapped: sin, accuracy: 1e-4)
}
func test_cos() {
let values = (0...n).map { _ in drand48() * Double.pi }
measureAndValidateMappedFunctionWithAccuracy(source: values, member: cos, mapped: cos, accuracy: 0.0001)
measureAndValidateMappedFunctionWithAccuracy(source: values, member: cos, mapped: cos, accuracy: 1e-4)
}
func test_tan() {
let values = (0...n).map { _ in drand48() * Double.pi }
measureAndValidateMappedFunctionWithAccuracy(source: values, member: tan, mapped: tan, accuracy: 0.0001)
measureAndValidateMappedFunctionWithAccuracy(source: values, member: tan, mapped: tan, accuracy: 1e-4)
}
func test_asin() {
let values = (0...n).map { _ in drand48() }
measureAndValidateMappedFunctionWithAccuracy(source: values, member: asin, mapped: asin, accuracy: 0.0001)
measureAndValidateMappedFunctionWithAccuracy(source: values, member: asin, mapped: asin, accuracy: 1e-4)
}
func test_acos() {
let values = (0...n).map { _ in drand48() }
measureAndValidateMappedFunctionWithAccuracy(source: values, member: acos, mapped: acos, accuracy: 0.0001)
measureAndValidateMappedFunctionWithAccuracy(source: values, member: acos, mapped: acos, accuracy: 1e-4)
}
func test_atan() {
let values = (0...n).map { _ in drand48() }
measureAndValidateMappedFunctionWithAccuracy(source: values, member: atan, mapped: atan, accuracy: 0.0001)
measureAndValidateMappedFunctionWithAccuracy(source: values, member: atan, mapped: atan, accuracy: 1e-4)
}
}

View File

@ -1,4 +1,4 @@
// Copyright (c) 20142015 Mattt Thompson (http://mattt.me)
// Copyright © 20142015 Mattt Thompson (http://mattt.me)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal