def code_generation_tests(): stdlib = util.all_files_in_dir("test_cases/stdlib/6.0/") def test_asm(filenames): environment.cached_environments = {} environment.cached_trees = {} generate.check_and_generate(filenames) subprocess.check_call(["nasm", "-O1", "-f", "elf", "-g", "-F", "dwarf", "output/out.s"]) subprocess.check_call(["ld", "-melf_i386", "-o", "main", "output/out.o", "test_cases/stdlib/6.0/runtime.o"]) result = subprocess.call(["./main"]) os.remove("main") os.remove("output/out.s") os.remove("output/out.o") return result test(test_asm, 123, "test_cases/a6/J[0-9]_*.java", os.path.isdir, lambda x: [x] + stdlib) test(test_asm, 123, "test_cases/a6/J[0-9]_*.java", os.path.isfile, lambda x: util.all_files_in_dir(x) + stdlib) test(test_asm, 13, "test_cases/a6/J[0-9]e*.java", os.path.isdir, lambda x: [x] + stdlib) test(test_asm, 13, "test_cases/a6/J[0-9]e*.java", os.path.isfile, lambda x: util.all_files_in_dir(x) + stdlib)
def static_tests(): stdlib = util.all_files_in_dir("test_cases/stdlib/5.0/") test(static.check, 0, "test_cases/a5/J[0-9]*", os.path.isdir, lambda x: [x] + stdlib) test(static.check, 42, "test_cases/a5/Je*", os.path.isdir, lambda x: [x] + stdlib) test(static.check, 0, "test_cases/a5/J[0-9]*", os.path.isfile, lambda x: util.all_files_in_dir(x) + stdlib) test(static.check, 42, "test_cases/a5/Je*", os.path.isfile, lambda x: util.all_files_in_dir(x) + stdlib)
def environment_tests(): stdlib = util.all_files_in_dir("test_cases/stdlib/3.0/") test(environment.check, 0, "test_cases/a3/J[0-9]*", os.path.isdir, lambda x: [x] + stdlib) test(environment.check, 42, "test_cases/a3/Je*", os.path.isdir, lambda x: [x] + stdlib) test(environment.check, 0, "test_cases/a3/J[0-9]*", os.path.isfile, lambda x: util.all_files_in_dir(x) + stdlib) test(environment.check, 42, "test_cases/a3/Je*", os.path.isfile, lambda x: util.all_files_in_dir(x) + stdlib)
def typechecker_tests(): stdlib = util.all_files_in_dir("test_cases/stdlib/4.0/") test(typechecker.typecheck_files, 0, "test_cases/a4/J[0-9]*", os.path.isdir, lambda x: [x] + stdlib) test(typechecker.typecheck_files, 0, "test_cases/a4/J[0-9]*", os.path.isfile, lambda x: util.all_files_in_dir(x) + stdlib) test(typechecker.typecheck_files, 42, "test_cases/a4/Je*", os.path.isdir, lambda x: [x] + stdlib) test(typechecker.typecheck_files, 42, "test_cases/a4/Je*", os.path.isfile, lambda x: util.all_files_in_dir(x) + stdlib)
import sys import os import util RUN = "generate.py" VERSION = "6.0" if __name__ == "__main__": test_case = sys.argv[1] stdlib = util.all_files_in_dir("test_cases/stdlib/" + VERSION + "/") if test_case.endswith(".java"): args = stdlib + [test_case] else: afid = util.all_files_in_dir(test_case) if len(afid) == 0: print "No files under directory " + test_case exit() args = stdlib + afid os.system("python " + RUN + " " + " ".join(args))