Perform a test case.
(self, testcase: DataDrivenTestCase)
| 125 | files = ["semanal-symtable.test"] |
| 126 | |
| 127 | def run_case(self, testcase: DataDrivenTestCase) -> None: |
| 128 | """Perform a test case.""" |
| 129 | try: |
| 130 | # Build test case input. |
| 131 | src = "\n".join(testcase.input) |
| 132 | result = build.build( |
| 133 | sources=[BuildSource("main", None, src)], |
| 134 | options=get_semanal_options(src, testcase), |
| 135 | alt_lib_path=test_temp_dir, |
| 136 | ) |
| 137 | # The output is the symbol table converted into a string. |
| 138 | a = result.errors |
| 139 | if a: |
| 140 | raise CompileError(a) |
| 141 | for module in sorted(result.files.keys()): |
| 142 | if module in testcase.test_modules: |
| 143 | a.append(f"{module}:") |
| 144 | for s in str(result.files[module].names).split("\n"): |
| 145 | a.append(" " + s) |
| 146 | except CompileError as e: |
| 147 | a = e.messages |
| 148 | assert_string_arrays_equal( |
| 149 | testcase.output, |
| 150 | a, |
| 151 | f"Invalid semantic analyzer output ({testcase.file}, line {testcase.line})", |
| 152 | ) |
| 153 | |
| 154 | |
| 155 | # Type info export test cases |
nothing calls this directly
no test coverage detected