From b6d0f9daca887bf2cdbeba2cb898af1a822bcb20 Mon Sep 17 00:00:00 2001 From: collin Date: Mon, 26 Oct 2020 16:46:11 -0700 Subject: [PATCH] fix static and dynamic check test runners --- dynamic-check/tests/mod.rs | 11 ++++++++-- .../src/types/functions/function_input.rs | 16 +------------- static-check/tests/mod.rs | 21 +++++++++++++++---- 3 files changed, 27 insertions(+), 21 deletions(-) diff --git a/dynamic-check/tests/mod.rs b/dynamic-check/tests/mod.rs index 63441b4496..96eac2b74e 100644 --- a/dynamic-check/tests/mod.rs +++ b/dynamic-check/tests/mod.rs @@ -17,8 +17,9 @@ use leo_ast::LeoAst; use leo_dynamic_check::DynamicCheck; +use leo_imports::ImportParser; use leo_static_check::StaticCheck; -use leo_typed::LeoTypedAst; +use leo_typed::{Input, LeoTypedAst}; use std::path::PathBuf; const TEST_PROGRAM_PATH: &str = ""; @@ -44,8 +45,14 @@ impl TestDynamicCheck { let typed = LeoTypedAst::new(TEST_PROGRAM_NAME, &ast); let program = typed.into_repr(); + // Create empty import parser. + let import_parser = ImportParser::new(); + + // Create empty input. + let input = Input::new(); + // Create static check. - let symbol_table = StaticCheck::run_with_input(&program).unwrap(); + let symbol_table = StaticCheck::run_with_input(&program, &import_parser, &input).unwrap(); // Create dynamic check let dynamic_check = DynamicCheck::new(&program, symbol_table).unwrap(); diff --git a/static-check/src/types/functions/function_input.rs b/static-check/src/types/functions/function_input.rs index f801a04afa..4062abe8ef 100644 --- a/static-check/src/types/functions/function_input.rs +++ b/static-check/src/types/functions/function_input.rs @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::{FunctionInputVariableType, ParameterType, SymbolTable, Type, TypeError}; +use crate::{FunctionInputVariableType, SymbolTable, Type, TypeError}; use leo_typed::{FunctionInput, Identifier}; use serde::{Deserialize, Serialize}; @@ -87,18 +87,4 @@ impl FunctionInputType { } }) } - - /// - /// Insert the current function input type into the given symbol table. - /// - /// If the symbol table did not have this name present, `None` is returned. - /// - pub fn insert(&self, table: &mut SymbolTable) -> Option { - match self { - FunctionInputType::Variable(variable) => variable.insert(table), - FunctionInputType::InputKeyword(_identifier) => { - unimplemented!("uncomment when support for input types is added") - } - } - } } diff --git a/static-check/tests/mod.rs b/static-check/tests/mod.rs index 155b8665ae..631b9ca6a0 100644 --- a/static-check/tests/mod.rs +++ b/static-check/tests/mod.rs @@ -18,8 +18,9 @@ pub mod symbol_table; use leo_ast::LeoAst; use leo_static_check::{StaticCheck, StaticCheckError, SymbolTableError}; -use leo_typed::LeoTypedAst; +use leo_typed::{Input, LeoTypedAst}; +use leo_imports::ImportParser; use std::path::PathBuf; const TEST_PROGRAM_PATH: &str = ""; @@ -58,8 +59,14 @@ impl TestStaticCheck { // Get program. let program = self.typed.into_repr(); + // Create empty import parser. + let import_parser = ImportParser::new(); + + // Create empty input. + let input = Input::new(); + // Create new symbol table. - let _symbol_table = StaticCheck::run_with_input(&program).unwrap(); + let _symbol_table = StaticCheck::run_with_input(&program, &import_parser, &input).unwrap(); } /// @@ -74,8 +81,11 @@ impl TestStaticCheck { // Create new symbol table. let static_check = &mut StaticCheck::new(); + // Create empty import parser. + let import_parser = ImportParser::new(); + // Run pass one and expect an error. - let error = static_check.pass_one(&program).unwrap_err(); + let error = static_check.pass_one(&program, &import_parser).unwrap_err(); match error { StaticCheckError::SymbolTableError(SymbolTableError::Error(_)) => {} // Ok @@ -95,8 +105,11 @@ impl TestStaticCheck { // Create a new symbol table. let static_check = &mut StaticCheck::new(); + // Create empty import parser. + let import_parser = ImportParser::new(); + // Run the pass one and expect no errors. - static_check.pass_one(&program).unwrap(); + static_check.pass_one(&program, &import_parser).unwrap(); // Run the pass two and expect and error. let error = static_check.pass_two(&program).unwrap_err();