Skip to content

Commit fc03508

Browse files
fix build function test
1 parent bb93049 commit fc03508

File tree

1 file changed

+11
-11
lines changed

1 file changed

+11
-11
lines changed

test/build_function.jl

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ function h_julia!(out, a, b, c, d, e, g)
88
out .= [a[1] + b[1] + c[1] + c[2]; c[3] + d[1] + e[1] + g[1]]
99
end
1010

11-
h_str = ModelingToolkit.build_function(h, [a], [b], ([c1, c2, c3], [d], [e], [g]))
11+
h_str = ModelingToolkit.build_function(h, [a], [b], [c1, c2, c3], [d], [e], [g])
1212
h_oop = eval(h_str[1])
1313
h_ip! = eval(h_str[2])
1414
inputs = ([1], [2], [3, 4, 5], [6], [7], [8])
@@ -27,30 +27,30 @@ function h_julia_skip!(out, a, b, c, d, e, g)
2727
out .= [a[1] + b[1] + c[1]; c[2] + c[3] + g[1]]
2828
end
2929

30-
h_str_skip = ModelingToolkit.build_function(h_skip, [a], [b], ([c1, c2, c3], [], [], [g]))
31-
h_oop_skip = eval(h_str[1])
32-
h_ip!_skip = eval(h_str[2])
30+
h_str_skip = ModelingToolkit.build_function(h_skip, [a], [b], [c1, c2, c3], [], [], [g], checkbounds=true)
31+
h_oop_skip = eval(h_str_skip[1])
32+
h_ip!_skip = eval(h_str_skip[2])
3333
inputs_skip = ([1], [2], [3, 4, 5], [], [], [8])
3434

3535
@test h_oop_skip(inputs_skip...) == h_julia_skip(inputs_skip...)
3636
out_1_skip = Array{Int64}(undef, 2)
3737
out_2_skip = similar(out_1_skip)
3838
h_ip!_skip(out_1_skip, inputs_skip...)
39-
h_julia!_skip(out_2_skip, inputs_skip...)
39+
h_julia_skip!(out_2_skip, inputs_skip...)
4040
@test out_1_skip == out_2_skip
4141

4242
# Same as above, except test ability to call with non-matrix arguments (i.e., for `nt`)
4343
inputs_skip_2 = ([1], [2], [3, 4, 5], [], (a = 1, b = 2), [8])
44-
@test h_oop_skip_2(inputs_skip_2...) == h_julia_skip_2(inputs_skip_2...)
44+
@test h_oop_skip(inputs_skip_2...) == h_julia_skip(inputs_skip_2...)
4545
out_1_skip_2 = Array{Int64}(undef, 2)
4646
out_2_skip_2 = similar(out_1_skip_2)
47-
h_ip!_skip_2(out_1_skip_2, inputs_skip_2...)
48-
h_julia!_skip_2(out_2_skip_2, inputs_skip_2...)
47+
h_ip!_skip(out_1_skip_2, inputs_skip_2...)
48+
h_julia_skip!(out_2_skip_2, inputs_skip_2...)
4949
@test out_1_skip_2 == out_2_skip_2
5050

5151
# Multiple input scalar
5252
h_scalar = a + b + c1 + c2 + c3 + d + e + g
53-
h_julia_scalar(a, b, c, d, e, g) = a[1] + c[1]; c[2] + c[3] + d[1] + e[1] + g[1]
54-
h_str_scalar = ModelingToolkit.build_function(h_scalar, [a], [b], ([c1, c2, c3], [d], [e], [g]))
55-
h_oop_scalar = eval(h_str[1])
53+
h_julia_scalar(a, b, c, d, e, g) = a[1] + b[1] + c[1] + c[2] + c[3] + d[1] + e[1] + g[1]
54+
h_str_scalar = ModelingToolkit.build_function(h_scalar, [a], [b], [c1, c2, c3], [d], [e], [g])
55+
h_oop_scalar = eval(h_str_scalar)
5656
@test h_oop_scalar(inputs...) == h_julia_scalar(inputs...)

0 commit comments

Comments
 (0)