From 072c6238727c9b94327a06a7e7d222067985753f Mon Sep 17 00:00:00 2001 From: Shashi Gowda Date: Fri, 16 Oct 2020 23:36:45 -0400 Subject: [PATCH] fuzz tests should soft-count failures --- test/fuzzlib.jl | 44 +++++++++++++++++++++++++------------------- test/interface.jl | 1 + 2 files changed, 26 insertions(+), 19 deletions(-) diff --git a/test/fuzzlib.jl b/test/fuzzlib.jl index ab0f2c4ce..6c249ee36 100644 --- a/test/fuzzlib.jl +++ b/test/fuzzlib.jl @@ -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 diff --git a/test/interface.jl b/test/interface.jl index 358913594..d773cd596 100644 --- a/test/interface.jl +++ b/test/interface.jl @@ -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