mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
merge revision(s) 45076: [Backport #9535]
* class.c (rb_mod_init_copy): do nothing if copying self. [ruby-dev:47989] [Bug #9535] * hash.c (rb_hash_initialize_copy): ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_3@45091 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
941bd1c392
commit
9e11c028e3
7 changed files with 28 additions and 5 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Sat Feb 22 09:26:05 2014 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
|
* class.c (rb_mod_init_copy): do nothing if copying self.
|
||||||
|
[ruby-dev:47989] [Bug #9535]
|
||||||
|
|
||||||
Tue Feb 18 22:53:34 2014 NAKAMURA Usaku <usa@ruby-lang.org>
|
Tue Feb 18 22:53:34 2014 NAKAMURA Usaku <usa@ruby-lang.org>
|
||||||
|
|
||||||
* ruby_atomic.h: fixed merge mistake of r44946. reported by ngoto at
|
* ruby_atomic.h: fixed merge mistake of r44946. reported by ngoto at
|
||||||
|
|
1
class.c
1
class.c
|
@ -180,6 +180,7 @@ rb_mod_init_copy(VALUE clone, VALUE orig)
|
||||||
if (RB_TYPE_P(clone, T_CLASS)) {
|
if (RB_TYPE_P(clone, T_CLASS)) {
|
||||||
class_init_copy_check(clone, orig);
|
class_init_copy_check(clone, orig);
|
||||||
}
|
}
|
||||||
|
if (clone == orig) return clone;
|
||||||
rb_obj_init_copy(clone, orig);
|
rb_obj_init_copy(clone, orig);
|
||||||
if (!FL_TEST(CLASS_OF(clone), FL_SINGLETON)) {
|
if (!FL_TEST(CLASS_OF(clone), FL_SINGLETON)) {
|
||||||
RBASIC(clone)->klass = rb_singleton_class_clone(orig);
|
RBASIC(clone)->klass = rb_singleton_class_clone(orig);
|
||||||
|
|
|
@ -1033,6 +1033,7 @@ static VALUE cState_init_copy(VALUE obj, VALUE orig)
|
||||||
{
|
{
|
||||||
JSON_Generator_State *objState, *origState;
|
JSON_Generator_State *objState, *origState;
|
||||||
|
|
||||||
|
if (obj == orig) return obj;
|
||||||
Data_Get_Struct(obj, JSON_Generator_State, objState);
|
Data_Get_Struct(obj, JSON_Generator_State, objState);
|
||||||
Data_Get_Struct(orig, JSON_Generator_State, origState);
|
Data_Get_Struct(orig, JSON_Generator_State, origState);
|
||||||
if (!objState) rb_raise(rb_eArgError, "unallocated JSON::State");
|
if (!objState) rb_raise(rb_eArgError, "unallocated JSON::State");
|
||||||
|
|
|
@ -1334,6 +1334,7 @@ rb_deflate_init_copy(VALUE self, VALUE orig)
|
||||||
Data_Get_Struct(self, struct zstream, z1);
|
Data_Get_Struct(self, struct zstream, z1);
|
||||||
z2 = get_zstream(orig);
|
z2 = get_zstream(orig);
|
||||||
|
|
||||||
|
if (z1 == z2) return self;
|
||||||
err = deflateCopy(&z1->stream, &z2->stream);
|
err = deflateCopy(&z1->stream, &z2->stream);
|
||||||
if (err != Z_OK) {
|
if (err != Z_OK) {
|
||||||
raise_zlib_error(err, 0);
|
raise_zlib_error(err, 0);
|
||||||
|
|
|
@ -117,6 +117,12 @@ class TestHash < Test::Unit::TestCase
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_self_initialize_copy
|
||||||
|
h = @cls[1=>2]
|
||||||
|
h.instance_eval {initialize_copy(h)}
|
||||||
|
assert_equal(2, h[1])
|
||||||
|
end
|
||||||
|
|
||||||
def test_AREF # '[]'
|
def test_AREF # '[]'
|
||||||
t = Time.now
|
t = Time.now
|
||||||
h = @cls[
|
h = @cls[
|
||||||
|
@ -145,8 +151,6 @@ class TestHash < Test::Unit::TestCase
|
||||||
assert_equal('nil', h1[nil])
|
assert_equal('nil', h1[nil])
|
||||||
assert_equal(nil, h1['nil'])
|
assert_equal(nil, h1['nil'])
|
||||||
assert_equal(:default, h1['koala'])
|
assert_equal(:default, h1['koala'])
|
||||||
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_ASET # '[]='
|
def test_ASET # '[]='
|
||||||
|
|
|
@ -277,6 +277,17 @@ class TestModule < Test::Unit::TestCase
|
||||||
assert_equal([:MIXIN, :USER], User.constants.sort)
|
assert_equal([:MIXIN, :USER], User.constants.sort)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def test_self_initialize_copy
|
||||||
|
bug9535 = '[ruby-dev:47989] [Bug #9535]'
|
||||||
|
m = Module.new do
|
||||||
|
def foo
|
||||||
|
:ok
|
||||||
|
end
|
||||||
|
initialize_copy(self)
|
||||||
|
end
|
||||||
|
assert_equal(:ok, Object.new.extend(m).foo, bug9535)
|
||||||
|
end
|
||||||
|
|
||||||
def test_included_modules
|
def test_included_modules
|
||||||
assert_equal([], Mixin.included_modules)
|
assert_equal([], Mixin.included_modules)
|
||||||
assert_equal([Mixin], User.included_modules)
|
assert_equal([Mixin], User.included_modules)
|
||||||
|
|
|
@ -1,10 +1,10 @@
|
||||||
#define RUBY_VERSION "1.9.3"
|
#define RUBY_VERSION "1.9.3"
|
||||||
#define RUBY_PATCHLEVEL 537
|
#define RUBY_PATCHLEVEL 538
|
||||||
|
|
||||||
#define RUBY_RELEASE_DATE "2014-02-19"
|
#define RUBY_RELEASE_DATE "2014-02-22"
|
||||||
#define RUBY_RELEASE_YEAR 2014
|
#define RUBY_RELEASE_YEAR 2014
|
||||||
#define RUBY_RELEASE_MONTH 2
|
#define RUBY_RELEASE_MONTH 2
|
||||||
#define RUBY_RELEASE_DAY 19
|
#define RUBY_RELEASE_DAY 22
|
||||||
|
|
||||||
#include "ruby/version.h"
|
#include "ruby/version.h"
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue