diff options
| author | Gustav Sörnäs <gustav@sornas.net> | 2021-01-11 15:27:54 +0100 |
|---|---|---|
| committer | Gustav Sörnäs <gustav@sornas.net> | 2021-01-11 15:27:54 +0100 |
| commit | 5ff6d5a75020b148a3af130d9bb90ef60618efc2 (patch) | |
| tree | 3740c8c1cfeba6d1376a01e34c34fd32a9c6a271 | |
| parent | 3a488562804af56f5df47e887a884b80acaa0f81 (diff) | |
| download | sylt-5ff6d5a75020b148a3af130d9bb90ef60618efc2.tar.gz | |
test unreachable statement
| -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 @@ +<!> |
