Repository navigation
fix(faker): Keep range generators correct across their whole input domain - #104
Merged
Merged
Conversation
…main IntBetween computed max-min+1 in int, so a range such as [0, math.MaxInt] overflowed and panicked inside IntN; DateBetween relied on time.Duration, which saturates past about 292 years, so a 1700-2100 range panicked; and FloatBetween returned +Inf when max-min exceeded math.MaxFloat64. The span is now computed in uint64 for ints, long date ranges are drawn as seconds plus nanoseconds, and wide float ranges interpolate between the bounds. Ranges that already worked draw the same values as before. FloatBetween now states its contract and panics on reversed, NaN, or infinite bounds like the other range helpers.
The fmt-check targets judged success only by whether the formatter printed anything, so a formatter that failed silently, as with GOLANGCI_LINT=false, passed the check. The three targets now share one recipe that also fails on a non-zero exit status and reports which module failed.
Code Metrics Report
Details | | main (9a2b1f6) | #104 (db13c19) | +/- |
|---------------------|----------------|----------------|-------|
+ | Coverage | 86.9% | 86.9% | +0.0% |
| Files | 59 | 59 | 0 |
| Lines | 4791 | 4813 | +22 |
+ | Covered | 4165 | 4186 | +21 |
+ | Code to Test Ratio | 1:1.0 | 1:1.0 | +0.0 |
| Code | 17787 | 17821 | +34 |
+ | Test | 17916 | 17988 | +72 |
- | Test Execution Time | 1m11s | 1m21s | +10s |Code coverage of files in pull request scope (98.8% → 98.1%, patch 97.2%)
Reported by octocov |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
IntBetween,FloatBetween, andDateBetweenno longer panic or return infinity for very wide ranges, while ranges that already worked draw the same values for the same seedFloatBetweennow panics on reversed, NaN, or infinite bounds like the other range helpersmake fmt-checkfails when the formatter itself exits non-zero, not only when it prints a diffChanges
IntBetweencomputes its span in uint64, so ranges such as[0, math.MaxInt]and[math.MinInt, math.MaxInt]workDateBetweendraws seconds plus nanoseconds when the range exceedstime.Duration(about 292 years), keeping the location offromFloatBetweeninterpolates between the bounds whenmax-minoverflows and keeps results inside[min, max)