@@ -64,6 +64,46 @@ BOOST_FIXTURE_TEST_CASE(test_undo_inst_destroy, F_DEFAULT)
6464 BOOST_TEST (inst->getRegion () == region);
6565}
6666
67+ BOOST_FIXTURE_TEST_CASE (test_undo_mod_inst_destroy, F_DEFAULT )
68+ {
69+ auto flat_net = dbNet::create (block, " n" );
70+ // Make module and contents
71+ auto module = dbModule::create (block, " test" );
72+ auto mod_net = dbModNet::create (module , " lower_net" );
73+ auto mod_bterm = dbModBTerm::create (module , " bterm" );
74+ mod_bterm->connect (mod_net);
75+ auto leaf_inst = dbInst::create (block, and2, " i1" , false , module );
76+ auto iterm = leaf_inst->findITerm (" b" );
77+ iterm->connect (flat_net, mod_net);
78+
79+ // Instantiate the module and connect it
80+ auto top = block->getTopModule ();
81+ dbModNet* top_net = dbModNet::create (top, " top_net" );
82+ auto inst = dbModInst::create (top, module , " mod_inst" );
83+ auto mod_iterm = dbModITerm::create (inst, " b" , mod_bterm);
84+ mod_iterm->connect (top_net);
85+
86+ auto group = dbGroup::create (block, " g" );
87+ group->addModInst (inst);
88+
89+ in_eco ([&]() {
90+ dbModInst::destroy (inst);
91+ BOOST_TEST (block->getModInsts ().size () == 0 );
92+ });
93+
94+ BOOST_TEST (block->findModInst (" mod_inst" ) == inst);
95+ BOOST_TEST (inst->getGroup () == group);
96+ BOOST_TEST (inst->getParent () == top);
97+ BOOST_TEST (inst->getMaster () == module );
98+ BOOST_TEST (inst->getModITerms ().size () == 1 );
99+ BOOST_TEST (*inst->getModITerms ().begin () == mod_iterm);
100+ BOOST_TEST (mod_iterm->getModNet () == top_net);
101+ BOOST_TEST (block->getInsts ().size () == 1 );
102+ BOOST_TEST (*block->getInsts ().begin () == leaf_inst);
103+ BOOST_TEST (block->getModInsts ().size () == 1 );
104+ BOOST_TEST (*block->getModInsts ().begin () == inst);
105+ }
106+
67107BOOST_FIXTURE_TEST_CASE (test_undo_net_create, F_DEFAULT )
68108{
69109 in_eco ([&]() {
0 commit comments