@@ -1514,14 +1514,12 @@ TEST(TensorOps, evalOpEvaluate)
15141514
15151515 // Check that var1 is attached to an integral by checking controller attribute
15161516 auto varItem = dynamic_pointer_cast<VariableBase>(var1);
1517- EXPECT_TRUE (varItem);
1518- if (varItem) {
1519- auto controller = varItem->controller .lock ();
1520- EXPECT_TRUE (controller != nullptr );
1521- if (controller) {
1522- EXPECT_EQ (OperationType::integrate, controller->type ());
1523- }
1524- }
1517+ ASSERT_TRUE (varItem);
1518+ auto controller = varItem->controller .lock ();
1519+ ASSERT_TRUE (controller != nullptr );
1520+ auto opBase = dynamic_pointer_cast<OperationBase>(controller);
1521+ ASSERT_TRUE (opBase);
1522+ EXPECT_EQ (OperationType::integrate, opBase->type ());
15251523 }
15261524
15271525 // Test requestReset and requestRedraw
@@ -1694,19 +1692,28 @@ TEST(TensorOps, evalOpEvaluate)
16941692 // Test makeVariablesConsistent
16951693 TEST_F (MinskySuite, makeVariablesConsistent)
16961694 {
1697- // Set up variables inconsistently - create duplicate variables with same name
1698- auto var1 = model->addItem (VariablePtr (VariableType::flow, " consistVar" ));
1699- auto var2 = model->addItem (VariablePtr (VariableType::flow, " consistVar" ));
1700-
1701- // Before makeVariablesConsistent, both should exist in items
1702- EXPECT_EQ (3 , model->items .size ()); // time + 2 consistVar
1703-
1704- // Make variables consistent
1695+ // makeVariablesConsistent calls update on GodleyIcons
1696+ // Add a GodleyIcon with flow & stock variables in the table
1697+ auto godley = new GodleyIcon;
1698+ model->addItem (godley);
1699+ godley->table .resize (3 , 3 );
1700+ godley->table .cell (0 , 1 ) = " stock1" ;
1701+ godley->table .cell (0 , 2 ) = " stock2" ;
1702+ godley->table .cell (2 , 1 ) = " flow1" ;
1703+ godley->table .cell (2 , 2 ) = " flow2" ;
1704+
1705+ // Before makeVariablesConsistent, flowVars and stockVars may not be populated
1706+ size_t flowVarsBefore = godley->flowVars ().size ();
1707+ size_t stockVarsBefore = godley->stockVars ().size ();
1708+
1709+ // Make variables consistent - this should call update on the GodleyIcon
17051710 makeVariablesConsistent ();
17061711
1707- // After makeVariablesConsistent, variables should be properly managed
1708- // (implementation may vary, but it should not crash)
1709- EXPECT_GE (model->items .size (), 2 ); // At least time + 1 consistVar
1712+ // Check that GodleyIcon's flowVars and stockVars have been populated
1713+ EXPECT_GT (godley->flowVars ().size (), flowVarsBefore);
1714+ EXPECT_GT (godley->stockVars ().size (), stockVarsBefore);
1715+ EXPECT_EQ (2 , godley->flowVars ().size ());
1716+ EXPECT_EQ (2 , godley->stockVars ().size ());
17101717 }
17111718
17121719 // Test garbageCollect
@@ -1722,15 +1729,20 @@ TEST(TensorOps, evalOpEvaluate)
17221729 try {
17231730 constructEquations ();
17241731
1725- // After constructing equations, there should be some flowVars
1726- size_t flowVarsBefore = flowVars.size ();
1727- size_t stockVarsBefore = stockVars.size ();
1732+ // After constructing equations, there should be some flowVars, stockVars, equations, integrals
1733+ EXPECT_GT (flowVars.size (), 0 );
1734+ EXPECT_GT (stockVars.size (), 0 );
1735+ EXPECT_GT (equations.size (), 0 );
1736+ EXPECT_GT (integrals.size (), 0 );
17281737
17291738 // GarbageCollect should clean things up
17301739 garbageCollect ();
17311740
1732- // Variables should still exist but temporary structures may be cleared
1733- EXPECT_GE (model->items .size (), 1 );
1741+ // Check that flowVars, stockVars, equations, integrals are empty
1742+ EXPECT_EQ (flowVars.size (), 0 );
1743+ EXPECT_EQ (stockVars.size (), 0 );
1744+ EXPECT_EQ (equations.size (), 0 );
1745+ EXPECT_EQ (integrals.size (), 0 );
17341746 } catch (...) {
17351747 // If constructEquations fails, garbageCollect should still work
17361748 garbageCollect ();
@@ -1869,12 +1881,8 @@ TEST(TensorOps, evalOpEvaluate)
18691881 EXPECT_TRUE (dimensions.count (" newDim2" ) > 0 );
18701882
18711883 // Verify the dimension types match
1872- if (dimensions.count (" newDim1" ) > 0 ) {
1873- EXPECT_EQ (Dimension::time, dimensions[" newDim1" ].type );
1874- }
1875- if (dimensions.count (" newDim2" ) > 0 ) {
1876- EXPECT_EQ (Dimension::value, dimensions[" newDim2" ].type );
1877- }
1884+ EXPECT_EQ (Dimension::time, dimensions[" newDim1" ].type );
1885+ EXPECT_EQ (Dimension::value, dimensions[" newDim2" ].type );
18781886 }
18791887
18801888 // Test openGroupInCanvas and openModelInCanvas
0 commit comments