Skip to content

Instantly share code, notes, and snippets.

@brixen
Created November 30, 2010 21:53
Show Gist options
  • Save brixen/722492 to your computer and use it in GitHub Desktop.
Save brixen/722492 to your computer and use it in GitHub Desktop.
def stat(args)
p :stat => args
end
def xtest(number)
p "number is: #{number}"
return false if number == 3
return true
end
def xfail(number)
puts "failed!"
return :oops
end
def xfail_fixnum(number)
p :fail_number => number
end
def Rubinius.bind_call(recv, meth, *args)
puts "method is #{meth.inspect}"
Rubinius::CallUnit.test(
Rubinius::CallUnit.for_method(method(:xtest)),
Rubinius::CallUnit.for_method(method(:stat)),
Rubinius::CallUnit.test(
Rubinius::CallUnit.test_kind_of(Fixnum, 0),
Rubinius::CallUnit.for_method(method(:xfail_fixnum)),
Rubinius::CallUnit.for_method(method(:xfail))))
end
obj = Object.new
def foo(obj, num)
puts "foo called with #{obj.inspect}, #{num.inspect}"
Rubinius.call_custom(obj, :blurg, num)
end
5.times do
foo(obj, 1)
end
foo(obj, 2)
foo(obj, 3)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment