Make tests also codegen correctly
This commit is contained in:
parent
efeefe0bfe
commit
4de346e3c0
@ -17,6 +17,7 @@ fn main() -> Result<(), std::io::Error> {
|
|||||||
let before = std::time::SystemTime::now();
|
let before = std::time::SystemTime::now();
|
||||||
|
|
||||||
let text = fs::read_to_string(&path)?;
|
let text = fs::read_to_string(&path)?;
|
||||||
|
|
||||||
match compile_simple(&text, PathBuf::from(&path)) {
|
match compile_simple(&text, PathBuf::from(&path)) {
|
||||||
Ok((
|
Ok((
|
||||||
CompileOutput {
|
CompileOutput {
|
||||||
|
@ -54,7 +54,7 @@ use crate::{ast::TopLevelStatement, lexer::Token, token_stream::TokenStream};
|
|||||||
|
|
||||||
mod ast;
|
mod ast;
|
||||||
mod codegen;
|
mod codegen;
|
||||||
mod error_raporting;
|
pub mod error_raporting;
|
||||||
mod lexer;
|
mod lexer;
|
||||||
pub mod mir;
|
pub mod mir;
|
||||||
mod pad_adapter;
|
mod pad_adapter;
|
||||||
|
@ -3,19 +3,26 @@ use reid::{
|
|||||||
mir::{self},
|
mir::{self},
|
||||||
parse_module, perform_all_passes,
|
parse_module, perform_all_passes,
|
||||||
};
|
};
|
||||||
|
use reid_lib::Context;
|
||||||
use util::assert_err;
|
use util::assert_err;
|
||||||
|
|
||||||
mod util;
|
mod util;
|
||||||
|
|
||||||
fn test(source: &str, name: &str) {
|
fn test(source: &str, name: &str) {
|
||||||
let mut map = Default::default();
|
assert_err(assert_err(std::panic::catch_unwind(|| {
|
||||||
let (id, tokens) = assert_err(parse_module(source, name, &mut map));
|
let mut map = Default::default();
|
||||||
let module = assert_err(compile_module(id, tokens, &mut map, None, true));
|
let (id, tokens) = assert_err(parse_module(source, name, &mut map));
|
||||||
|
|
||||||
assert_err(perform_all_passes(
|
let module = assert_err(compile_module(id, tokens, &mut map, None, true));
|
||||||
&mut mir::Context::from(vec![module], Default::default()),
|
let mut mir_context = mir::Context::from(vec![module], Default::default());
|
||||||
&mut map,
|
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]
|
#[test]
|
||||||
@ -66,6 +73,7 @@ fn hello_world_compiles_well() {
|
|||||||
fn mutable_compiles_well() {
|
fn mutable_compiles_well() {
|
||||||
test(include_str!("../../examples/mutable.reid"), "test");
|
test(include_str!("../../examples/mutable.reid"), "test");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn ptr_compiles_well() {
|
fn ptr_compiles_well() {
|
||||||
test(include_str!("../../examples/ptr.reid"), "test");
|
test(include_str!("../../examples/ptr.reid"), "test");
|
||||||
|
Loading…
Reference in New Issue
Block a user