@@ -5,6 +5,50 @@ using Random, LinearAlgebra
5
5
# For curmod_*
6
6
include (" testenv.jl" )
7
7
8
+
9
+ @testset " SystemError" begin
10
+ err = try ; systemerror (" reason" , Cint (0 )); false ; catch ex; ex; end :: SystemError
11
+ errs = sprint (Base. showerror, err)
12
+ @test startswith (errs, " SystemError: reason: " )
13
+
14
+ err = try ; systemerror (" reason" , Cint (0 ), extrainfo= " addend" ); false ; catch ex; ex; end :: SystemError
15
+ errs = sprint (Base. showerror, err)
16
+ @test startswith (errs, " SystemError (with addend): reason: " )
17
+
18
+ err = try
19
+ Libc. errno (0xc0ffee )
20
+ systemerror (" reason" , true )
21
+ false
22
+ catch ex
23
+ ex
24
+ end :: SystemError
25
+ errs = sprint (Base. showerror, err)
26
+ @test startswith (errs, " SystemError: reason: " )
27
+
28
+ err = try ; Base. windowserror (" reason" , UInt32 (0 )); false ; catch ex; ex; end :: SystemError
29
+ errs = sprint (Base. showerror, err)
30
+ @test startswith (errs, Sys. iswindows () ? " SystemError: reason: " :
31
+ " SystemError (with Base.WindowsErrorInfo(0x00000000, nothing)): reason: " )
32
+
33
+ err = try ; Base. windowserror (" reason" , UInt32 (0 ); extrainfo= " addend" ); false ; catch ex; ex; end :: SystemError
34
+ errs = sprint (Base. showerror, err)
35
+ @test startswith (errs, Sys. iswindows () ? " SystemError (with addend): reason: " :
36
+ " SystemError (with Base.WindowsErrorInfo(0x00000000, \" addend\" )): reason: " )
37
+
38
+ @static if Sys. iswindows ()
39
+ err = try
40
+ ccall (:SetLastError , stdcall, Cvoid, (UInt32,), 0x00000000 )
41
+ Base. windowserror (" reason" , true )
42
+ false
43
+ catch ex
44
+ ex
45
+ end :: SystemError
46
+ errs = sprint (Base. showerror, err)
47
+ @test startswith (errs, " SystemError: reason: " )
48
+ end
49
+ end
50
+
51
+
8
52
cfile = " at $(@__FILE__ ) :"
9
53
c1line = @__LINE__ () + 1
10
54
method_c1 (x:: Float64 , s:: AbstractString... ) = true
@@ -593,4 +637,4 @@ for (func,str) in ((TestMethodShadow.:+,":+"), (TestMethodShadow.:(==),":(==)"),
593
637
e
594
638
end :: MethodError
595
639
@test occursin (" You may have intended to import Base.$str " , sprint (Base. showerror, ex))
596
- end
640
+ end
0 commit comments