Skip to content

Commit

Permalink
Remove unused assert toggling
Browse files Browse the repository at this point in the history
Running testsuite *without* asserts takes roughly 150% or the time to
run it *with* asserts, probably because the compiler is helped by some
of the checks. The toggling is unused anyway, so delete it.
  • Loading branch information
fredrikekre committed Nov 20, 2024
1 parent 6eeb397 commit 6a31f28
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 49 deletions.
45 changes: 0 additions & 45 deletions src/ToggleableAsserts.jl

This file was deleted.

5 changes: 1 addition & 4 deletions src/debug.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
# Debug info #
##############

# Code derived from ToggleableAsserts.jl kept in a separate file
include("ToggleableAsserts.jl")

abstract type RunicException <: Exception end

struct AssertionError <: RunicException
Expand All @@ -23,7 +20,7 @@ function Base.showerror(io::IO, err::AssertionError)
return
end

function macroexpand_assert(expr)
macro assert(expr)
msg = string(expr)
return :($(esc(expr)) || throw(AssertionError($msg)))
end
Expand Down
18 changes: 18 additions & 0 deletions test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,24 @@ using JuliaSyntax:
end
end

@testset "Runic.AssertionError" begin
issuemsg = "This is unexpected, please file an issue with a reproducible example at " *
"https://github.com/fredrikekre/Runic.jl/issues/new."
try
Runic.@assert 1 == 2
catch err
@test err isa Runic.AssertionError
@test sprint(showerror, err) == "Runic.AssertionError: 1 == 2. " * issuemsg
end
try
Runic.unreachable()
catch err
@test err isa Runic.AssertionError
@test sprint(showerror, err) ==
"Runic.AssertionError: unreachable code reached. " * issuemsg
end
end

@testset "Chisels" begin
# Type stability of verified_kids
node = Runic.Node(JuliaSyntax.parseall(JuliaSyntax.GreenNode, "a = 1 + b\n"))
Expand Down

0 comments on commit 6a31f28

Please sign in to comment.