Skip to content

Commit

Permalink
fuzz tests should soft-count failures
Browse files Browse the repository at this point in the history
  • Loading branch information
shashi committed Oct 17, 2020
1 parent bb49dde commit 072c623
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 19 deletions.
44 changes: 25 additions & 19 deletions test/fuzzlib.jl
Original file line number Diff line number Diff line change
Expand Up @@ -140,28 +140,34 @@ function fuzz_test(ntrials, spec, simplify=simplify;kwargs...)
catch err
Errored(err)
end
try
if unsimplified isa Errored
@test simplified isa Errored
elseif isnan(unsimplified)
@test isnan(simplified)
if !isnan(simplified)
error("Failed")
end
else
@test unsimplified simplified
if !(unsimplified simplified)
error("Failed")
end
if unsimplified isa Errored
if !(simplified isa Errored)
@test_skip false
@goto print_err
end
catch err
println("""Test failed for expression
@test true
elseif isnan(unsimplified)
if !isnan(simplified)
@test_skip false
@goto print_err
end
@test true
else
if !(unsimplified simplified)
@test_skip false
@goto print_err
end
@test true
end
continue

@label print_err
println("""Test failed for expression
$(sprint(io->showraw(io, expr))) = $unsimplified
Simplified to:
Simplified:
$(sprint(io->showraw(io, simplify(expr)))) = $simplified
On inputs:
Inputs:
$inputs = $args
""")
end
""")
end
end
1 change: 1 addition & 0 deletions test/interface.jl
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,6 @@ SymbolicUtils.to_symbolic(ex::Expr) = ex
@test simplify(ex) == ex

SymbolicUtils.symtype(::Expr) = Real
SymbolicUtils.symtype(::Symbol) = Real
@test simplify(ex) == -1 + :x
@test simplify(:a * (:b + -1 * :c) + -1 * (:b * :a + -1 * :c * :a), polynorm=true) == 0

0 comments on commit 072c623

Please sign in to comment.