Skip to content

Commit

Permalink
WIP: add tool to generate test cases for BLS operators
Browse files Browse the repository at this point in the history
  • Loading branch information
arvidn committed May 4, 2023
1 parent 65d7b58 commit 3ad371c
Show file tree
Hide file tree
Showing 3 changed files with 1,578 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/test_ops.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,8 @@ fn run_op_test(op: &Opf, args_str: &str, expected: &str, expected_cost: u64) {
assert_eq!(rest, "");
let result = op(&mut a, args, 10000000000 as Cost);
match result {
Err(_) => {
Err(e) => {
println!("Error: {}", e.1);
assert_eq!(expected, "FAIL");
}
Ok(Reduction(cost, ret_value)) => {
Expand All @@ -219,7 +220,12 @@ fn run_op_test(op: &Opf, args_str: &str, expected: &str, expected_cost: u64) {
fn test_ops() {
use std::fs::read_to_string;

const TEST_FILES: &[&str; 3] = &["test-core-ops.txt", "test-more-ops.txt", "test-bls-ops.txt"];
const TEST_FILES: &[&str; 4] = &[
"test-blspy-vectors.txt",
"test-core-ops.txt",
"test-more-ops.txt",
"test-bls-ops.txt",
];

let funs = HashMap::from([
("i", op_if as Opf),
Expand Down Expand Up @@ -282,7 +288,9 @@ fn test_ops() {
continue;
}
let (op_name, t) = t.split_once(" ").unwrap();
let op = funs.get(op_name).unwrap();
let op = funs
.get(op_name)
.expect(&format!("couldn't find operator \"{op_name}\""));
let (args, out) = t.split_once("=>").unwrap();
let (expected, expected_cost) = if out.contains("|") {
out.split_once("|").unwrap()
Expand Down
Loading

0 comments on commit 3ad371c

Please sign in to comment.