Symbol table test - multiple values
This commit is contained in:
parent
26fa4a29ec
commit
ca10481d7c
@ -5,24 +5,31 @@ use super::*;
|
|||||||
use crate::util::quick_ast;
|
use crate::util::quick_ast;
|
||||||
|
|
||||||
macro_rules! values_in_table {
|
macro_rules! values_in_table {
|
||||||
//TODO multiple values
|
($source:literal, $single_value:expr) => {
|
||||||
($source:expr, $single_value:expr) => {
|
values_in_table!($source | $single_value);
|
||||||
|
};
|
||||||
|
($source:literal | $( $value:expr ),* ) => {
|
||||||
{
|
{
|
||||||
let mut symbol_table = SymbolTable::new();
|
let mut symbol_table = SymbolTable::new();
|
||||||
let ast = quick_ast($source);
|
let ast = quick_ast($source);
|
||||||
symbol_table.add_top_level_symbols(&ast).unwrap();
|
symbol_table.add_top_level_symbols(&ast).unwrap();
|
||||||
match symbol_table.lookup_by_fqsn($single_value) {
|
$(
|
||||||
Some(_spec) => (),
|
match symbol_table.lookup_by_fqsn($value) {
|
||||||
None => panic!(),
|
Some(_spec) => (),
|
||||||
};
|
None => panic!(),
|
||||||
|
};
|
||||||
|
)*
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn basic_symbol_table() {
|
fn basic_symbol_table() {
|
||||||
values_in_table! { "let a = 10; fn b() { 20 }", &fqsn!("b"; tr) };
|
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]
|
#[test]
|
||||||
|
Loading…
Reference in New Issue
Block a user