44 lines
1.2 KiB
Rust
44 lines
1.2 KiB
Rust
pub mod call;
|
|
pub mod compilation_unit;
|
|
pub mod expression;
|
|
pub mod function;
|
|
pub mod identifier;
|
|
pub mod integer_literal;
|
|
pub mod let_statement;
|
|
pub mod statement;
|
|
pub mod string_literal;
|
|
|
|
#[cfg(test)]
|
|
mod name_tests {
|
|
use crate::parser::parse_compilation_unit;
|
|
use crate::symbol_table::SymbolTable;
|
|
|
|
#[test]
|
|
fn smoke_screen() {
|
|
let mut symbol_table = SymbolTable::new();
|
|
let mut compilation_unit =
|
|
parse_compilation_unit("fn println() end fn main() let x = 42 println(x) end");
|
|
assert_eq!(
|
|
compilation_unit
|
|
.gather_declared_names(&mut symbol_table)
|
|
.len(),
|
|
0
|
|
);
|
|
assert_eq!(compilation_unit.check_name_usages(&symbol_table).len(), 0);
|
|
}
|
|
|
|
#[test]
|
|
fn get_some_diagnostics() {
|
|
let mut symbol_table = SymbolTable::new();
|
|
let mut compilation_unit = parse_compilation_unit("fn main() notDefined(uhOh) end");
|
|
assert_eq!(
|
|
compilation_unit
|
|
.gather_declared_names(&mut symbol_table)
|
|
.len(),
|
|
0
|
|
);
|
|
let name_usage_diagnostics = compilation_unit.check_name_usages(&symbol_table);
|
|
assert_eq!(name_usage_diagnostics.len(), 2);
|
|
}
|
|
}
|