Some test fixes

This commit is contained in:
gluaxspeed 2021-07-28 11:53:45 -07:00
parent 7d48c2fb75
commit 72e2bb1fb6
4 changed files with 9 additions and 16 deletions

View File

@ -231,7 +231,9 @@ impl Namespace for CompileNamespace {
.unwrap_or_else(|_| "Error converting ast to string.".to_string()),
);
std::fs::remove_dir_all(std::path::Path::new("/tmp/output")).expect("Error failed to clean up output dir.");
if std::fs::read_dir("/tmp/output").is_ok() {
std::fs::remove_dir_all(std::path::Path::new("/tmp/output")).expect("Error failed to clean up output dir.");
}
let final_output = CompileOutput {
circuit: last_circuit.unwrap(),

View File

@ -95,11 +95,7 @@ impl Namespace for ParseStatementNamespace {
}
fn run_test(&self, test: Test) -> Result<Value, String> {
let tokenizer = tokenizer::tokenize("test", test.content.into()).map_err(|x| {
let s = x.to_string();
println!("s is {}", s);
s
})?;
let tokenizer = tokenizer::tokenize("test", test.content.into()).map_err(|x| x.to_string())?;
if tokenizer
.iter()
.all(|x| matches!(x.token, Token::CommentLine(_) | Token::CommentBlock(_)))
@ -112,11 +108,7 @@ impl Namespace for ParseStatementNamespace {
}
let mut tokens = ParserContext::new(tokenizer);
let parsed = tokens.parse_statement().map_err(|x| {
let s = x.to_string();
println!("bruh {}", s);
s
})?;
let parsed = tokens.parse_statement().map_err(|x| x.to_string())?;
not_fully_consumed(&mut tokens)?;
Ok(serde_yaml::to_value(&parsed).expect("serialization failed"))

View File

@ -1,15 +1,14 @@
/*
namespace: Compile
expectation: Fail
input_file: input/integers.in
input_file: input/dummy.in
*/
function main(a: u32) -> u32 {
function main() {
console.log("{}", 1u8);
return 10u32;
}
function main() {
console.log("{}", 2u8);
console.log("{}", 2u8);
}

View File

@ -2,4 +2,4 @@
namespace: Compile
expectation: Fail
outputs:
- "- Circuit has no constraints, use inputs and registers in program to produce them"
- " --> compiler-test:8:1\n |\n 8 | function main() {\n|\n 9 | ...\n|\n 10 | }\n | ^\n |\n = a function named \"main\" already exists in this scope"