WIP: recursion
This commit is contained in:
parent
f176d36dd8
commit
1597d1eaf4
4
src/test/contracts/recursion.ligo
Normal file
4
src/test/contracts/recursion.ligo
Normal file
@ -0,0 +1,4 @@
|
||||
// Test while loops in PascaLIGO
|
||||
|
||||
function fibo (const n : int; const acc: int) : int is
|
||||
if n<1 then acc else fibo(n-1,acc+n)
|
5
src/test/contracts/recursion.mligo
Normal file
5
src/test/contracts/recursion.mligo
Normal file
@ -0,0 +1,5 @@
|
||||
// Test while loops in PascaLIGO
|
||||
|
||||
let fibo (n : int) (acc: int) : int =
|
||||
if (n < 1) then acc
|
||||
else fibo (n-1) (acc+n)
|
@ -1493,6 +1493,20 @@ let assert_religo () : unit result =
|
||||
let%bind _ = expect_eq program "main" (make_input true) make_expected in
|
||||
ok ()
|
||||
|
||||
let recursion_ligo () : unit result =
|
||||
let%bind program = type_file "./contracts/recursion.ligo" in
|
||||
let make_input = e_pair (e_int 10) (e_int 0) in
|
||||
let make_expected = e_int 55 in
|
||||
let%bind _ = expect_eq program "fibo" make_input make_expected in
|
||||
ok ()
|
||||
|
||||
let recursion_mligo () : unit result =
|
||||
let%bind program = mtype_file "./contracts/recursion.mligo" in
|
||||
let make_input = e_pair (e_int 10) (e_int 0) in
|
||||
let make_expected = e_int 55 in
|
||||
let%bind _ = expect_eq program "fibo" make_input make_expected in
|
||||
ok ()
|
||||
|
||||
let guess_string_mligo () : unit result =
|
||||
let%bind program = type_file "./contracts/guess_string.mligo" in
|
||||
let make_input = fun n -> e_pair (e_int n) (e_int 42) in
|
||||
@ -2407,6 +2421,8 @@ let main = test_suite "Integration (End to End)" [
|
||||
test "failwith ligo" failwith_ligo ;
|
||||
test "failwith mligo" failwith_mligo ;
|
||||
test "assert mligo" assert_mligo ;
|
||||
test "recursion (ligo)" recursion_ligo ;
|
||||
test "recursion (mligo)" recursion_mligo ;
|
||||
(* test "guess string mligo" guess_string_mligo ; WIP? *)
|
||||
test "lambda mligo" lambda_mligo ;
|
||||
test "lambda religo" lambda_religo ;
|
||||
|
Loading…
Reference in New Issue
Block a user