Skip to content

Commit

Permalink
Merge pull request #1208 from AleoHQ/feature/console-refactor-and-outs
Browse files Browse the repository at this point in the history
[Bugfix]Fix recently merged tests failing
  • Loading branch information
acoglio authored Jul 28, 2021
2 parents 806e16f + 72e2bb1 commit d2fe35c
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 16 deletions.
4 changes: 3 additions & 1 deletion compiler/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand Down
12 changes: 2 additions & 10 deletions parser/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(_)))
Expand All @@ -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"))
Expand Down
7 changes: 3 additions & 4 deletions tests/compiler/function/duplicate_definition_fail.leo
Original file line number Diff line number Diff line change
@@ -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);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"

0 comments on commit d2fe35c

Please sign in to comment.