Created
October 24, 2011 20:02
-
-
Save pdabrowski6/1309986 to your computer and use it in GitHub Desktop.
fill foo(x)
This file contains 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 characters
require 'test/unit' | |
def foo(x) | |
if x.kind_of?(Fixnum) | |
x = x * -1 | |
else | |
x = x.to_i | |
x = x * 1 | |
x = x.to_f | |
end | |
if x.kind_of?(Fixnum) | |
x = x.to_f | |
else | |
x = x.to_i | |
end | |
end | |
class TestFoo < Test::Unit::TestCase | |
def test_smoke_scenario | |
assert_equal 1, foo(foo(-1)) | |
assert_equal -5, foo(foo(5)) | |
assert_equal 0, foo(foo(0)) | |
assert_equal 10, foo(foo(foo(foo(10)))) | |
(1..100).each{|i| assert_equal -i, foo(foo(i))} | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment