Merge pull request #853 from powdr-labs/run_importer_and_resolver_in_tests

Run importer and resolver in tests.
This commit is contained in:
chriseth
2023-12-19 11:00:53 +00:00
committed by GitHub
3 changed files with 9 additions and 8 deletions

View File

@@ -16,6 +16,7 @@ type_check = { path = "../type_check" }
[dev-dependencies]
parser = { path = "../parser" }
importer = { path = "../importer" }
pretty_assertions = "1.3.0"
test-log = "0.2.12"
env_logger = "0.10.0"

View File

@@ -62,11 +62,11 @@ pub mod utils {
#[cfg(test)]
mod test_util {
use ast::asm_analysis::AnalysisASMFile;
use importer::resolve_str;
use number::FieldElement;
use parser::parse_asm;
/// A test utility to process a source file until after type checking
pub fn typecheck_str<T: FieldElement>(source: &str) -> Result<AnalysisASMFile<T>, Vec<String>> {
type_check::check(parse_asm(None, source).unwrap())
type_check::check(resolve_str(source))
}
}

View File

@@ -173,12 +173,12 @@ mod tests {
let batched: AnalysisASMFile<GoldilocksField> = batch_str(&input);
assert_eq!(
format!("{batched}")
.replace("\n\n", "\n")
.replace('\t', " "),
expected.replace("\n\n", "\n").replace('\t', " "),
);
let result = format!("{batched}").replace("\n\n", "\n");
let expected = expected.replace("\n\n", "\n");
// The stdlib is added by the importer, so we only check for the initial part.
assert!(result.len() >= expected.len());
assert!(expected.len() >= 50);
assert_eq!(result[..expected.len()], expected);
}
#[test]