Skip to content

Commit 8702a47

Browse files
committed
Fix method error
1 parent 9793809 commit 8702a47

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

test/test_error_handling.jl

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,20 @@ using DynamicExpressions
22
using Test
33

44
# Test that we generate errors:
5+
baseT = Float64
6+
T = Union{baseT,Vector{baseT},Matrix{baseT}}
7+
58
scalar_add(x::T, y::T) where {T<:Real} = x + y
9+
610
operators = GenericOperatorEnum(; binary_operators=[scalar_add], extend_user_operators=true)
7-
tree = scalar_add(x1, x2)
11+
12+
x1, x2, x3 = [Node(T; feature=i) for i in 1:3]
13+
14+
tree = Node(1, x1, x2)
815

916
# With error handling:
1017
try
11-
eval_tree_array(tree, [[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]], operators; catch_errors=true)
18+
eval_tree_array(tree, [[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]], operators; throw_errors=true)
1219
@test false
1320
catch e
1421
@test isa(e, ErrorException)
@@ -18,7 +25,7 @@ end
1825

1926
# Without error handling:
2027
output, flag = eval_tree_array(
21-
tree, [[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]], operators; catch_errors=false
28+
tree, [[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]], operators; throw_errors=false
2229
)
2330
@test output === nothing
2431
@test !flag
@@ -32,4 +39,4 @@ catch e
3239
end
3340

3441
# But can be overrided:
35-
output = tree([[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]]; catch_errors=false)
42+
output = tree([[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]]; throw_errors=false)

0 commit comments

Comments
 (0)