Skip to content

Commit

Permalink
test: add tests for trace column groups to IR
Browse files Browse the repository at this point in the history
  • Loading branch information
tohrnii committed Dec 22, 2022
1 parent 0402835 commit c13bb22
Showing 1 changed file with 67 additions and 0 deletions.
67 changes: 67 additions & 0 deletions ir/src/tests/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,73 @@ fn boundary_constraints_with_constants() {
assert!(result.is_ok());
}

#[test]
fn trace_cols_groups() {
let source = "
constants:
A: 123
B: [1, 2, 3]
C: [[1, 2, 3], [4, 5, 6]]
trace_columns:
main: [clk, a[4]]
public_inputs:
stack_inputs: [16]
transition_constraints:
enf a[0]' = a[1] - 1
boundary_constraints:
enf a[1].first = A
enf clk.last = B[0] + C[0][1]";

let parsed = parse(source).expect("Parsing failed");
let result = AirIR::from_source(&parsed);
assert!(result.is_ok());
}

#[test]
fn err_trace_cols_access_out_of_bounds() {
// out of bounds in transition constraints
let source = "
constants:
A: 123
B: [1, 2, 3]
C: [[1, 2, 3], [4, 5, 6]]
trace_columns:
main: [clk, a[4]]
public_inputs:
stack_inputs: [16]
transition_constraints:
enf a[4]' = a[4] - 1
boundary_constraints:
enf a[1].first = A
enf clk.last = B[0] + C[0][1]";

let parsed = parse(source).expect("Parsing failed");

let result = AirIR::from_source(&parsed);
assert!(result.is_err());

// out of bounds in boundary constraints
let source = "
constants:
A: 123
B: [1, 2, 3]
C: [[1, 2, 3], [4, 5, 6]]
trace_columns:
main: [clk, a[4]]
public_inputs:
stack_inputs: [16]
transition_constraints:
enf a[0]' = a[0] - 1
boundary_constraints:
enf a[4].first = A
enf clk.last = B[0] + C[0][1]";

let parsed = parse(source).expect("Parsing failed");

let result = AirIR::from_source(&parsed);
assert!(result.is_err());
}

#[test]
fn err_tc_invalid_vector_access() {
let source = "
Expand Down

0 comments on commit c13bb22

Please sign in to comment.