Symbol table test - multiple values

This commit is contained in:
greg 2019-10-16 22:46:58 -07:00
parent 26fa4a29ec
commit ca10481d7c
1 changed files with 15 additions and 8 deletions

View File

@ -5,24 +5,31 @@ use super::*;
use crate::util::quick_ast;
macro_rules! values_in_table {
//TODO multiple values
($source:expr, $single_value:expr) => {
($source:literal, $single_value:expr) => {
values_in_table!($source | $single_value);
};
($source:literal | $( $value:expr ),* ) => {
{
let mut symbol_table = SymbolTable::new();
let ast = quick_ast($source);
symbol_table.add_top_level_symbols(&ast).unwrap();
match symbol_table.lookup_by_fqsn($single_value) {
Some(_spec) => (),
None => panic!(),
};
$(
match symbol_table.lookup_by_fqsn($value) {
Some(_spec) => (),
None => panic!(),
};
)*
}
}
};
}
#[test]
fn basic_symbol_table() {
values_in_table! { "let a = 10; fn b() { 20 }", &fqsn!("b"; tr) };
values_in_table! { "type Option<T> = Some(T) | None", &fqsn!("Option"; tr) };
values_in_table! { "type Option<T> = Some(T) | None" |
&fqsn!("Option"; tr),
&fqsn!("Option"; ty, "Some"; tr),
&fqsn!("Option"; ty, "None"; tr) };
}
#[test]