0002-test-ruby-test_object.rb-test_inspect-add-tests-for-.patch

Benoit Daloze, 06/22/2012 07:36 PM

Download (1.44 KB)

View differences:

test/ruby/test_object.rb
690 690
    assert_equal(true, s.tainted?)
691 691
  end
692 692

  
693
  def test_inspect
694
    x = Object.new
695
    assert_match(/\A#<Object:0x\h+>\z/, x.inspect)
696

  
697
    x.instance_variable_set(:@ivar, :value)
698
    assert_match(/\A#<Object:0x\h+ @ivar=:value>\z/, x.inspect)
699

  
700
    x = Object.new
701
    x.instance_variable_set(:@recur, x)
702
    assert_match(/\A#<Object:0x\h+ @recur=#<Object:0x\h+ \.\.\.>>\z/, x.inspect)
703

  
704
    x = Object.new
705
    x.instance_variable_set(:@foo, "value")
706
    x.instance_variable_set(:@bar, 42)
707
    assert_match(/\A#<Object:0x\h+ (?:@foo="value", @bar=42|@bar=42, @foo="value")>\z/, x.inspect)
708

  
709
    # #inspect does not call #to_s anymore
710
    feature6130 = '[ruby-core:43238]'
711
    x = Object.new
712
    def x.to_s
713
      "to_s"
714
    end
715
    assert_match(/\A#<Object:0x\h+>\z/, x.inspect, feature6130)
716
  end
717

  
693 718
  def test_exec_recursive
694 719
    Thread.current[:__recursive_key__] = nil
695 720
    a = [[]]
696
-