Skip to content

Commit f48ad63

Browse files
committed
Make framework buildable on Linux. Fix tests on Linux.
1 parent efe1e3d commit f48ad63

File tree

10 files changed

+65
-22
lines changed

10 files changed

+65
-22
lines changed

Sources/NumberKit/BigInt.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
// limitations under the License.
1919
//
2020

21-
import Darwin
21+
import Foundation
2222

2323

2424
/// Class `BigInt` implements signed, arbitrary-precision integers. `BigInt` objects

Sources/NumberKit/Complex.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
// limitations under the License.
1919
//
2020

21-
import Darwin
21+
import Foundation
2222

2323

2424
/// The `ComplexNumber` protocol defines an interface for complex numbers. A complex

Sources/NumberKit/FloatingPointNumber.swift

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
// limitations under the License.
1919
//
2020

21-
import Darwin
21+
import Foundation
2222

2323

2424
/// Protocol `FloatingPointNumber` is used in combination with struct
@@ -51,28 +51,28 @@ extension Float: FloatingPointNumber {
5151
return Swift.abs(self)
5252
}
5353
public var sqrt: Float {
54-
return Darwin.sqrt(self)
54+
return Foundation.sqrt(self)
5555
}
5656
public var sin: Float {
57-
return Darwin.sin(self)
57+
return Foundation.sin(self)
5858
}
5959
public var cos: Float {
60-
return Darwin.cos(self)
60+
return Foundation.cos(self)
6161
}
6262
public var exp: Float {
63-
return Darwin.exp(self)
63+
return Foundation.exp(self)
6464
}
6565
public var log: Float {
66-
return Darwin.log(self)
66+
return Foundation.log(self)
6767
}
6868
public func pow(_ ex: Float) -> Float {
69-
return Darwin.pow(self, ex)
69+
return Foundation.pow(self, ex)
7070
}
7171
public func hypot(_ y: Float) -> Float {
72-
return Darwin.hypot(self, y)
72+
return Foundation.hypot(self, y)
7373
}
7474
public func atan2(_ y: Float) -> Float {
75-
return Darwin.atan2(self, y)
75+
return Foundation.atan2(self, y)
7676
}
7777
}
7878

@@ -85,27 +85,27 @@ extension Double: FloatingPointNumber {
8585
return Swift.abs(self)
8686
}
8787
public var sqrt: Double {
88-
return Darwin.sqrt(self)
88+
return Foundation.sqrt(self)
8989
}
9090
public var sin: Double {
91-
return Darwin.sin(self)
91+
return Foundation.sin(self)
9292
}
9393
public var cos: Double {
94-
return Darwin.cos(self)
94+
return Foundation.cos(self)
9595
}
9696
public var exp: Double {
97-
return Darwin.exp(self)
97+
return Foundation.exp(self)
9898
}
9999
public var log: Double {
100-
return Darwin.log(self)
100+
return Foundation.log(self)
101101
}
102102
public func pow(_ ex: Double) -> Double {
103-
return Darwin.pow(self, ex)
103+
return Foundation.pow(self, ex)
104104
}
105105
public func hypot(_ y: Double) -> Double {
106-
return Darwin.hypot(self, y)
106+
return Foundation.hypot(self, y)
107107
}
108108
public func atan2(_ y: Double) -> Double {
109-
return Darwin.atan2(self, y)
109+
return Foundation.atan2(self, y)
110110
}
111111
}

Sources/NumberKit/IntegerNumber.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
// limitations under the License.
1919
//
2020

21-
import Darwin
21+
import Foundation
2222

2323

2424
/// Protocol `IntegerNumber` is used in combination with struct `Rational<T>`.

Sources/NumberKit/Rational.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
// limitations under the License.
1919
//
2020

21-
import Darwin
21+
import Foundation
2222

2323

2424
/// The `RationalNumber` protocol defines an interface for rational numbers. A rational

Tests/LinuxMain.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#if os(Linux)
2+
13
import XCTest
24
@testable import NumberKitTests
35

@@ -9,3 +11,5 @@ XCTMain(
911
testCase(NumberUtilTests.allTests),
1012
]
1113
)
14+
15+
#endif

Tests/NumberKitTests/BigIntTests.swift

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,4 +356,25 @@ class BigIntTests: XCTestCase {
356356
let x3n = BigInt(stringLiteral: x3s)
357357
XCTAssertEqual(x3n.description, x3s)
358358
}
359+
360+
static let allTests = [
361+
("testConstructors", testConstructors),
362+
("testPlus", testPlus),
363+
("testMinus", testMinus),
364+
("testTimes", testTimes),
365+
("testDividedBy", testDividedBy),
366+
("testRemainder", testRemainder),
367+
("testSqrt", testSqrt),
368+
("testPowerOf", testPowerOf),
369+
("testDoubleConversion", testDoubleConversion),
370+
("testFloatConversion", testFloatConversion),
371+
("testAnd", testAnd),
372+
("testShifts", testShifts),
373+
("testBitCount", testBitCount),
374+
("testZeroBits", testZeroBits),
375+
("testBitTest", testBitTest),
376+
("testBitSet", testBitSet),
377+
("testWords", testWords),
378+
("testDescription", testDescription),
379+
]
359380
}

Tests/NumberKitTests/ComplexTests.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,4 +37,9 @@ class ComplexTests: XCTestCase {
3737
let c = 1.0.i
3838
XCTAssertEqual(c * c, -1)
3939
}
40+
41+
static let allTests = [
42+
("testConstructors", testConstructors),
43+
("testImaginaryInvariant", testImaginaryInvariant),
44+
]
4045
}

Tests/NumberKitTests/NumberUtilTests.swift

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,10 @@ class NumberUtilTests: XCTestCase {
5757
XCTAssertEqual(max(-1, 0), 0)
5858
XCTAssertEqual(max(0, -1), 0)
5959
}
60+
61+
static let allTests = [
62+
("testPow", testPow),
63+
("testPowOperator", testPowOperator),
64+
("testMinMax", testMinMax),
65+
]
6066
}

Tests/NumberKitTests/RationalTests.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ class RationalTests: XCTestCase {
5454
func testPlus() {
5555
let r1 = Rational(16348, 343).plus(24/7)
5656
XCTAssertEqual(r1, 17524/343)
57-
Swift.print("r1 = \(r1), other = \(17524/343)")
5857
XCTAssert(r1 == Rational(from: "17524/343"))
5958
XCTAssert(r1 == 17524/343)
6059
let r2: Rational<Int> = (74433/215).plus(312/15)
@@ -88,4 +87,12 @@ class RationalTests: XCTestCase {
8887
let r1 = Rational(10, -3).divided(by: -31/49)
8988
XCTAssertEqual(r1, Rational(10 * 49, 3 * 31))
9089
}
90+
91+
static let allTests = [
92+
("testConstructors", testConstructors),
93+
("testPlus", testPlus),
94+
("testMinus", testMinus),
95+
("testTimes", testTimes),
96+
("testDividedBy", testDividedBy),
97+
]
9198
}

0 commit comments

Comments
 (0)