mirror of
https://github.com/AleoHQ/leo.git
synced 2024-09-22 04:27:25 +03:00
fix static and dynamic check test runners
This commit is contained in:
parent
020773fb2a
commit
b6d0f9daca
@ -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();
|
||||
|
@ -14,7 +14,7 @@
|
||||
// You should have received a copy of the GNU General Public License
|
||||
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
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<ParameterType> {
|
||||
match self {
|
||||
FunctionInputType::Variable(variable) => variable.insert(table),
|
||||
FunctionInputType::InputKeyword(_identifier) => {
|
||||
unimplemented!("uncomment when support for input types is added")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user