Revisions
-
foysavas revised this gist
Mar 18, 2010 . 3 changed files with 22 additions and 26 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,10 @@ > ruby -rmath_functions.rb -e "puts MathFunctions.factorial(2)" 2 > ruby --test -rmath_functions.rb . Finished in 1.000706 seconds. 1 tests, 2 assertions, 0 failures, 0 errors This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,26 +0,0 @@ This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,12 @@ module MathFunctions def self.factorial(n) (1..n).inject(1) { |acc, x| acc * x} end end =begin :unittest assert MathFunctions.factorial(6) == 720 assert MathFunctions.factorial(5) == 120 =end -
mattknox created this gist
Mar 18, 2010 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,26 @@ module MathFunctions include InlineTest def factorial(n) (1..n).inject(1) { |acc, x| acc * x} end unit_test do assert factorial(6) == 720 assert factorial(5) == 120 end end module InlineTest def env_is_testy? true end if env_is_testy? def unit_test(name, &block) block[] end else def unit_test(*args, &block) end end end