mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	* lib/delegate.rb (Delegator): now inherits BasicObject.
[ruby-dev:39154], [Bug #2679], [ruby-dev:40242] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26566 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
		
							parent
							
								
									7a4621eecf
								
							
						
					
					
						commit
						10e8419da6
					
				
					 3 changed files with 38 additions and 16 deletions
				
			
		| 
						 | 
				
			
			@ -34,12 +34,20 @@ class TestDelegateClass < Test::Unit::TestCase
 | 
			
		|||
    def m
 | 
			
		||||
      :o
 | 
			
		||||
    end
 | 
			
		||||
    private
 | 
			
		||||
    def delegate_test_m
 | 
			
		||||
      :o
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  class Foo
 | 
			
		||||
    def m
 | 
			
		||||
      :m
 | 
			
		||||
    end
 | 
			
		||||
    private
 | 
			
		||||
    def delegate_test_m
 | 
			
		||||
      :m
 | 
			
		||||
    end
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  class Bar < DelegateClass(Foo)
 | 
			
		||||
| 
						 | 
				
			
			@ -50,6 +58,9 @@ class TestDelegateClass < Test::Unit::TestCase
 | 
			
		|||
    assert_equal(:m, Foo.new.m)
 | 
			
		||||
    assert_equal(:m, SimpleDelegator.new(Foo.new).m)
 | 
			
		||||
    assert_equal(:m, Bar.new(Foo.new).m)
 | 
			
		||||
    bug = '[ruby-dev:39154]'
 | 
			
		||||
    assert_equal(:m, SimpleDelegator.new(Foo.new).__send__(:delegate_test_m), bug)
 | 
			
		||||
    assert_equal(:m, Bar.new(Foo.new).__send__(:delegate_test_m), bug)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  class IV < DelegateClass(Integer)
 | 
			
		||||
| 
						 | 
				
			
			@ -67,4 +78,11 @@ class TestDelegateClass < Test::Unit::TestCase
 | 
			
		|||
    d = Marshal.load(Marshal.dump(c))
 | 
			
		||||
    assert_equal(1, d.var, bug1744)
 | 
			
		||||
  end
 | 
			
		||||
 | 
			
		||||
  def test_copy_frozen
 | 
			
		||||
    bug2679 = '[ruby-dev:40242]'
 | 
			
		||||
    a = [42, :hello].freeze
 | 
			
		||||
    d = SimpleDelegator.new(a)
 | 
			
		||||
    assert_nothing_raised(bug2679) {d.dup[0] += 1}
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue