Skip to content

Commit

Permalink
Rework of StdlibInt+Floats.swift tests (#108) (#110).
Browse files Browse the repository at this point in the history
  • Loading branch information
oscbyspro committed Oct 29, 2024
1 parent b837384 commit 47ef173
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 321 deletions.
5 changes: 5 additions & 0 deletions Sources/TestKit2/Global+Types.swift
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,11 @@ public let typesAsCoreIntegersAsUnsigned: [any CoreIntegerAsUnsigned.Type] = [
// MARK: + Floats
//=----------------------------------------------------------------------------=

public let typesAsSwiftIEEE754: [any SwiftIEEE754.Type] = [
Float32.self,
Float64.self,
]

public let typesAsSwiftBinaryFloatingPoint: [any Swift.BinaryFloatingPoint.Type] = [
Float32.self,
Float64.self,
Expand Down
29 changes: 29 additions & 0 deletions Sources/TestKit2/Protocols/SwiftIEEE754.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
//=----------------------------------------------------------------------------=
// This source file is part of the Ultimathnum open source project.
//
// Copyright (c) 2023 Oscar Byström Ericsson
// Licensed under Apache License, Version 2.0
//
// See http://www.apache.org/licenses/LICENSE-2.0 for license information.
//=----------------------------------------------------------------------------=

//*============================================================================*
// MARK: * Swift IEEE 754
//*============================================================================*

public protocol SwiftIEEE754: Swift.BinaryFloatingPoint {

//=------------------------------------------------------------------------=
// MARK: Initializers
//=------------------------------------------------------------------------=

static func random(in range: Range<Self>, using randomness: inout some Swift.RandomNumberGenerator) -> Self
static func random(in range: ClosedRange<Self>, using randomness: inout some Swift.RandomNumberGenerator) -> Self
}

//*============================================================================*
// MARK: * Swift IEEE 754 x Models
//*============================================================================*

extension Float32: SwiftIEEE754 { }
extension Float64: SwiftIEEE754 { }
Loading

0 comments on commit 47ef173

Please sign in to comment.