@@ -111,34 +111,40 @@ for turbo in [false, true], T in [Float16, Float32, Float64]
111
111
@test isnan (tree (X; turbo= turbo)[1 ])
112
112
end
113
113
114
- # And, with generic operator enum, this should be an actual error:
115
- operators = GenericOperatorEnum (; binary_operators= [+ , - , * , / ], unary_operators= [cos, sin])
116
- x1 = Node (Float64; feature= 1 )
117
- tree = sin (x1 / 0.0 )
118
- X = randn (Float32, 10 );
119
- @noinline stack = try
120
- tree (X)[1 ]
121
- @test false
122
- catch e
123
- @test e isa ErrorException
124
- # Check that "Failed to evaluate" is in the message:
125
- @test occursin (" Failed to evaluate" , e. msg)
126
- current_exceptions ()
127
- end ;
128
- @test length (stack) == 2
129
- @test stack[1 ]. exception isa DomainError
130
-
131
- # If a method is not defined, we should get a nothing:
132
- X = randn (Float32, 1 , 10 );
133
- @test tree (X; throw_errors= false ) === nothing
134
- # or a MethodError:
135
- @noinline stack = try
136
- tree (X; throw_errors= true )
137
- @test false
138
- catch e
139
- @test e isa ErrorException
140
- @test occursin (" Failed to evaluate" , e. msg)
141
- current_exceptions ()
114
+ # Check if julia version >= 1.7:
115
+ if VERSION >= v " 1.7"
116
+ # And, with generic operator enum, this should be an actual error:
117
+ operators = GenericOperatorEnum (;
118
+ binary_operators= [+ , - , * , / ], unary_operators= [cos, sin]
119
+ )
120
+ x1 = Node (Float64; feature= 1 )
121
+ tree = sin (x1 / 0.0 )
122
+ X = randn (Float32, 10 )
123
+ local stack
124
+ try
125
+ tree (X)[1 ]
126
+ @test false
127
+ catch e
128
+ @test e isa ErrorException
129
+ # Check that "Failed to evaluate" is in the message:
130
+ @test occursin (" Failed to evaluate" , e. msg)
131
+ stack = current_exceptions ()
132
+ end
133
+ @test length (stack) == 2
134
+ @test stack[1 ]. exception isa DomainError
135
+
136
+ # If a method is not defined, we should get a nothing:
137
+ X = randn (Float32, 1 , 10 )
138
+ @test tree (X; throw_errors= false ) === nothing
139
+ # or a MethodError:
140
+ try
141
+ tree (X; throw_errors= true )
142
+ @test false
143
+ catch e
144
+ @test e isa ErrorException
145
+ @test occursin (" Failed to evaluate" , e. msg)
146
+ stack = current_exceptions ()
147
+ end
148
+ @test length (stack) == 2
149
+ @test stack[1 ]. exception isa MethodError
142
150
end
143
- @test length (stack) == 2
144
- @test stack[1 ]. exception isa MethodError
0 commit comments