From 1a5911f452ad999fa35ce264e7e73bbdfec58775 Mon Sep 17 00:00:00 2001 From: Alexis Roda Date: Fri, 26 Jul 2019 20:15:41 +0200 Subject: 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. --- z80count.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'z80count.py') 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 ") @@ -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: -- cgit v1.2.3