diff options
author | Alexis Roda <alexis.roda.villalonga@gmail.com> | 2019-07-26 20:15:41 +0200 |
---|---|---|
committer | Alexis Roda <alexis.roda.villalonga@gmail.com> | 2019-07-26 20:15:41 +0200 |
commit | 1a5911f452ad999fa35ce264e7e73bbdfec58775 (patch) | |
tree | ab7c46882a21fa223a1ed79bd00955012c618977 /z80count.py | |
parent | fe518ecdf05f526fc3fe104dfa89dd54c3d15886 (diff) | |
download | z80count-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-x | z80count.py | 17 |
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: |