forked from JuliaLang/julia
-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.jl
54 lines (46 loc) · 1.46 KB
/
client.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# This file is a part of Julia. License is MIT: https://julialang.org/license
nested_error_expr = quote
try
__not_a_binding__
catch
1 ÷ 0 # Generate error while handling error
end
end
nested_error_pattern = r"""
ERROR: DivideError: integer division error
Stacktrace:.*
caused by: UndefVarError: `__not_a_binding__` not defined
Stacktrace:.*
"""s
@testset "display_error" begin
# Display of errors which cause more than one entry on the exception stack
excs = try
eval(nested_error_expr)
catch
Base.current_exceptions()
end
@test typeof.(first.(excs)) == [UndefVarError, DivideError]
@test occursin(nested_error_pattern, sprint(Base.display_error, excs))
@test occursin(r"""
2-element ExceptionStack:
DivideError: integer division error
Stacktrace:.*
caused by: UndefVarError: `__not_a_binding__` not defined
Stacktrace:.*
"""s, sprint(show, excs))
end
@testset "Fallback REPL" begin
# Fallback REPL should show errors with display_error
errio = IOBuffer()
Base.eval_user_input(errio, nested_error_expr, true)
err_str = String(take!(errio))
@test occursin(nested_error_pattern, err_str)
end
@testset "display_error(io, er, bt) works" begin
errio = IOBuffer()
Base.display_error(errio, ErrorException, [])
err_str = String(take!(errio))
@test occursin(r"""
ERROR: ErrorException
"""s, err_str)
end