Skip to content

Commit

Permalink
Update coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
nickdrozd committed Nov 30, 2023
1 parent 15fb147 commit 8b2152c
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 31 deletions.
60 changes: 32 additions & 28 deletions test/test_coverage.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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(
Expand All @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion tm/machine.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions tools/instr_seq.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand All @@ -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

0 comments on commit 8b2152c

Please sign in to comment.