def test_requires_stop(self) -> None: condition = DummyCondition(requires_stop=False) conditions = {'foo_cond': condition} body = DummyPulseTemplate(requires_stop=False) t = LoopPulseTemplate('foo_cond', body) self.assertFalse(t.requires_stop({}, conditions)) condition.requires_stop_ = True self.assertTrue(t.requires_stop({}, conditions)) body.requires_stop_ = True condition.requires_stop_ = False self.assertFalse(t.requires_stop({}, conditions))
def test_requires_stop(self) -> None: condition = DummyCondition(requires_stop=False) conditions = {'foo_cond': condition} body = DummyPulseTemplate(requires_stop=False) t = WhileLoopPulseTemplate('foo_cond', body) self.assertFalse(t.requires_stop({}, conditions)) condition.requires_stop_ = True self.assertTrue(t.requires_stop({}, conditions)) body.requires_stop_ = True condition.requires_stop_ = False self.assertFalse(t.requires_stop({}, conditions))
def test_requires_stop_declaration(self) -> None: body = DummyPulseTemplate(requires_stop=False) t = RepetitionPulseTemplate(body, ParameterDeclaration('foo')) parameter = DummyParameter() parameters = dict(foo=parameter) condition = DummyCondition() conditions = dict(foo=condition) for body_requires_stop in [True, False]: for condition_requires_stop in [True, False]: for parameter_requires_stop in [True, False]: body.requires_stop_ = body_requires_stop condition.requires_stop_ = condition_requires_stop parameter.requires_stop_ = parameter_requires_stop self.assertEqual(parameter_requires_stop, t.requires_stop(parameters, conditions))