changes to testing framework

This commit is contained in:
evan-schott 2023-09-05 15:06:28 -07:00
parent a3e25ebc69
commit cc2d54ae2b
5 changed files with 17 additions and 6 deletions

View File

@ -312,7 +312,6 @@ impl<'a> Compiler<'a> {
/// Writes the Symbol Table to a JSON file.
fn write_symbol_table_to_json(&self, file_suffix: &str, symbol_table: &SymbolTable) -> Result<()> {
symbol_table.to_json_file(self.output_directory.clone(), &format!("{}.{file_suffix}", self.program_name))?;
Ok(())
}
}

View File

@ -20,8 +20,8 @@ use utilities::{
get_build_options,
get_cwd_option,
hash_asts,
hash_symbol_tables,
hash_content,
hash_symbol_tables,
parse_program,
setup_build_directory,
BufferEmitter,

View File

@ -22,8 +22,8 @@ use utilities::{
get_build_options,
get_cwd_option,
hash_asts,
hash_symbol_tables,
hash_content,
hash_symbol_tables,
parse_program,
setup_build_directory,
Aleo,

View File

@ -61,8 +61,6 @@ pub fn hash_symbol_tables() -> (String, String, String) {
let type_checked_symbol_table = hash_file("/tmp/output/test.type_checked_symbol_table.json");
let unrolled_symbol_table = hash_file("/tmp/output/test.unrolled_symbol_table.json");
println!("hashed the st's");
(initial_symbol_table, type_checked_symbol_table, unrolled_symbol_table)
}

View File

@ -178,8 +178,22 @@ impl SymbolTable {
/// Serializes the symbol table into a JSON string.
pub fn to_json_string(&self) -> Result<String> {
Ok(serde_json::to_string_pretty(&self).map_err(|e| AstError::failed_to_convert_symbol_table_to_json_string(&e))?)
Ok(serde_json::to_string_pretty(&self)
.map_err(|e| AstError::failed_to_convert_symbol_table_to_json_string(&e))?)
}
/// Converts the symbol table into a JSON value
pub fn to_json_value(&self) -> Result<serde_json::Value> {
Ok(serde_json::to_value(self).map_err(|e| AstError::failed_to_convert_symbol_table_to_json_value(&e))?)
}
// Serializes the symbol table into a JSON file.
pub fn to_json_file(&self, mut path: std::path::PathBuf, file_name: &str) -> Result<()> {
path.push(file_name);
let file =
std::fs::File::create(&path).map_err(|e| AstError::failed_to_create_symbol_table_json_file(&path, &e))?;
let writer = std::io::BufWriter::new(file);
Ok(serde_json::to_writer_pretty(writer, &self)
.map_err(|e| AstError::failed_to_write_symbol_table_to_json_file(&path, &e))?)
}
}