From 5ff6d5a75020b148a3af130d9bb90ef60618efc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gustav=20S=C3=B6rn=C3=A4s?= Date: Mon, 11 Jan 2021 15:27:54 +0100 Subject: test unreachable statement --- src/main.rs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/main.rs b/src/main.rs index 8517561..26b0d02 100644 --- a/src/main.rs +++ b/src/main.rs @@ -27,14 +27,28 @@ fn run_file(path: &Path) -> Result<(), Vec> { Ok(block) => vm::run_block(block).or_else(|e| Err(vec![e])), Err(errors) => Err(errors), } - } #[cfg(test)] mod tests { use super::run_file; + use crate::error::{Error, ErrorKind}; use std::path::Path; + #[test] + fn unreachable_token() { + let file = Path::new("tests/unreachable.tdy"); + assert!(matches!( + run_file(&file).unwrap_err().as_slice(), + &[Error { + kind: ErrorKind::Unreachable, + file: _, + line: _, + message: _, + }] + )); + } + macro_rules! test_file { ($fn:ident, $path:literal) => { #[test] @@ -44,7 +58,6 @@ mod tests { } }; } - test_file!(order_of_operations, "tests/order-of-operations.tdy"); test_file!(variables, "tests/variables.tdy"); test_file!(scoping, "tests/scoping.tdy"); -- cgit v1.2.1