File tree Expand file tree Collapse file tree 1 file changed +34
-7
lines changed
spec/ruby/core/objectspace Expand file tree Collapse file tree 1 file changed +34
-7
lines changed Original file line number Diff line number Diff line change 7
7
r . should == s
8
8
end
9
9
10
- it "retrieves an Integer by object_id" do
11
- f = 1
12
- r = ObjectSpace . _id2ref ( f . object_id )
13
- r . should == f
10
+ it "retrieves true by object_id" do
11
+ ObjectSpace . _id2ref ( true . object_id ) . should == true
12
+ end
13
+
14
+ it "retrieves false by object_id" do
15
+ ObjectSpace . _id2ref ( false . object_id ) . should == false
16
+ end
17
+
18
+ it "retrieves nil by object_id" do
19
+ ObjectSpace . _id2ref ( nil . object_id ) . should == nil
20
+ end
21
+
22
+ it "retrieves a small Integer by object_id" do
23
+ ObjectSpace . _id2ref ( 1 . object_id ) . should == 1
24
+ ObjectSpace . _id2ref ( ( -42 ) . object_id ) . should == -42
25
+ end
26
+
27
+ it "retrieves a large Integer by object_id" do
28
+ obj = 1 << 88
29
+ ObjectSpace . _id2ref ( obj . object_id ) . should . equal? ( obj )
14
30
end
15
31
16
32
it "retrieves a Symbol by object_id" do
17
- s = :sym
18
- r = ObjectSpace . _id2ref ( s . object_id )
19
- r . should == s
33
+ ObjectSpace . _id2ref ( :sym . object_id ) . should . equal? ( :sym )
34
+ end
35
+
36
+ it "retrieves a String by object_id" do
37
+ obj = "str"
38
+ ObjectSpace . _id2ref ( obj . object_id ) . should . equal? ( obj )
39
+ end
40
+
41
+ it "retrieves a frozen literal String by object_id" do
42
+ ObjectSpace . _id2ref ( "frozen string literal _id2ref" . freeze . object_id ) . should . equal? ( "frozen string literal _id2ref" . freeze )
43
+ end
44
+
45
+ it "retrieves an Encoding by object_id" do
46
+ ObjectSpace . _id2ref ( Encoding ::UTF_8 . object_id ) . should . equal? ( Encoding ::UTF_8 )
20
47
end
21
48
22
49
it 'raises RangeError when an object could not be found' do
You can’t perform that action at this time.
0 commit comments