Skip to content

Commit

Permalink
Add integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
fmoletta committed Sep 18, 2023
1 parent a1ceb1f commit 267803a
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 0 deletions.
63 changes: 63 additions & 0 deletions cairo_programs/math_cmp.cairo
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
%builtins range_check

from starkware.cairo.common.math_cmp import (
is_not_zero,
is_nn,
is_le,
is_nn_le,
is_in_range,
is_le_felt,
)

func main{range_check_ptr: felt}() {
// is_not_zero
let a = is_not_zero(10);
assert a = 1;
let b = is_not_zero(1);
assert b = 1;
let c = is_not_zero(0);
assert c = 0;

// is_nn
let d = is_nn(0);
assert d = 1;
let e = is_nn(88);
assert e = 1;
let f = is_nn(-88);
assert f = 0;

// is_le
let g = is_le(1, 2);
assert g = 1;
let h = is_le(2, 2);
assert h = 1;
let i = is_le(56, 20);
assert i = 0;

// is_nn_le
let j = is_nn_le(1, 2);
assert j = 1;
let k = is_nn_le(2, 2);
assert k = 1;
let l = is_nn_le(56, 20);
assert l = 0;

// is_in_range
let m = is_in_range(1, 2, 3);
assert m = 0;
let n = is_in_range(2, 2, 5);
assert n = 1;
let o = is_in_range(56, 20, 120);
assert o = 1;

// TODO: Uncomment once ASSERT_LE_FELT hint is implemented
// is_le_felt
// let p = is_le_felt(1, 2);
// assert p = 1;
// let q = is_le_felt(2, 2);
// assert q = 1;
// let r = is_le_felt(56, 20);
// assert r = 0;

return ();
}
8 changes: 8 additions & 0 deletions pkg/vm/cairo_run/cairo_run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,3 +202,11 @@ func TestSqrtHint(t *testing.T) {
t.Errorf("Program execution failed with error: %s", err)
}
}

func TestMathCmp(t *testing.T) {
cairoRunConfig := cairo_run.CairoRunConfig{DisableTracePadding: false, Layout: "all_cairo", ProofMode: false}
_, err := cairo_run.CairoRun("../../../cairo_programs/math_cmp.json", cairoRunConfig)
if err != nil {
t.Errorf("Program execution failed with error: %s", err)
}
}

0 comments on commit 267803a

Please sign in to comment.