-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor constraints and tests. Remove NaN conversions.
- Copy constraints from the golang.org/x/constraints package. - Improve type constraints in functions to only accept values that make sense. - Prevent ever converting a NaN from float64 to float32 or vice-versa. - Remove the 'testify' test dependency. - Add a bunch of test cases. Signed-off-by: Matt Dale <[email protected]>
- Loading branch information
1 parent
4f5be5e
commit b9a94bc
Showing
5 changed files
with
502 additions
and
400 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright 2021 The Go Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style | ||
// license that can be found in the LICENSE file. | ||
|
||
package gmath | ||
|
||
// Signed is a constraint that permits any signed integer type. | ||
// If future releases of Go add new predeclared signed integer types, | ||
// this constraint will be modified to include them. | ||
type Signed interface { | ||
~int | ~int8 | ~int16 | ~int32 | ~int64 | ||
} | ||
|
||
// Unsigned is a constraint that permits any unsigned integer type. | ||
// If future releases of Go add new predeclared unsigned integer types, | ||
// this constraint will be modified to include them. | ||
type Unsigned interface { | ||
~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr | ||
} | ||
|
||
// Integer is a constraint that permits any integer type. | ||
// If future releases of Go add new predeclared integer types, | ||
// this constraint will be modified to include them. | ||
type Integer interface { | ||
Signed | Unsigned | ||
} | ||
|
||
// Float is a constraint that permits any floating-point type. | ||
// If future releases of Go add new predeclared floating-point types, | ||
// this constraint will be modified to include them. | ||
type Float interface { | ||
~float32 | ~float64 | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.