diff options
| -rw-r--r-- | src/main.rs | 17 | ||||
| -rw-r--r-- | tests/unreachable.tdy | 1 |
2 files changed, 16 insertions, 2 deletions
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<Error>> { 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"); diff --git a/tests/unreachable.tdy b/tests/unreachable.tdy new file mode 100644 index 0000000..f016a14 --- /dev/null +++ b/tests/unreachable.tdy @@ -0,0 +1 @@ +<!> |
