Refactor test/ranges.jl range construction#39806
Conversation
e9a437d to
3229823
Compare
| @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.
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.
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)
jw3126
left a comment
There was a problem hiding this comment.
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. |
|
This PR has had no activity for two years+, so I'll close it as stale. @mkitti If you're still interested in working on this PR, let me know, and I can re-open it. |
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
letblock rather than repeatedly callingfirst,last,step, andlength. Theletblock 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
rangeare 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: