From e5e1647b7098303602cffd972165f12f080f1567 Mon Sep 17 00:00:00 2001 From: Jesse Brault Date: Sat, 28 Feb 2026 06:57:06 -0600 Subject: [PATCH] Multiple statements test. --- dmc-lib/src/asm/mod.rs | 46 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) diff --git a/dmc-lib/src/asm/mod.rs b/dmc-lib/src/asm/mod.rs index be43b61..0459706 100644 --- a/dmc-lib/src/asm/mod.rs +++ b/dmc-lib/src/asm/mod.rs @@ -1,3 +1,49 @@ pub mod asm_block; pub mod asm_function; pub mod asm_instruction; + +#[cfg(test)] +mod smoke_tests { + use crate::asm::asm_function::AsmFunction; + use crate::ir::assemble_context::AssembleContext; + use crate::ir::Ir; + use crate::parser::parse_compilation_unit; + use crate::symbol_table::SymbolTable; + + fn assemble(src: &str) -> Vec { + let mut compilation_unit = parse_compilation_unit(src); + let mut symbol_table = SymbolTable::new(); + compilation_unit.gather_declared_names(&mut symbol_table); + compilation_unit.check_name_usages(&symbol_table); + compilation_unit.type_check(&symbol_table); + let irs = compilation_unit.lower_to_ir(); + let mut asm_functions = vec![]; + for ir in &irs { + match ir { + Ir::Function(ir_function) => { + asm_functions.push(ir_function.assemble(&mut AssembleContext::new())); + } + _ => {} + } + } + asm_functions + } + + #[test] + fn multiple_statements() { + let asm_functions = assemble( + " + fn println() end + fn main() + let x = 42 + println(x) + println(16) + let y = \"Hello, World!\" + println(y) + end", + ); + for asm_function in &asm_functions { + println!("{:#?}", asm_function); + } + } +}