зеркало из https://github.com/github/ruby.git
* gc.c (id2ref): fix symbol test.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10022 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
192fcacebf
Коммит
989fb4fec7
|
@ -1,3 +1,7 @@
|
|||
Sat Mar 4 15:26:40 2006 Tanaka Akira <akr@m17n.org>
|
||||
|
||||
* gc.c (id2ref): fix symbol test.
|
||||
|
||||
Fri Mar 3 21:22:42 2006 Tanaka Akira <akr@m17n.org>
|
||||
|
||||
* lib/fileutils.rb (FileUtils.cp_r): implement :remove_destination
|
||||
|
|
6
gc.c
6
gc.c
|
@ -1938,15 +1938,15 @@ id2ref(VALUE obj, VALUE objid)
|
|||
if (ptr == Qfalse) return Qfalse;
|
||||
if (ptr == Qnil) return Qnil;
|
||||
if (FIXNUM_P(ptr)) return (VALUE)ptr;
|
||||
ptr = objid ^ FIXNUM_FLAG; /* unset FIXNUM_FLAG */
|
||||
|
||||
if ((objid % sizeof(RVALUE)) == (4 << 2)) {
|
||||
ID symid = objid / sizeof(RVALUE);
|
||||
if ((ptr % sizeof(RVALUE)) == (4 << 2)) {
|
||||
ID symid = ptr / sizeof(RVALUE);
|
||||
if (rb_id2name(symid) == 0)
|
||||
rb_raise(rb_eRangeError, "%p is not symbol id value", p0);
|
||||
return ID2SYM(symid);
|
||||
}
|
||||
|
||||
ptr = objid ^ FIXNUM_FLAG; /* unset FIXNUM_FLAG */
|
||||
if (!is_pointer_to_heap((void *)ptr)|| BUILTIN_TYPE(ptr) >= T_BLOCK) {
|
||||
rb_raise(rb_eRangeError, "%p is not id value", p0);
|
||||
}
|
||||
|
|
|
@ -0,0 +1,35 @@
|
|||
require 'test/unit'
|
||||
|
||||
class TestObjectSpace < Test::Unit::TestCase
|
||||
def self.deftest_id2ref(obj)
|
||||
/:(\d+)/ =~ caller[0]
|
||||
file = $`
|
||||
line = $1.to_i
|
||||
eval <<"End", binding, file, line
|
||||
define_method("test_id2ref_#{line}") {\
|
||||
o = ObjectSpace._id2ref(obj.object_id);\
|
||||
assert_equal(obj, o, "didn't round trip: #{obj.inspect}");\
|
||||
}
|
||||
End
|
||||
end
|
||||
|
||||
deftest_id2ref(-0x4000000000000001)
|
||||
deftest_id2ref(-0x4000000000000000)
|
||||
deftest_id2ref(-0x40000001)
|
||||
deftest_id2ref(-0x40000000)
|
||||
deftest_id2ref(-1)
|
||||
deftest_id2ref(0)
|
||||
deftest_id2ref(1)
|
||||
deftest_id2ref(0x3fffffff)
|
||||
deftest_id2ref(0x40000000)
|
||||
deftest_id2ref(0x3fffffffffffffff)
|
||||
deftest_id2ref(0x4000000000000000)
|
||||
deftest_id2ref(:a)
|
||||
deftest_id2ref(:abcdefghijilkjl)
|
||||
deftest_id2ref(:==)
|
||||
deftest_id2ref(Object.new)
|
||||
deftest_id2ref(self)
|
||||
deftest_id2ref(true)
|
||||
deftest_id2ref(false)
|
||||
deftest_id2ref(nil)
|
||||
end
|
Загрузка…
Ссылка в новой задаче