Sha256: e913c846857a3a10b38b2b9eb70e950849697bb6ce971e89f7095b3456016dcf
Contents?: true
Size: 1.31 KB
Versions: 1
Compression:
Stored size: 1.31 KB
Contents
# _____ _ # |_ _|__ ___| |_ # | |/ _ \/ __| __| # | | __/\__ \ |_ # |_|\___||___/\__| # # for lib/facets/core/kernel/instance_exec.rb # # Extracted Fri Feb 16 02:00:36 EST 2007 # Project.rb Test Extraction # require 'facets/core/kernel/instance_exec.rb' require 'test/unit' class TestInstanceEvalWithArgs < Test::Unit::TestCase class Dummy def f :dummy_value end end def test_instance_exec # Create a block that returns the value of an argument # and a value of a method call to +self+. block = lambda { |a| [a, f] } assert_equal [:arg_value, :dummy_value], Dummy.new.instance_exec(:arg_value, &block) end def test_instance_exec_with_frozen_obj block = lambda { |a| [a, f] } obj = Dummy.new obj.freeze assert_equal [:arg_value, :dummy_value], obj.instance_exec(:arg_value, &block) end def test_instance_exec_nested i = 0 obj = Dummy.new block = lambda do |arg| [arg] + instance_exec(1){|a| [f, a] } end assert_equal([:arg_value, :dummy_value, 1], obj.instance_exec(:arg_value, &block)) end def test_instance_exec_with_immediate_value obj = 1 block = lambda { |a| [a,self] } assert_equal(["A", 1], obj.instance_exec("A", &block)) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
facets-1.8.49 | test/lib/facets/core/kernel/test_instance_exec.rb |