diff --git a/reid/examples/cli.rs b/reid/examples/cli.rs index 49d594f..2de0e71 100644 --- a/reid/examples/cli.rs +++ b/reid/examples/cli.rs @@ -17,6 +17,7 @@ fn main() -> Result<(), std::io::Error> { let before = std::time::SystemTime::now(); let text = fs::read_to_string(&path)?; + match compile_simple(&text, PathBuf::from(&path)) { Ok(( CompileOutput { diff --git a/reid/src/lib.rs b/reid/src/lib.rs index 56492a7..eec083f 100644 --- a/reid/src/lib.rs +++ b/reid/src/lib.rs @@ -54,7 +54,7 @@ use crate::{ast::TopLevelStatement, lexer::Token, token_stream::TokenStream}; mod ast; mod codegen; -mod error_raporting; +pub mod error_raporting; mod lexer; pub mod mir; mod pad_adapter; diff --git a/reid/tests/e2e.rs b/reid/tests/e2e.rs index 840208e..274a67d 100644 --- a/reid/tests/e2e.rs +++ b/reid/tests/e2e.rs @@ -3,19 +3,26 @@ use reid::{ mir::{self}, parse_module, perform_all_passes, }; +use reid_lib::Context; use util::assert_err; mod util; fn test(source: &str, name: &str) { - let mut map = Default::default(); - let (id, tokens) = assert_err(parse_module(source, name, &mut map)); - let module = assert_err(compile_module(id, tokens, &mut map, None, true)); + assert_err(assert_err(std::panic::catch_unwind(|| { + let mut map = Default::default(); + let (id, tokens) = assert_err(parse_module(source, name, &mut map)); - assert_err(perform_all_passes( - &mut mir::Context::from(vec![module], Default::default()), - &mut map, - )); + let module = assert_err(compile_module(id, tokens, &mut map, None, true)); + let mut mir_context = mir::Context::from(vec![module], Default::default()); + assert_err(perform_all_passes(&mut mir_context, &mut map)); + + let context = Context::new(format!("Reid ({})", env!("CARGO_PKG_VERSION"))); + + assert_err(mir_context.codegen(&context)); + + Ok::<(), ()>(()) + }))) } #[test] @@ -66,6 +73,7 @@ fn hello_world_compiles_well() { fn mutable_compiles_well() { test(include_str!("../../examples/mutable.reid"), "test"); } + #[test] fn ptr_compiles_well() { test(include_str!("../../examples/ptr.reid"), "test");