Skip to content

Instantly share code, notes, and snippets.

@pdabrowski6
Created October 24, 2011 20:02
Show Gist options
  • Save pdabrowski6/1309986 to your computer and use it in GitHub Desktop.
Save pdabrowski6/1309986 to your computer and use it in GitHub Desktop.
fill foo(x)
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