From a119ef4aceb40d5ebb9898e71fe8dedf357127e3 Mon Sep 17 00:00:00 2001 From: Torkel Date: Sun, 21 Jul 2024 11:16:18 -0400 Subject: [PATCH] test fix --- .../coupled_equation_crn_systems.jl | 2 +- test/reactionsystem_core/reactionsystem.jl | 24 +++++++++++++++++++ 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/test/reactionsystem_core/coupled_equation_crn_systems.jl b/test/reactionsystem_core/coupled_equation_crn_systems.jl index 6bd57b925b..db7e14b887 100644 --- a/test/reactionsystem_core/coupled_equation_crn_systems.jl +++ b/test/reactionsystem_core/coupled_equation_crn_systems.jl @@ -993,7 +993,7 @@ let # Equation with variable using non-declared independent variable. @test_throws Exception ReactionSystem([ Reaction(p1, [S1], [S2]), - U1 ~ S1 + p2 + E(U1) ~ S1 + p2 ], t; name = :rs) # Differential with respect to non-declared independent variable. diff --git a/test/reactionsystem_core/reactionsystem.jl b/test/reactionsystem_core/reactionsystem.jl index 77ee4e0954..1ba9142bf1 100644 --- a/test/reactionsystem_core/reactionsystem.jl +++ b/test/reactionsystem_core/reactionsystem.jl @@ -628,6 +628,30 @@ let @test_throws Exception convert(NonlinearSystem, nc) end +# Checks that the same name cannot be used for two different of parameters/species/variables. +let + # Stores a parameter, a species, and a variable (with identical names) in different variables. + x_p = let + only(@parameters x) + end + x_sp = let + only(@species x(t)) + end + x_v = let + only(@variables x(t)) + end + + # Checks that creating systems with different in combination produces errors. + # Currently broken on MTK, potentially fix in Catalyst once sorted out there (https://github.com/SciML/ModelingToolkit.jl/issues/2883). + @parameters d + @species X(t) + rx = Reaction(d, [X], []) + @test_broken false # (not sure how to mark a `@test_throws` as broken) + # @test_throws rs1 = ReactionSystem([rx], t, [X, x_sp,], [d, x_p]; name = :rs) + # @test_throws rs2 = ReactionSystem([rx], t, [X, X, x_v], [d, x_p]; name = :rs) + # @test_throws rs2 = ReactionSystem([rx], t, [X, x_sp, x_v], [d]; name = :rs) +end + ### Other Tests ### # Test for https://github.com/SciML/ModelingToolkit.jl/issues/436.