From abb899865eb1c78abf7ab2edb15278dec7da936a Mon Sep 17 00:00:00 2001 From: Stephen Canon Date: Mon, 20 Sep 2021 09:53:38 -0400 Subject: [PATCH 1/2] resolve warnings in 5.5 tools build, add skeleton readme for integer utilities --- Package.swift | 14 ++++++-------- Sources/IntegerUtilities/README.md | 14 ++++++++++++++ 2 files changed, 20 insertions(+), 8 deletions(-) create mode 100644 Sources/IntegerUtilities/README.md diff --git a/Package.swift b/Package.swift index d526fe2..eba63bc 100644 --- a/Package.swift +++ b/Package.swift @@ -59,41 +59,39 @@ let package = Package( .target( name: "_TestSupport", dependencies: ["Numerics"], - exclude: excludedFilenames + exclude: ["CMakeLists.txt"] ), // MARK: - Unit test bundles .testTarget( name: "ComplexTests", dependencies: ["_TestSupport"], - exclude: excludedFilenames + exclude: ["CMakeLists.txt"] ), .testTarget( name: "IntegerUtilitiesTests", dependencies: ["IntegerUtilities"], - exclude: excludedFilenames + exclude: ["CMakeLists.txt"] ), .testTarget( name: "RealTests", dependencies: ["_TestSupport"], - exclude: excludedFilenames + exclude: ["CMakeLists.txt"] ), // MARK: - Test executables .target( name: "ComplexLog", dependencies: ["Numerics", "_TestSupport"], - path: "Tests/Executable/ComplexLog", - exclude: excludedFilenames + path: "Tests/Executable/ComplexLog" ), .target( name: "ComplexLog1p", dependencies: ["Numerics", "_TestSupport"], - path: "Tests/Executable/ComplexLog1p", - exclude: excludedFilenames + path: "Tests/Executable/ComplexLog1p" ) ] ) diff --git a/Sources/IntegerUtilities/README.md b/Sources/IntegerUtilities/README.md new file mode 100644 index 0000000..e531306 --- /dev/null +++ b/Sources/IntegerUtilities/README.md @@ -0,0 +1,14 @@ +# Integer Utilities + +## Utilities defined for `BinaryInteger` + +The following API are defined for all integer types conforming to `BinaryInteger`: + +- The `gcd(_:_:)` free function implements the _Greatest Common Divisor_ + operation. + +## Utilities defined for `FixedWidthInteger` + +- The `rotated(right:)` and `rotated(left:)` methods implement _bitwise + rotation_ for signed and unsigned integer types. The count parameter may + be any `BinaryInteger` type. From e22ff866a40e305aaa7f4f53338c7716cb919128 Mon Sep 17 00:00:00 2001 From: Stephen Canon Date: Mon, 20 Sep 2021 12:35:22 -0400 Subject: [PATCH 2/2] Add GCD files to CMake build. --- Sources/IntegerUtilities/CMakeLists.txt | 1 + Tests/IntegerUtilitiesTests/CMakeLists.txt | 1 + Tests/WindowsMain.swift | 7 +++++++ 3 files changed, 9 insertions(+) diff --git a/Sources/IntegerUtilities/CMakeLists.txt b/Sources/IntegerUtilities/CMakeLists.txt index f09216e..410df3a 100644 --- a/Sources/IntegerUtilities/CMakeLists.txt +++ b/Sources/IntegerUtilities/CMakeLists.txt @@ -8,6 +8,7 @@ See https://swift.org/LICENSE.txt for license information #]] add_library(IntegerUtilities + GCD.swift Rotate.swift) set_target_properties(IntegerUtilities PROPERTIES INTERFACE_INCLUDE_DIRECTORIES ${CMAKE_Swift_MODULE_DIRECTORY}) diff --git a/Tests/IntegerUtilitiesTests/CMakeLists.txt b/Tests/IntegerUtilitiesTests/CMakeLists.txt index 287cf1b..0b18d22 100644 --- a/Tests/IntegerUtilitiesTests/CMakeLists.txt +++ b/Tests/IntegerUtilitiesTests/CMakeLists.txt @@ -8,6 +8,7 @@ See https://swift.org/LICENSE.txt for license information #]] add_library(IntegerUtilitiesTests + GCDTests.swift RotateTests.swift) target_compile_options(IntegerUtilitiesTests PRIVATE -enable-testing) diff --git a/Tests/WindowsMain.swift b/Tests/WindowsMain.swift index b956a8c..d0336f5 100644 --- a/Tests/WindowsMain.swift +++ b/Tests/WindowsMain.swift @@ -90,6 +90,12 @@ extension RotateTests { ]) } +extension IntegerUtilitiesGCDTests { + static var all = testCase([ + ("testGCDInt", IntegerUtilitiesGCDTests.testGCDInt), + ]) +} + var testCases = [ ComplexTests.ApproximateEqualityTests.all, RealTests.ApproximateEqualityTests.all, @@ -98,6 +104,7 @@ var testCases = [ ArithmeticTests.all, PropertyTests.all, RotateTests.all, + IntegerUtilitiesGCDTests.all, ] #if swift(>=5.3) && canImport(_Differentiation)