Skip to content

Commit

Permalink
Test a first non-trivial function: factorial
Browse files Browse the repository at this point in the history
  • Loading branch information
mossprescott committed Feb 13, 2024
1 parent 65888db commit f22871c
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions alt/scheme/test_rvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,21 @@ def test_define():
assert output == []


def test_fact():
program = """
(define (fact n)
(if (< n 2) 1
(* n (fact (- n 1)))))
(fact 5)
"""

inspect, output = run_to_halt(program, max_cycles=20000)

assert inspect.stack() == [120]
assert output == []


def test_capture():
program = """
(define (add x) (lambda (y) (+ x y)))
Expand Down

0 comments on commit f22871c

Please sign in to comment.