From 20767009abfa4218f11dae7bc369f60f09c75e12 Mon Sep 17 00:00:00 2001 From: wdednam Date: Wed, 18 Dec 2024 09:32:57 +0100 Subject: [PATCH] pythonised simpleIntegrationTest --- test/00/simpleIntegrationTest.sh | 125 ++++++++++++++++++------------- 1 file changed, 72 insertions(+), 53 deletions(-) diff --git a/test/00/simpleIntegrationTest.sh b/test/00/simpleIntegrationTest.sh index 7c93148b3..dc760c66b 100755 --- a/test/00/simpleIntegrationTest.sh +++ b/test/00/simpleIntegrationTest.sh @@ -30,59 +30,78 @@ pass() trap "fail" 1 2 3 15 -cat >input.tcl < {} - - minsky.load $here/examples/exponentialGrowth.mky - - getValue :y - assert {[value.value]==1} - - set item "minsky.canvas.item" - findObject VarConstant - set a [\$item.value] - assert {[minsky.canvas.item.value]!=0} - - # setting this flag prevents an extra reset occurring - used to - # distinguish between static plot updates and simulation - running 1 - minsky.reset - step - step - getValue :y - assert {[value.value]>0} - if {\$a<0} { - assert {[value.value]>0 && [value.value]<1} - } else { - assert {[value.value]>0 && [value.value]>1} - } - - set v [value.value] - - findObject IntOp - \$item.toggleCoupled - - minsky.reset - step - step - getValue :y - if {\$a<0} { - assert {[value.value]>0 && [value.value]<1} - } else { - assert {[value.value]>0 && [value.value]>1} - } - assert "\[value.value\]==\$v" - - tcl_exit -} - +cat >input.py < 0, "Value of :y after steps is not greater than 0." + +# Conditional check based on VarConstant value +if var_constant_value < 0: + assert 0 < y_value_after_step.value() < 1, "Expected :y to be between 0 and 1 for negative VarConstant." +else: + assert y_value_after_step.value() > 1, "Expected :y to be greater than 1 for positive VarConstant." + +stored_y_value = y_value_after_step.value() + +# Step 5: Toggle coupling for IntOp +findObject("IntOp") +minsky.canvas.item.toggleCoupled() +print("Toggled coupled state for IntOp.") + +# Step 6: Reset and rerun simulation +minsky.reset() +step() +step() + +y_value_after_toggle = getValue(":y") +if var_constant_value < 0: + assert 0 < y_value_after_toggle.value() < 1, "Expected :y to be between 0 and 1 for negative VarConstant." +else: + assert y_value_after_toggle.value() > 1, "Expected :y to be greater than 1 for positive VarConstant." + +assert y_value_after_toggle.value() == stored_y_value, "Value of :y does not match after toggling coupled state." EOF -$here/gui-tk/minsky input.tcl -if test $? -ne 0; then fail; fi + +python3 input.py +if [ $? -ne 0 ]; then fail; fi pass