Skip to content

Commit 23f3fd1

Browse files
committed
fix the fuzz
1 parent 96311dd commit 23f3fd1

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

src/SymbolicUtils.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ include("types.jl")
1313

1414
# Methods on symbolic objects
1515
using SpecialFunctions, NaNMath
16-
import IfElse: ifelse # need to not bring IfElse name in or it will clash
16+
import IfElse: ifelse # need to not bring IfElse name in or it will clash with Rewriters.IfElse
1717
include("methods.jl")
1818

1919
# LinkedList, simplification utilities

src/types.jl

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -858,7 +858,13 @@ end
858858

859859
*(a::Pow, b::Mul) = b * a
860860

861-
_merge(f, d, others...; filter=x->false) = _merge!(f, copy(d), others...; filter=filter)
861+
function copy_similar(d, others)
862+
K = promote_type(keytype(d), keytype.(others)...)
863+
V = promote_type(valtype(d), valtype.(others)...)
864+
Dict{K, V}(d)
865+
end
866+
867+
_merge(f, d, others...; filter=x->false) = _merge!(f, copy_similar(d, others), others...; filter=filter)
862868
function _merge!(f, d, others...; filter=x->false)
863869
acc = d
864870
for other in others

test/fuzzlib.jl

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
using SymbolicUtils
2+
using SymbolicUtils: Term
3+
using SpecialFunctions
24
using Test
3-
using IfElse
5+
import IfElse: ifelse
6+
import IfElse
47

58
using SymbolicUtils: showraw, Symbolic
69

@@ -102,6 +105,9 @@ function gen_rand_expr(inputs;
102105
min_depth=min_depth,
103106
max_depth=max_depth)
104107
else
108+
@show f
109+
@show arity
110+
@show args
105111
rethrow(err)
106112
end
107113
end
@@ -115,9 +121,15 @@ function fuzz_test(ntrials, spec, simplify=simplify;kwargs...)
115121
inputs = Set()
116122
expr = gen_rand_expr(inputs; spec=spec, kwargs...)
117123
inputs = collect(inputs)
124+
code = try
125+
SymbolicUtils.Code.toexpr(expr)
126+
catch err
127+
@show expr
128+
rethrow(err)
129+
end
118130
unsimplifiedstr = """
119131
function $(tuple(inputs...))
120-
$(sprint(io->showraw(io, expr)))
132+
$(sprint(io->print(io, code)))
121133
end
122134
"""
123135

0 commit comments

Comments
 (0)