From 6927c5c03898414f840d740a90613eed74e6fe8d Mon Sep 17 00:00:00 2001 From: belliash Date: Thu, 7 Feb 2019 18:29:53 +0100 Subject: [PATCH] Factorial test. --- tests/factorial_test.aer | 15 +++++++++++++++ tests/factorial_test.exp | 1 + 2 files changed, 16 insertions(+) create mode 100644 tests/factorial_test.aer create mode 100644 tests/factorial_test.exp diff --git a/tests/factorial_test.aer b/tests/factorial_test.aer new file mode 100644 index 0000000..f064e5c --- /dev/null +++ b/tests/factorial_test.aer @@ -0,0 +1,15 @@ +class Program { + + function factorial(int $num) { + if($num == 0 || $num == 1) + return 1; + else + return $num * $this->factorial($num - 1); + } + + function main() { + int $num = 7; + print('Factorial of ', $num, ' is ', $this->factorial($num), '.'); + } + +} diff --git a/tests/factorial_test.exp b/tests/factorial_test.exp new file mode 100644 index 0000000..279b35a --- /dev/null +++ b/tests/factorial_test.exp @@ -0,0 +1 @@ +Factorial of 7 is 5040.