From 79534a8d384ee620821fb76d1d710b018464167e Mon Sep 17 00:00:00 2001 From: Andrew Morris Date: Tue, 21 Mar 2023 11:23:05 +1100 Subject: [PATCH] Enable testing exceptions with test_output --- inputs/passing/bigint/noMix.ts | 5 +++++ vstc/src/test_inputs.rs | 14 +++++--------- 2 files changed, 10 insertions(+), 9 deletions(-) create mode 100644 inputs/passing/bigint/noMix.ts diff --git a/inputs/passing/bigint/noMix.ts b/inputs/passing/bigint/noMix.ts new file mode 100644 index 0000000..378d8bc --- /dev/null +++ b/inputs/passing/bigint/noMix.ts @@ -0,0 +1,5 @@ +// test_output! E: "TypeError: Cannot mix BigInt and other types" + +export default function () { + return 1 + (1n as unknown as number); +} diff --git a/vstc/src/test_inputs.rs b/vstc/src/test_inputs.rs index 0863cc3..a615646 100644 --- a/vstc/src/test_inputs.rs +++ b/vstc/src/test_inputs.rs @@ -83,16 +83,12 @@ mod tests { let mut vm = VirtualMachine::new(); - let result = match vm.run(&bytecode, &[]) { - Ok(result) => result, - Err(err) => { - println!(" Uncaught exception: {}", err); - failed_paths.insert(file_path.clone()); - continue; - } - }; + let result = vm.run(&bytecode, &[]); - let result_str = result.codify(); + let result_str = match result { + Ok(val) => val.codify(), + Err(err) => format!("E: {}", err.codify()), + }; if result_str != output_str { println!(