Add e2e tests
This commit is contained in:
parent
824978de49
commit
19c883ea33
74
reid/tests/e2e.rs
Normal file
74
reid/tests/e2e.rs
Normal file
@ -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(),
|
||||||
|
}));
|
||||||
|
}
|
@ -2,6 +2,9 @@ use reid::{
|
|||||||
mir::{self, linker::compile_std},
|
mir::{self, linker::compile_std},
|
||||||
perform_all_passes,
|
perform_all_passes,
|
||||||
};
|
};
|
||||||
|
use util::assert_err;
|
||||||
|
|
||||||
|
mod util;
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn compiles() {
|
fn compiles() {
|
||||||
@ -20,10 +23,3 @@ fn passes_all_passes() {
|
|||||||
base: Default::default(),
|
base: Default::default(),
|
||||||
}));
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn assert_err<T, U: std::fmt::Debug>(value: Result<T, U>) {
|
|
||||||
match value {
|
|
||||||
Ok(_) => {}
|
|
||||||
Err(err) => assert!(false, "{:?}", err),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
9
reid/tests/util.rs
Normal file
9
reid/tests/util.rs
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
pub fn assert_err<T, U: std::fmt::Debug>(value: Result<T, U>) -> T {
|
||||||
|
match value {
|
||||||
|
Ok(val) => val,
|
||||||
|
Err(err) => {
|
||||||
|
assert!(false, "{:?}", err);
|
||||||
|
panic!("after assert!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user