def test_running_and_state(self): ReportGuard(False) kb = KnuthBendix() kb.set_alphabet("abc") kb.add_rule("aa", "") kb.add_rule("bc", "") kb.add_rule("bbb", "") kb.add_rule("ababababababab", "") kb.add_rule("abacabacabacabacabacabacabacabac", "") kb.run_for(milliseconds(500)) self.assertTrue(kb.stopped()) self.assertFalse(kb.finished()) self.assertFalse(kb.running()) self.assertTrue(kb.started()) self.assertFalse(kb.stopped_by_predicate()) self.assertTrue(kb.timed_out()) kb = KnuthBendix() kb.set_alphabet("abc") kb.add_rule("aa", "") kb.add_rule("bc", "") kb.add_rule("bbb", "") kb.add_rule("ababababababab", "") kb.add_rule("abacabacabacabacabacabacabacabac", "") kb.run_until(lambda: kb.nr_active_rules() > 100) self.assertTrue(kb.stopped()) self.assertFalse(kb.finished()) self.assertFalse(kb.running()) self.assertTrue(kb.started()) self.assertTrue(kb.stopped_by_predicate()) self.assertFalse(kb.timed_out())
def test_state(self): ReportGuard(False) S = FroidurePin(Transformation([1, 0] + list(range(2, 10)))) S.add_generator(Transformation(list(range(1, 10)) + [0])) self.assertFalse(S.started()) S.run_for(milliseconds(10)) self.assertTrue(S.started()) self.assertTrue(S.timed_out()) self.assertTrue(S.stopped()) self.assertFalse(S.finished())
def test_run_for(self): ReportGuard(False) S = FroidurePin(Transformation([1, 0] + list(range(2, 10)))) S.add_generator(Transformation(list(range(1, 10)) + [0])) S.run_for(milliseconds(10))