Skip to content

Commit

Permalink
test: units passed to diff2term
Browse files Browse the repository at this point in the history
  • Loading branch information
ven-k committed Apr 3, 2024
1 parent 3d635e8 commit d32e23d
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
2 changes: 2 additions & 0 deletions test/downstream/Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
[deps]
ModelingToolkit = "961ee093-0014-501f-94e3-6117800e7a78"
ParameterizedFunctions = "65888b18-ceab-5e60-b2b9-181511a3b968"
Symbolics = "0c5d862f-8b57-4792-8d23-62f2024744c7"
Unitful = "1986cc42-f94f-5a68-af5c-568840ba703d"

[compat]
ModelingToolkit = "8.33, 9"
Expand Down
28 changes: 28 additions & 0 deletions test/downstream/modeling_toolkit_utils.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using Symbolics: diff2term
using ModelingToolkit
using ModelingToolkit: equivalent, get_unit, value, VariableUnit
using Unitful: @u_str
using Test

@variables t [unit = u"s"] k(t)
D = Differential(t)

@test equivalent(
u"1/s",
get_unit(
diff2term(
value(D(k)),
Dict(VariableUnit => get_unit(D(k)))
)
)
)

@test equivalent(
u"1/s^2",
get_unit(
diff2term(
value(D(D(k))),
Dict(VariableUnit => get_unit(D(D(k))))
)
)
)
3 changes: 2 additions & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ if GROUP == "All" || GROUP == "Core" || GROUP == "SymbolicIndexingInterface"
end
end

if GROUP == "Downstream"
if GROUP == "All" || GROUP == "Downstream"
activate_downstream_env()
#@time @safetestset "ParameterizedFunctions MATLABDiffEq Regression Test" begin include("downstream/ParameterizedFunctions_MATLAB.jl") end
@safetestset "ModelingToolkit Variable Utils Test" begin include("downstream/modeling_toolkit_utils.jl") end
end

0 comments on commit d32e23d

Please sign in to comment.