Skip to content

Commit

Permalink
Fibonacci test (#8)
Browse files Browse the repository at this point in the history
* Json parser for cairo output programs

* Adding testing and folder structure

* Add Fibonacci test

* Comment out test for now

---------

Co-authored-by: antonio.calvin <[email protected]>
  • Loading branch information
jrchatruc and toni-calvin authored Jul 11, 2023
1 parent 08a45cb commit 0d98aa2
Show file tree
Hide file tree
Showing 6 changed files with 880 additions and 19 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ run:
@go run cmd/cli/main.go

test:
@go test ./...
@go test -v ./...

build:
@cd pkg/lambdaworks/lib/lambdaworks && cargo build --release
Expand Down
18 changes: 18 additions & 0 deletions cairo_programs/fibonacci.cairo
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
func main() {
// Call fib(1, 1, 10).
let result: felt = fib(1, 1, 10);

// Make sure the 10th Fibonacci number is 144.
assert result = 144;
ret;
}

func fib(first_element, second_element, n) -> (res: felt) {
jmp fib_body if n != 0;
tempvar result = second_element;
return (second_element,);

fib_body:
tempvar y = first_element + second_element;
return fib(second_element, y, n - 1);
}
Loading

0 comments on commit 0d98aa2

Please sign in to comment.