Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 30 additions & 7 deletions test/00/inputWired.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,38 @@ pass()
}

trap "fail" 1 2 3 15
cat >input.tcl <<EOF
source $here/test/assert.tcl
minsky.addOperation integrate
minsky.findObject Variable:integral
assert {[minsky.inputWired [minsky.canvas.item.valueId]]}
tcl_exit
cat >input.py <<EOF
import sys
sys.path.insert(0, '$here')
from pyminsky import minsky, findObject

# Add an integration operation to the canvas
minsky.canvas.addOperation("integrate")

# Use findObject to locate the integration operation (IntOp)
integrationOp = findObject("IntOp")
assert integrationOp is not None, "Integration operation not found or not focused"

# Use findObject to locate the integral variable (Variable:integral)
integralVariable = findObject("Variable:integral")
assert integralVariable is not None, "Integral variable not found or not focused"

# Match the integral variable's position with items in the model to retrieve valueId
value_id = None
for i in range(len(minsky.model.items)):
item = minsky.model.items[i]
if item.x() == integralVariable.x() and item.y() == integralVariable.y():

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Th Item::id() method is a more direct way of determining items match.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also - in this case, the items list will have exactly two items - an IntOp and a Variable::integral. So we could just examine Item::classType()

value_id = item.valueId()
break

# Ensure the value_id is valid
assert value_id is not None, "Integral variable does not have a valueId"

# Verify that the integral variable input is wired
assert minsky.inputWired(value_id), "Integral variable input is not wired"
EOF

$here/gui-tk/minsky input.tcl
python3 input.py
if [ $? -ne 0 ]; then fail; fi

pass