def test_build_sequence_loop(self) -> None: sequencer = DummySequencer() block = DummyInstructionBlock() block.add_instruction(DummyInstruction()) delegator = DummySequencingElement() body = DummySequencingElement() trigger = Trigger() condition = HardwareCondition(trigger) condition.build_sequence_loop(delegator, body, sequencer, {}, {}, {}, {}, block) self.assertEqual(1, len(block.embedded_blocks)) body_block = block.embedded_blocks[0] self.assertEqual( [ DummyInstruction(), CJMPInstruction(trigger, InstructionPointer(body_block)) ], block.instructions, "The expected conditional jump was not generated by HardwareConditon." ) self.assertEqual( InstructionPointer(block, 1), body_block.return_ip, "The return address of the loop body block was set wrongly by HardwareCondition." ) self.assertEqual( {body_block: [(body, {}, {}, {}, {})]}, sequencer.sequencing_stacks, "HardwareCondition did not correctly push the body element to the stack" ) self.assertFalse(condition.requires_stop())
def test_build_sequence_loop(self) -> None: sequencer = DummySequencer() block = DummyInstructionBlock() delegator = DummySequencingElement() body = DummySequencingElement() trigger = Trigger() condition = HardwareCondition(trigger) condition.build_sequence_loop(delegator, body, sequencer, {}, {}, block) self.assertEqual(1, len(block.embedded_blocks)) body_block = block.embedded_blocks[0] self.assertEqual([CJMPInstruction(trigger, body_block, 0)], block.instructions, "The expected conditional jump was not generated by HardwareConditon.") self.assertEqual(InstructionPointer(block, 0), body_block.return_ip, "The return address of the loop body block was set wrongly by HardwareCondition.") self.assertEqual({body_block: [(body, {}, {})]}, sequencer.sequencing_stacks, "HardwareCondition did not correctly push the body element to the stack") self.assertFalse(condition.requires_stop())