Test for modules in symbol table
This commit is contained in:
parent
c96644ddce
commit
4a1987b5a2
@ -14,10 +14,10 @@ fn add_symbols_from_source(src: &str) -> (SymbolTable, Result<(), String>) {
|
||||
}
|
||||
|
||||
macro_rules! values_in_table {
|
||||
($source:literal, $single_value:expr) => {
|
||||
values_in_table!($source | $single_value);
|
||||
($source:expr, $single_value:expr) => {
|
||||
values_in_table!($source => $single_value);
|
||||
};
|
||||
($source:literal | $( $value:expr ),* ) => {
|
||||
($source:expr => $( $value:expr ),* ) => {
|
||||
{
|
||||
let (symbol_table, _) = add_symbols_from_source($source);
|
||||
$(
|
||||
@ -33,7 +33,7 @@ macro_rules! values_in_table {
|
||||
#[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" |
|
||||
values_in_table! { "type Option<T> = Some(T) | None" =>
|
||||
&fqsn!("Option"; tr),
|
||||
&fqsn!("Option"; ty, "Some"; tr),
|
||||
&fqsn!("Option"; ty, "None"; tr) };
|
||||
@ -155,6 +155,22 @@ inner_func(x)
|
||||
assert!(output.unwrap_err().contains("Duplicate"))
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn modules() {
|
||||
let source = r#"
|
||||
module stuff {
|
||||
fn item() {
|
||||
}
|
||||
}
|
||||
|
||||
fn item()
|
||||
"#;
|
||||
values_in_table! { source =>
|
||||
&fqsn!("item"; tr),
|
||||
&fqsn!("stuff"; tr, "item"; tr)
|
||||
};
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn duplicate_modules() {
|
||||
let source = r#"
|
||||
|
Loading…
Reference in New Issue
Block a user