aboutsummaryrefslogtreecommitdiff
path: root/z80count.py
diff options
context:
space:
mode:
authorAlexis Roda <alexis.roda.villalonga@gmail.com>2019-07-26 20:15:41 +0200
committerAlexis Roda <alexis.roda.villalonga@gmail.com>2019-07-26 20:15:41 +0200
commit1a5911f452ad999fa35ce264e7e73bbdfec58775 (patch)
treeab7c46882a21fa223a1ed79bd00955012c618977 /z80count.py
parentfe518ecdf05f526fc3fe104dfa89dd54c3d15886 (diff)
downloadz80count-1a5911f452ad999fa35ce264e7e73bbdfec58775.tar.gz
z80count-1a5911f452ad999fa35ce264e7e73bbdfec58775.zip
Added tests.
Minor refactor in order to improve testability. Note: tests have been automatically generated from data found in an spreadsheet and probably need some cleanup.
Diffstat (limited to 'z80count.py')
-rwxr-xr-xz80count.py17
1 files changed, 13 insertions, 4 deletions
diff --git a/z80count.py b/z80count.py
index 6c569f7..02c75a4 100755
--- a/z80count.py
+++ b/z80count.py
@@ -84,8 +84,7 @@ def init_table(table_file="z80table.json"):
return sorted(table, key=lambda o: o["w"])
-def main():
-
+def parse_command_line():
parser = argparse.ArgumentParser(
description='Z80 Cycle Count', epilog="Copyright (C) 2019 Juan J Martinez <jjm@usebox.net>")
@@ -105,11 +104,21 @@ def main():
parser.add_argument(
"outfile", nargs="?", type=argparse.FileType('w'), default=sys.stdout,
help="Output file")
- args = parser.parse_args()
+ return parser.parse_args()
+
+
+def lookup(line, table):
+ for entry in table:
+ if entry["cregex"].search(line):
+ return entry
+ return None
+
+
+def main():
+ args = parse_command_line()
in_f = args.infile
out_f = args.outfile
-
table = init_table()
total = total_cond = 0
while True: