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

add helpful error to malformed @test_throws and @test_warn #53839

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

sjkelly
Copy link
Contributor

@sjkelly sjkelly commented Mar 25, 2024

When using the @test_throws with a single argument, the following error appears:

julia> using Test

julia> @test_throws foo
ERROR: LoadError: MethodError: no method matching var"@test_throws"(::LineNumberNode, ::Module, ::Symbol)

Closest candidates are:
  var"@test_throws"(::LineNumberNode, ::Module, ::Any, ::Any)
   @ Test ~/.julia/juliaup/julia-1.10.2+0.aarch64.apple.darwin14/share/julia/stdlib/v1.10/Test/src/Test.jl:761

in expression starting at REPL[2]:1

The corrective action is not immediately obvious. This PR makes that so:

julia> using Test

julia> @test_throws foo
ERROR: Incorrect usage of the `@test_throws` macro, expected format: `@test_throws exception expr`
Stacktrace:
 [1] error(s::String)
   @ Base ./error.jl:35
 [2] top-level scope
   @ REPL[2]:1

When using the `@test_throws` with a single argument,
the following error appears:

```
julia> using Test

julia> @test_throws foo
ERROR: LoadError: MethodError: no method matching var"@test_throws"(::LineNumberNode, ::Module, ::Symbol)

Closest candidates are:
  var"@test_throws"(::LineNumberNode, ::Module, ::Any, ::Any)
   @ Test ~/.julia/juliaup/julia-1.10.2+0.aarch64.apple.darwin14/share/julia/stdlib/v1.10/Test/src/Test.jl:761

in expression starting at REPL[2]:1
```

The corrective action is not immediately obvious. This PR makes that so:

```
julia> using Test

julia> @test_throws foo
ERROR: Incorrect usage of the `@test_throws` macro, expected format: `@test_throws exception expr`
Stacktrace:
 [1] error(s::String)
   @ Base ./error.jl:35
 [2] top-level scope
   @ REPL[2]:1
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant