diff --git a/test/test_coverage.py b/test/test_coverage.py index af442983..b09bd7ec 100644 --- a/test/test_coverage.py +++ b/test/test_coverage.py @@ -2,10 +2,7 @@ from unittest import TestCase -from test.machine import QuickMachine -from test.lin_rec import StrictLinRecMachine - -from tm.machine import Machine +from tm.machine import Machine, quick_term_or_rec from tm.reason import ( Program, @@ -103,28 +100,40 @@ def test_machine(self): "1RB 1LA 1RC 0LB 0LB ..." ).run().blanks) - self.assertIsNotNone( - StrictLinRecMachine( - "1RB 1LA 0RC ... 1LC 0LA" - ).run(check_rec = 1)) + self.assertFalse( + quick_term_or_rec( + "1RB 1LA 0RC ... 1LC 0LA", + 100)) - self.assertIsNotNone( - StrictLinRecMachine( - "1RB 1RB 1RC 0LC 0LB 1RC" - ).run(check_rec = 1)) + self.assertTrue( + quick_term_or_rec( + "1RB 1RB 1RC 0LC 0LB 1RC", + 100)) - self.assertIsNotNone( - StrictLinRecMachine( - "1RB 0LB 1LA 0RA" - ).run( - check_rec = 1, - sim_lim = 50, - )) + self.assertFalse( + quick_term_or_rec( + "1RB 0LB 1LA 0RA", + 50)) - self.assertIsNotNone( - StrictLinRecMachine( - "1RB 1LA 0LB 1LB" - ).run(check_rec = 1)) + self.assertTrue( + quick_term_or_rec( + "1RB 1LA 0LB 1LB", + 50)) + + self.assertTrue( + quick_term_or_rec( + "1RB ... 0RC 1LB 1LA 0RB", + 50)) + + self.assertTrue( + quick_term_or_rec( + "1RB 1RB 0LA ...", + 10)) + + self.assertTrue( + quick_term_or_rec( + "1RB 1RA 1RC 0RD 1LE 0RA 0R_ 0RB 1LB 1LE", + 100_000_000)) self.assertIsNotNone( Machine( @@ -136,11 +145,6 @@ def test_machine(self): "1RB ... 0LB 0RA" ).run()) - self.assertIsNotNone( - QuickMachine( - "1RB 2LA 0RB 1LA 0LB 1RA" - ).run()) - def test_prover(self): progs = ( "1RB 2LA 3LA 2LA 3LB 3RA 0RA 0RB", diff --git a/tm/machine.py b/tm/machine.py index 513d7281..ccd94edf 100644 --- a/tm/machine.py +++ b/tm/machine.py @@ -261,7 +261,7 @@ def run( ######################################## -def quick_term_or_rec(prog: str, sim_lim: int) -> bool: # no-cover +def quick_term_or_rec(prog: str, sim_lim: int) -> bool: # pylint: disable = while-used, too-many-locals comp = tcompile(prog) diff --git a/tools/instr_seq.py b/tools/instr_seq.py index 95f8fa53..0008cf00 100644 --- a/tools/instr_seq.py +++ b/tools/instr_seq.py @@ -37,7 +37,7 @@ def run_for_undefined(prog: Program) -> Undfnd | None: state = 0 - for _ in range(100_000_000): + for _ in range(100_000_000): # no-branch if (instr := prog[state, tape.scan]) is None: return step, (state, tape.scan) @@ -55,4 +55,4 @@ def run_for_undefined(prog: Program) -> Undfnd | None: if (state := next_state) == -1: # no-cover return None - return None + return None # no-cover