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()), .unwrap_or_else(|_| "Error converting ast to string.".to_string()),
); );
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."); std::fs::remove_dir_all(std::path::Path::new("/tmp/output")).expect("Error failed to clean up output dir.");
}
let final_output = CompileOutput { let final_output = CompileOutput {
circuit: last_circuit.unwrap(), circuit: last_circuit.unwrap(),

View File

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

View File

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

View File

@ -2,4 +2,4 @@
namespace: Compile namespace: Compile
expectation: Fail expectation: Fail
outputs: 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"