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 text = fs::read_to_string(&path)?; | ||||
| 
 | ||||
|         match compile_simple(&text, PathBuf::from(&path)) { | ||||
|             Ok(( | ||||
|                 CompileOutput { | ||||
|  | ||||
| @ -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; | ||||
|  | ||||
| @ -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"); | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user