Multiple statements test.
This commit is contained in:
parent
6b855b8ebb
commit
e5e1647b70
@ -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<AsmFunction> {
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user