diff options
author | marcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-03-07 17:54:49 +0000 |
---|---|---|
committer | marcandre <marcandre@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-03-07 17:54:49 +0000 |
commit | dfde34cb3c968f3238afcfd05298bc6b88585bcb (patch) | |
tree | 634eea6b870bfb289dd47c3b2ab087353218ed16 /test/ruby/marshaltestlib.rb | |
parent | 221f2a1d8a7c42165b3144fbf22b9585e3026e18 (diff) | |
download | ruby-dfde34cb3c968f3238afcfd05298bc6b88585bcb.tar.gz |
* class.c (rb_mod_ancestors): Include singleton_class in ancestors list
[Feature #8035]
* test/ruby/test_module.rb (class): test for above
* test/ruby/marshaltestlib.rb (module): adapt test
* NEWS: list change
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39628 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/marshaltestlib.rb')
-rw-r--r-- | test/ruby/marshaltestlib.rb | 52 |
1 files changed, 20 insertions, 32 deletions
diff --git a/test/ruby/marshaltestlib.rb b/test/ruby/marshaltestlib.rb index c8f81da35c..1507b3a9f1 100644 --- a/test/ruby/marshaltestlib.rb +++ b/test/ruby/marshaltestlib.rb @@ -40,6 +40,14 @@ module MarshalTestLib end end + def marshal_equal_with_ancestry(o1, msg = nil) + marshal_equal(o1, msg) do |o| + ancestry = o.singleton_class.ancestors + ancestry[ancestry.index(o.singleton_class)] = :singleton_class + ancestry + end + end + class MyObject; def initialize(v) @v = v end; attr_reader :v; end def test_object o1 = Object.new @@ -54,25 +62,17 @@ module MarshalTestLib def test_object_extend o1 = Object.new o1.extend(Mod1) - marshal_equal(o1) { |o| - (class << self; self; end).ancestors - } + marshal_equal_with_ancestry(o1) o1.extend(Mod2) - marshal_equal(o1) { |o| - (class << self; self; end).ancestors - } + marshal_equal_with_ancestry(o1) end def test_object_subclass_extend o1 = MyObject.new(2) o1.extend(Mod1) - marshal_equal(o1) { |o| - (class << self; self; end).ancestors - } + marshal_equal_with_ancestry(o1) o1.extend(Mod2) - marshal_equal(o1) { |o| - (class << self; self; end).ancestors - } + marshal_equal_with_ancestry(o1) end class MyArray < Array @@ -141,25 +141,17 @@ module MarshalTestLib def test_hash_extend o1 = Hash.new o1.extend(Mod1) - marshal_equal(o1) { |o| - (class << self; self; end).ancestors - } + marshal_equal_with_ancestry(o1) o1.extend(Mod2) - marshal_equal(o1) { |o| - (class << self; self; end).ancestors - } + marshal_equal_with_ancestry(o1) end def test_hash_subclass_extend o1 = MyHash.new(2) o1.extend(Mod1) - marshal_equal(o1) { |o| - (class << self; self; end).ancestors - } + marshal_equal_with_ancestry(o1) o1.extend(Mod2) - marshal_equal(o1) { |o| - (class << self; self; end).ancestors - } + marshal_equal_with_ancestry(o1) end def test_bignum @@ -289,13 +281,9 @@ module MarshalTestLib def test_struct_subclass_extend o1 = MyStruct.new o1.extend(Mod1) - marshal_equal(o1) { |o| - (class << self; self; end).ancestors - } + marshal_equal_with_ancestry(o1) o1.extend(Mod2) - marshal_equal(o1) { |o| - (class << self; self; end).ancestors - } + marshal_equal_with_ancestry(o1) end def test_symbol @@ -404,7 +392,7 @@ module MarshalTestLib o = Object.new o.extend Mod1 o.extend Mod2 - marshal_equal(o) {|obj| class << obj; ancestors end} + marshal_equal_with_ancestry(o) o = Object.new o.extend Module.new assert_raise(TypeError) { marshaltest(o) } @@ -417,7 +405,7 @@ module MarshalTestLib o = "" o.extend Mod1 o.extend Mod2 - marshal_equal(o) {|obj| class << obj; ancestors end} + marshal_equal_with_ancestry(o) o = "" o.extend Module.new assert_raise(TypeError) { marshaltest(o) } |