Skip to content

Commit 85f9a05

Browse files
committed
Tests for build_function fix
1 parent 4c271cc commit 85f9a05

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

test/build_function.jl

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,21 @@ h_oop_scalar = eval(h_str_scalar)
7171

7272
@test isequal(simplify(ModelingToolkit.unflatten_long_ops(prod(z))),
7373
simplify(prod(z)))
74+
75+
@variables t x(t) y(t) k
76+
f = eval(build_function((x+y)/k, [x,y,k]))
77+
@test f([1,1,2]) == 1
78+
79+
f = eval(build_function([(x+y)/k], [x,y,k])[1])
80+
@test f([1,1,2]) == [1]
81+
82+
f = eval(build_function([(x+y)/k], [x,y,k])[2])
83+
z = [0.0]
84+
f(z, [1,1,2])
85+
@test z == [1]
86+
87+
f = eval(build_function(sparse([1],[1], [(x+y)/k], 10,10), [x,y,k])[1])
88+
89+
@test size(f([1.,1.,2])) == (10,10)
90+
@test f([1.,1.,2])[1,1] == 1.0
91+
@test sum(f([1.,1.,2])) == 1.0

0 commit comments

Comments
 (0)