Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Sources/PropertyBased/Shrink+Float.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ extension Shrink {
current = bound
end = from

leap = (from / 2) - (bound / 2)
leap = from - bound
if leap.isNaN {
current = .nan
} else if leap.isInfinite {
Expand Down
10 changes: 10 additions & 0 deletions Tests/PropertyBasedTests/ShrinkTests+Float.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ import Testing
try #require(results.count > 1)
#expect(results.first == end)
#expect(!results.contains(start))

if start > end {
#expect(results.allSatisfy { $0 >= end })
} else {
#expect(results.allSatisfy { $0 <= end })
}
}

@Test func testShrinkWithNan() throws {
Expand Down Expand Up @@ -51,5 +57,9 @@ import Testing

let shrink5 = (20).shrink(within: 1.5...10)
#expect(shrink5.current == 1.5)

var shrink6 = (10.0).shrink(towards: 0)
_ = shrink6.next()
#expect(shrink6.current == 5)
}
}