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
use is_juliarepr
more in show.jl testing
#54304
base: master
Are you sure you want to change the base?
Conversation
@@ -248,6 +248,8 @@ end | |||
@test repr(:(∓ 1)) == ":(∓1)" | |||
@test repr(:(± 1)) == ":(±1)" | |||
|
|||
eval_parse_repr(x) = eval(Meta.parse(repr(x))) | |||
eval_parse_repr_test(x) = @test eval_parse_repr(x) == x |
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.
This makes the line numbers reported by a test failure worse.
julia> using Test
julia> @test 1==2
Test Failed at REPL[2]:1 <---- Just entered
Expression: 1 == 2
Evaluated: 1 == 2
ERROR: There was an error during testing
julia> @test 1==3
Test Failed at REPL[3]:1 <---- Just entered
Expression: 1 == 3
Evaluated: 1 == 3
ERROR: There was an error during testing
julia> test_eq_1(x) = @test x == 1
test_eq_1 (generic function with 1 method)
julia> test_eq_1(2)
Test Failed at REPL[4]:1 <----- where function defined
Expression: x == 1
Evaluated: 2 == 1
ERROR: There was an error during testing
julia> test_eq_1(3)
Test Failed at REPL[4]:1 <----- where function defined
Expression: x == 1
Evaluated: 3 == 1
ERROR: There was an error during testing
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.
So just make it return a bool and add back the @test
.
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.
We can have either line numbers or display the actual/expected values. I prefer displaying the actual/expected values (this) because we can always get line numbers from stack traces.
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.
What do you mean? As is, this is just worse than before. Finding the line number in the stacktrace is often not easy.
Just inline it back if it is an issue. Going around DRY-ing test code is seldom a good idea.
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.
What do you mean?
julia> f(x) = x == 5
f (generic function with 1 method)
julia> @test f(4)
Test Failed at REPL[15]:1
Expression: f(4)
ERROR: There was an error during testing
julia> g(x) = @test x == 5
g (generic function with 1 method)
julia> g(4)
Test Failed at REPL[16]:1
Expression: x == 5
Evaluated: 4 == 5
ERROR: There was an error during testing
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 not make the errors worse than before (e.g. the line for the test failure)
It used to be used a bunch, now it's used almost always where the construct appears.