diff --git a/reid/tests/e2e.rs b/reid/tests/e2e.rs new file mode 100644 index 0000000..031d217 --- /dev/null +++ b/reid/tests/e2e.rs @@ -0,0 +1,74 @@ +use reid::{ + compile_module, + mir::{self}, + perform_all_passes, +}; +use util::assert_err; + +mod util; + +pub static ARRAY: &str = include_str!("../../reid_src/array.reid"); +pub static FIBONACCI: &str = include_str!("../../reid_src/fibonacci.reid"); +pub static HELLO_WORLD: &str = include_str!("../../reid_src/hello_world.reid"); +pub static MUTABLE: &str = include_str!("../../reid_src/mutable.reid"); +pub static STRINGS: &str = include_str!("../../reid_src/strings.reid"); + +#[test] +fn array_compiles_well() { + let module = assert_err(compile_module(ARRAY, "array".to_owned(), None, true)); + + assert_err(perform_all_passes(&mut mir::Context { + modules: vec![module], + base: Default::default(), + })); +} + +#[test] +fn fibonacci_compiles_well() { + let module = assert_err(compile_module( + FIBONACCI, + "fibonacci".to_owned(), + None, + true, + )); + + assert_err(perform_all_passes(&mut mir::Context { + modules: vec![module], + base: Default::default(), + })); +} + +#[test] +fn hello_world_compiles_well() { + let module = assert_err(compile_module( + HELLO_WORLD, + "hello_world".to_owned(), + None, + true, + )); + + assert_err(perform_all_passes(&mut mir::Context { + modules: vec![module], + base: Default::default(), + })); +} + +#[test] +fn mutable_compiles_well() { + let module = assert_err(compile_module(MUTABLE, "mutable".to_owned(), None, true)); + + assert_err(perform_all_passes(&mut mir::Context { + modules: vec![module], + base: Default::default(), + })); +} + +#[test] +fn strings_compiles_well() { + let module = assert_err(compile_module(STRINGS, "strings".to_owned(), None, true)); + + assert_err(perform_all_passes(&mut mir::Context { + modules: vec![module], + base: Default::default(), + })); +} diff --git a/reid/tests/stdlib.rs b/reid/tests/stdlib.rs index 9a5f457..95afc7a 100644 --- a/reid/tests/stdlib.rs +++ b/reid/tests/stdlib.rs @@ -2,6 +2,9 @@ use reid::{ mir::{self, linker::compile_std}, perform_all_passes, }; +use util::assert_err; + +mod util; #[test] fn compiles() { @@ -20,10 +23,3 @@ fn passes_all_passes() { base: Default::default(), })); } - -fn assert_err(value: Result) { - match value { - Ok(_) => {} - Err(err) => assert!(false, "{:?}", err), - } -} diff --git a/reid/tests/util.rs b/reid/tests/util.rs new file mode 100644 index 0000000..1548785 --- /dev/null +++ b/reid/tests/util.rs @@ -0,0 +1,9 @@ +pub fn assert_err(value: Result) -> T { + match value { + Ok(val) => val, + Err(err) => { + assert!(false, "{:?}", err); + panic!("after assert!"); + } + } +}