From 4a1987b5a2fc371c8d8cb4df57cfe2c9a30ae5b7 Mon Sep 17 00:00:00 2001 From: greg Date: Thu, 24 Oct 2019 03:02:52 -0700 Subject: [PATCH] Test for modules in symbol table --- schala-lang/language/src/symbol_table/test.rs | 24 +++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/schala-lang/language/src/symbol_table/test.rs b/schala-lang/language/src/symbol_table/test.rs index 11c2d2d..d6188e0 100644 --- a/schala-lang/language/src/symbol_table/test.rs +++ b/schala-lang/language/src/symbol_table/test.rs @@ -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 = Some(T) | None" | + values_in_table! { "type Option = 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#"