-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
special case splat call printing, add basic tests for printing
- Loading branch information
Showing
5 changed files
with
118 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# NOTE: | ||
# tests in this file may not be so robust against the future changes in TypeProfiler.jl or | ||
# even those in julia itself | ||
|
||
@testset "print toplevel errors" begin | ||
let | ||
io = IOBuffer() | ||
s = """ | ||
a = begin | ||
b = | ||
end | ||
""" | ||
|
||
res, interp = profile_toplevel(s; filename = @__FILE__) | ||
print_reports(io, res.toplevel_error_reports) | ||
let s = String(take!(io)) | ||
@test occursin("1 toplevel error found", s) | ||
@test occursin(Regex("@ $(@__FILE__):\\d"), s) | ||
@test occursin("syntax: unexpected \"end\"", s) | ||
end | ||
|
||
res, interp = profile_toplevel(s; filename = "foo") | ||
print_reports(io, res.toplevel_error_reports) | ||
let s = String(take!(io)) | ||
@test occursin("1 toplevel error found", s) | ||
@test occursin(r"@ foo:\d", s) | ||
@test occursin("syntax: unexpected \"end\"", s) | ||
end | ||
end | ||
end | ||
|
||
# tests with Windows-paths is just an hell | ||
@static Sys.iswindows() || begin | ||
|
||
@testset "print inference errors" begin | ||
let | ||
res, interp = @profile_toplevel begin | ||
s = "julia" | ||
sum(s) | ||
end | ||
|
||
io = IOBuffer() | ||
@test print_reports(io, res.inference_error_reports) | ||
let s = String(take!(io)) | ||
@test occursin("2 possible errors found", s) | ||
@test occursin(Regex("@ $(escape_string(@__FILE__)):$((@__LINE__)-7)"), s) # toplevel call signature | ||
end | ||
end | ||
|
||
@testset "special case splat call signature" begin | ||
let | ||
vmod = gen_virtualmod() | ||
res, interp = @profile_toplevel vmod begin | ||
foo(args...) = sum(args) | ||
foo(rand(Char, 1000000000)...) | ||
end | ||
|
||
io = IOBuffer() | ||
postprocess = TypeProfiler.gen_postprocess(vmod, Main) | ||
@test print_reports(io, res.inference_error_reports, postprocess) | ||
let s = String(take!(io)) | ||
@test occursin("1 possible error found", s) | ||
@test occursin(Regex("@ $(escape_string(@__FILE__)):$((@__LINE__)-8)"), s) # toplevel call signature | ||
@test occursin("foo(rand(Char, 1000000000)...)", s) | ||
end | ||
end | ||
end | ||
end | ||
|
||
end # @static Sys.iswindows || |