Skip to content

Commit 5eea47a

Browse files
committed
Include test of many operators to stress test @nif
1 parent 9aed074 commit 5eea47a

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

test/test_evaluation.jl

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,3 +158,20 @@ if VERSION >= v"1.7"
158158
@test stack[1].exception isa MethodError
159159
end
160160
end
161+
162+
@testset "Test many operators" begin
163+
# Since we use `@nif` in evaluating expressions,
164+
# we can see if there are any issues with LARGE numbers of operators.
165+
binary_operators = [@eval function (x, y)
166+
return x + y
167+
end for i in 1:100]
168+
unary_operators = [@eval function (x)
169+
return x^2
170+
end for i in 1:100]
171+
operators = OperatorEnum(; binary_operators, unary_operators)
172+
tree = Node(1, Node(50, Node(; val=3.0), Node(; feature=2)))
173+
# = (3.0 + x2)^2
174+
X = randn(Float64, 2, 10)
175+
truth = @. (3.0 + X[2, :])^2
176+
@test all(truth .≈ tree(X, operators))
177+
end

0 commit comments

Comments
 (0)