Skip to content
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

Show evaluated test arguments for most functions #57825

Merged
merged 12 commits into from
Mar 21, 2025
Prev Previous commit
Next Next commit
Exclude broadcasted functions
omus committed Mar 19, 2025
commit c2627ad4a868c92ef2f70f3735ad1990c10ffef0
4 changes: 4 additions & 0 deletions stdlib/Test/src/Test.jl
Original file line number Diff line number Diff line change
@@ -586,6 +586,10 @@ end

function _is_simple_call(@nospecialize ex)
ex.head === :call || return false

# Broadcasted functions are not currently supported
first(string(ex.args[1])) != '.' || return false

num_pargs = 0
for x in ex.args[2:end]
if isa(x, Expr) && x.head === :parameters
10 changes: 10 additions & 0 deletions stdlib/Test/test/runtests.jl
Original file line number Diff line number Diff line change
@@ -168,6 +168,8 @@ let fails = @testset NoThrowTestSet begin
@test_throws r"sqrt\([Cc]omplx" sqrt(-1)
@test_throws str->occursin("a T", str) error("a test")
@test_throws ["BoundsError", "acquire", "1-element", "at index [2]"] [1][2]
# 29 - Fail - broadcast
@test 1 .== 2
end
for fail in fails
@test fail isa Test.Fail
@@ -314,6 +316,11 @@ let fails = @testset NoThrowTestSet begin
@test occursin(r"Message: \"BoundsError.* 1-element.*at index \[2\]", str)
end

let str = sprint(show, fails[29])
@test occursin("Expression: 1 .== 2", str)
@test !occursin("Evaluated", str)
end

end

struct BadError <: Exception end
@@ -1804,6 +1811,9 @@ end
@test !_is_simple_call(:(f(x...)))
@test !_is_simple_call(:(f(x, y...)))
@test !_is_simple_call(:(f(x; y...)))

@test _is_simple_call(:(x == y))
@test !_is_simple_call(:(x .== y))
end

@testset "_function_name" begin