schala/schala-lang/language/src/reduced_ir/test.rs

44 lines
778 B
Rust
Raw Normal View History

#![cfg(test)]
use crate::symbol_table::SymbolTable;
use super::*;
fn build_ir(input: &str) -> ReducedIR {
let ast = crate::util::quick_ast(input);
let mut symbol_table = SymbolTable::new();
symbol_table.process_ast(&ast).unwrap();
let reduced = reduce(&ast, &symbol_table);
reduced.debug(&symbol_table);
reduced
}
#[test]
fn test_ir() {
let src = r#"
let global_one = 10 + 20
let global_two = "the string hello"
fn a_function(i, j, k) {
fn nested(x) {
x + 10
}
i + j * nested(k)
}
fn another_function(e) {
let local_var = 420
e * local_var
}
another_function()
"#;
let reduced = build_ir(src);
2021-10-24 22:55:12 -07:00
assert_eq!(reduced.functions.len(), 3);
//assert!(1 == 2);
}