Skip to content

Instantly share code, notes, and snippets.

@mlooney
Created August 19, 2009 16:50
Show Gist options
  • Save mlooney/170456 to your computer and use it in GitHub Desktop.
Save mlooney/170456 to your computer and use it in GitHub Desktop.
An evil hack
require 'test/unit'
class Funky
def self.datehack(a=1, b=a+1)
b
end
def self.evildatehack(a=b+1, b=1)
a
end
end
class ArgHack < Test::Unit::TestCase
def test_date_hack
assert_equal 2, Funky.datehack
assert_equal 4, Funky.datehack(3)
end
def test_evildate_hack
assert_raise NameError do
assert_equal 2, Funky.evildatehack
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment