Skip to content

Commit

Permalink
chore: fix some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
TomAFrench committed Feb 27, 2024
1 parent fc82cb0 commit 5c9b841
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 22 deletions.
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
// Tests arithmetic operations on fields
fn main() {
let x = 4;
let y = 2;
assert((x + y) == unsafe { add(x, y) });
assert((x - y) == unsafe { sub(x, y) });
assert((x * y) == unsafe { mul(x, y) });
assert((x / y) == unsafe { div(x, y) });
unsafe {
let x = 4;
let y = 2;
assert((x + y) == add(x, y));
assert((x - y) == sub(x, y));
assert((x * y) == mul(x, y));
assert((x / y) == div(x, y));
}
}

unconstrained fn add(x: Field, y: Field) -> Field {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,28 +3,30 @@ fn main() {
let x: u32 = 6;
let y: u32 = 2;

assert((x + y) == unsafe { add(x, y) });
unsafe {
assert((x + y) == add(x, y));

assert((x - y) == unsafe { sub(x, y) });
assert((x - y) == sub(x, y));

assert((x * y) == unsafe { mul(x, y) });
assert((x * y) == mul(x, y));

assert((x / y) == unsafe { div(x, y) });
// TODO SSA => ACIR has some issues with i32 ops
assert(unsafe { check_signed_div(6, 2, 3)});
assert((x / y) == div(x, y));
// TODO SSA => ACIR has some issues with i32 ops
assert(check_signed_div(6, 2, 3));

assert(unsafe { eq(1, 2) } == false);
assert(unsafe { eq(1, 1) });
assert(eq(1, 2) == false);
assert(eq(1, 1));

assert(unsafe { lt(x, y) } == false);
assert(unsafe { lt(y, x) });
assert(lt(x, y) == false);
assert(lt(y, x));

assert((x & y) == unsafe { and(x, y) });
assert((x | y) == unsafe { or(x, y) });
// TODO SSA => ACIR has some issues with xor ops
assert(unsafe { check_xor(x, y, 4) });
assert((x >> y) == unsafe { shr(x, y) });
assert((x << y) == unsafe { shl(x, y) });
assert((x & y) == and(x, y));
assert((x | y) == or(x, y));
// TODO SSA => ACIR has some issues with xor ops
assert(check_xor(x, y, 4));
assert((x >> y) == shr(x, y));
assert((x << y) == shl(x, y));
}
}

unconstrained fn add(x: u32, y: u32) -> u32 {
Expand Down

0 comments on commit 5c9b841

Please sign in to comment.