-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor test/ranges.jl range construction #39806
base: master
Are you sure you want to change the base?
Conversation
e9a437d
to
3229823
Compare
test/ranges.jl
Outdated
@test q === range(; start, stop ) | ||
@test q == range(; start, stop, step ) | ||
@test q == range(; start, stop, length) | ||
@test q ≈ range(; stop, length) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we add @test_broken q == range(; stop, length)
? Not sure, equality seems very hard to achieve here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually on master I currently get equality:
julia> r = 2.8:20.0
2.8:1.0:19.8
julia> using Test
julia> let start=first(r), stop=last(r), step=step(r), length=length(r)
q = range(start, stop)
@test q == range(; stop, length)
end
Test Passed
julia> versioninfo()
Julia Version 1.7.0-DEV.551
Commit 9daf90ab49* (2021-02-16 19:40 UTC)
Platform Info:
OS: Windows (x86_64-w64-mingw32)
CPU: Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
WORD_SIZE: 64
LIBM: libopenlibm
LLVM: libLLVM-11.0.1 (ORCJIT, skylake)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this and all the energy you put into ranges. I have a package https://github.com/jw3126/RangeHelpers.jl where I experiment with ways to make range construction even more convenient. Would be interested in your opinion.
This looks interesting. You should be able to extend |
8cc86b8
to
e32fda2
Compare
Rebased |
I'm abandoning this. I think some similar changes may have been merged already. I will close this shortly after reviewing if any changes should be resubmitted. |
Refactor test/ranges.jl "range construction" testsets
Over several pull requests the inner
@testset "range(;kw...)"
in test/ranges.jl introduced in #38041 by @jw3126 to test the all keyword form of range was lost. Here we reintroduce it and add separate test sets forrange(start, stop)
andrange(start, stop, length)
.Let block and compact keyword syntax
The tests are also reformatted to use a
let
block rather than repeatedly callingfirst
,last
,step
, andlength
. Thelet
block also allows use to use the compact keyword calling syntax when the variable name matches the keyword name. Alignment is kept across the test sets.Additional malformed calls of ranges
Additionally, several malformed calls of
range
are added based on other pull requests where such forms were proposed and found to be problematic or otherwise declined.Summary
In summary, the refactor results in the following form with distinct tests groups for the
range(; kw...)
,range(start, stop)
, andrange(start, stop, length)
.History: