-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtests.py
More file actions
28 lines (23 loc) · 860 Bytes
/
tests.py
File metadata and controls
28 lines (23 loc) · 860 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
"""
Simple test script that runs JackAnalyzer and compares resulting .xml files (___Test.xml) to the .xml files provided by Nand to Tetris course (___.xml).
"""
from JackAnalyzer import JackAnalyzer
import filecmp
files_and_directories = [
"assets\ArrayTest\Main.jack",
"assets\ExpressionLessSquare",
"assets\Square"]
print("\nTEST OUTCOMES")
print("=============\n")
test_count = 1
for program in files_and_directories:
ja = JackAnalyzer(program, "Test")
ja.analyze()
for i in range(len(ja.xml_files)):
analyzed_file = ja.xml_files[i]
compare_file = ja.get_output_file(ja.jack_files[i])
check = filecmp.cmp(analyzed_file, compare_file, False)
outcome = ("FAILED", "PASSED")[check]
print("Test {0}: {1}".format(test_count, outcome))
print("Compared {0} to {1}\n".format(analyzed_file, compare_file))
test_count += 1