Sha256: bebf2ea55c207c2bbc602c2dc00a735a33be3d23df2cd48f6482c2fca4e7cb9e
Contents?: true
Size: 1.35 KB
Versions: 4
Compression:
Stored size: 1.35 KB
Contents
require 'test/unit' require 'rbconfig' dir = File.dirname(__FILE__) $:.unshift(dir) if not $:.include?(dir) $:.unshift("#{dir}/../lib") if not $:.include?("#{dir}/../lib") $:.unshift("#{dir}/../ext") if not $:.include?("#{dir}/../ext") require 'internal/method' require "node_samples" $stdout.sync = true $stderr.sync = true class TC_Method < Test::Unit::TestCase module Foo def foo(n=1) # A fancy way to return 42 if false then answer = 0 else answer = 0 (1..42).each do |i| answer += (i / i) end end return n * answer end end class MarshalMethodHelper include Foo end include Foo def test_method_node m = method(:foo) n = m.body if defined?(RubyVM::InstructionSequence) then # YARV assert_equal Node::METHOD, n.class else # pre-YARV assert_equal Node::SCOPE, n.class end end def test_marshal_method o = MarshalMethodHelper.new m = o.method(:foo) d = Marshal.dump(m) m2 = Marshal.load(d) assert_equal m.call, m2.call end def test_marshal_unbound_method o = MarshalMethodHelper.new u = o.method(:foo).unbind d = Marshal.dump(u) u2 = Marshal.load(d) m = u.bind(o) m2 = u.bind(o) assert_equal m.call, m2.call end end if __FILE__ == $0 then exit Test::Unit::AutoRunner.run end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
ruby-internal-0.7.2 | test/test_method.rb |
ruby-internal-0.7.1 | test/test_method.rb |
ruby-internal-0.7.0 | test/test_method.rb |
ruby-internal-0.6.0 | test/test_method.rb |