forked from Ada-C7/recursion-writing
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrecursive-methods.rb
More file actions
34 lines (25 loc) · 844 Bytes
/
recursive-methods.rb
File metadata and controls
34 lines (25 loc) · 844 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
def factorial(n)
end
def reverse(s)
end
def bunny(n)
end
def nested(s)
end
# Factorial Tests
raise "factorial broke - factorial(4)" unless factorial(4) == 24
raise "factorial broke - factorial(0)" unless factorial(0) == 1
puts "passes all factorial tests"
# Reverse Tests
raise "reverse broke - reverse('hello world')" unless reverse("hello world") == "dlrow olleh"
raise "reverse broke - reverse('a b c')" unless reverse("a b c") == "c b a"
puts "passes all reverse tests"
# Bunny Tests
raise "bunny broke - bunny(0)" unless bunny(0) == 0
raise "bunny broke - bunny(10)" unless bunny(10) == 20
puts "passes all bunny tests"
# Nested Tests
raise "nested broke - nested('((()))')" unless reverse("((()))") == true
raise "nested broke - nested('())')" unless reverse("())") == false
puts "passes all nested tests"
puts "All test passed"