-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
disable assert macro unless running in debug mode
- Loading branch information
1 parent
3559b72
commit ffa738c
Showing
12 changed files
with
190 additions
and
80 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -780,6 +780,7 @@ export | |
atreplinit, | ||
exit, | ||
ntuple, | ||
isdebug, | ||
|
||
# I/O and events | ||
close, | ||
|
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,60 @@ | ||
# This file is run from test/misc.jl separately since it needs to run with `-g2`. | ||
using Test | ||
|
||
# test @assert macro | ||
@test_throws AssertionError (@assert 1 == 2) | ||
@test_throws AssertionError (@assert false) | ||
@test_throws AssertionError (@assert false "this is a test") | ||
@test_throws AssertionError (@assert false "this is a test" "another test") | ||
@test_throws AssertionError (@assert false :a) | ||
let | ||
try | ||
@assert 1 == 2 | ||
error("unexpected") | ||
catch ex | ||
@test isa(ex, AssertionError) | ||
@test occursin("1 == 2", ex.msg) | ||
end | ||
end | ||
# test @assert message | ||
let | ||
try | ||
@assert 1 == 2 "this is a test" | ||
error("unexpected") | ||
catch ex | ||
@test isa(ex, AssertionError) | ||
@test ex.msg == "this is a test" | ||
end | ||
end | ||
# @assert only uses the first message string | ||
let | ||
try | ||
@assert 1 == 2 "this is a test" "this is another test" | ||
error("unexpected") | ||
catch ex | ||
@test isa(ex, AssertionError) | ||
@test ex.msg == "this is a test" | ||
end | ||
end | ||
# @assert calls string() on second argument | ||
let | ||
try | ||
@assert 1 == 2 :random_object | ||
error("unexpected") | ||
catch ex | ||
@test isa(ex, AssertionError) | ||
@test !occursin("1 == 2", ex.msg) | ||
@test occursin("random_object", ex.msg) | ||
end | ||
end | ||
# if the second argument is an expression, c | ||
let deepthought(x, y) = 42 | ||
try | ||
@assert 1 == 2 string("the answer to the ultimate question: ", | ||
deepthought(6, 9)) | ||
error("unexpected") | ||
catch ex | ||
@test isa(ex, AssertionError) | ||
@test ex.msg == "the answer to the ultimate question: 42" | ||
end | ||
end |
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
Oops, something went wrong.