diff --git a/test/clock.jl b/test/clock.jl index 7afd7572fb..96815cd1a2 100644 --- a/test/clock.jl +++ b/test/clock.jl @@ -298,44 +298,42 @@ eqs = [yd ~ Sample(dt)(y) ss = mtkcompile(cl) ss_nosplit = mtkcompile(cl; split = false) - if VERSION >= v"1.7" - prob = ODEProblem(ss, [x => 0.0, kp => 1.0], (0.0, 1.0)) - prob_nosplit = ODEProblem(ss_nosplit, [x => 0.0, kp => 1.0], (0.0, 1.0)) - sol = solve(prob, Tsit5(), kwargshandle = KeywordArgSilent) - sol_nosplit = solve(prob_nosplit, Tsit5(), kwargshandle = KeywordArgSilent) - - function foo!(dx, x, p, t) - kp, ud1, ud2 = p - dx[1] = -x[1] + ud1 + ud2 - end + prob = ODEProblem(ss, [x => 0.0, kp => 1.0], (0.0, 1.0)) + prob_nosplit = ODEProblem(ss_nosplit, [x => 0.0, kp => 1.0], (0.0, 1.0)) + sol = solve(prob, Tsit5(), kwargshandle = KeywordArgSilent) + sol_nosplit = solve(prob_nosplit, Tsit5(), kwargshandle = KeywordArgSilent) - function affect1!(integrator) - kp = integrator.p[1] - y = integrator.u[1] - r = 1.0 - ud1 = kp * (r - y) - integrator.p[2] = ud1 - nothing - end - function affect2!(integrator) - kp = integrator.p[1] - y = integrator.u[1] - r = 1.0 - ud2 = kp * (r - y) - integrator.p[3] = ud2 - nothing - end - cb1 = PeriodicCallback(affect1!, dt; final_affect = true, initial_affect = true) - cb2 = PeriodicCallback(affect2!, dt2; final_affect = true, initial_affect = true) - cb = CallbackSet(cb1, cb2) - # kp ud1 ud2 - prob = ODEProblem(foo!, [0.0], (0.0, 1.0), [1.0, 1.0, 1.0], callback = cb) - sol2 = solve(prob, Tsit5()) - - @test sol.u≈sol2.u atol=1e-6 - @test sol_nosplit.u≈sol2.u atol=1e-6 + function foo!(dx, x, p, t) + kp, ud1, ud2 = p + dx[1] = -x[1] + ud1 + ud2 end + function affect1!(integrator) + kp = integrator.p[1] + y = integrator.u[1] + r = 1.0 + ud1 = kp * (r - y) + integrator.p[2] = ud1 + nothing + end + function affect2!(integrator) + kp = integrator.p[1] + y = integrator.u[1] + r = 1.0 + ud2 = kp * (r - y) + integrator.p[3] = ud2 + nothing + end + cb1 = PeriodicCallback(affect1!, dt; final_affect = true, initial_affect = true) + cb2 = PeriodicCallback(affect2!, dt2; final_affect = true, initial_affect = true) + cb = CallbackSet(cb1, cb2) + # kp ud1 ud2 + prob = ODEProblem(foo!, [0.0], (0.0, 1.0), [1.0, 1.0, 1.0], callback = cb) + sol2 = solve(prob, Tsit5()) + + @test sol.u≈sol2.u atol=1e-6 + @test sol_nosplit.u≈sol2.u atol=1e-6 + ## @info "Testing hybrid system with components" using ModelingToolkitStandardLibrary.Blocks diff --git a/test/direct.jl b/test/direct.jl index ce2a3f5785..5f52a54fea 100644 --- a/test/direct.jl +++ b/test/direct.jl @@ -240,22 +240,20 @@ kwargs = (; name = 3) @test cool_name[1] == (42,) @test collect(cool_name[2]) == [:name => 3] -if VERSION >= v"1.5" - name = 3 - @named cool_name = foo(42; name) - @test cool_name[1] == (42,) - @test collect(cool_name[2]) == [:name => name] - @named cool_name = foo(; name) - @test collect(cool_name) == [:name => name] - - ff = 3 - @named cool_name = foo(42; ff) - @test cool_name[1] == (42,) - @test collect(cool_name[2]) == [pp; :ff => ff] - - @named cool_name = foo(; ff) - @test collect(cool_name) == [pp; :ff => ff] -end +name = 3 +@named cool_name = foo(42; name) +@test cool_name[1] == (42,) +@test collect(cool_name[2]) == [:name => name] +@named cool_name = foo(; name) +@test collect(cool_name) == [:name => name] + +ff = 3 +@named cool_name = foo(42; ff) +@test cool_name[1] == (42,) +@test collect(cool_name[2]) == [pp; :ff => ff] + +@named cool_name = foo(; ff) +@test collect(cool_name) == [pp; :ff => ff] foo(i; name) = (; i, name) @named goo[1:3] = foo(10) diff --git a/test/input_output_handling.jl b/test/input_output_handling.jl index e053584776..54fdbfc1b4 100644 --- a/test/input_output_handling.jl +++ b/test/input_output_handling.jl @@ -8,10 +8,8 @@ using ModelingToolkit: t_nounits as t, D_nounits as D eqs = [D(xx) ~ some_input] @named model = System(eqs, t) @test_throws ExtraVariablesSystemException mtkcompile(model) -if VERSION >= v"1.8" - err = "In particular, the unset input(s) are:\n some_input(t)" - @test_throws err mtkcompile(model) -end +err = "In particular, the unset input(s) are:\n some_input(t)" +@test_throws err mtkcompile(model) # Test input handling @variables x(t) u(t) [input = true] v(t)[1:2] [input = true]