File: testObjectSpace.rb

package info (click to toggle)
jruby1.0 1.0.2-4
  • links: PTS
  • area: main
  • in suites: lenny
  • size: 28,004 kB
  • ctags: 33,860
  • sloc: ruby: 166,858; java: 90,218; yacc: 1,572; xml: 708; sh: 700; makefile: 53; ansic: 19
file content (31 lines) | stat: -rw-r--r-- 696 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
require 'test/minirunit'

# Normal objects
o1 = "hey"
o2 = "ho"
id1 = o1.object_id
id2 = o2.object_id
test_equal(o1, ObjectSpace._id2ref(id1))
test_equal(o2, ObjectSpace._id2ref(id2))

# Fixnums
o1 = 17
o2 = 100001
id1 = o1.object_id
id2 = o2.object_id
test_equal(o1, ObjectSpace._id2ref(id1))
test_equal(o2, ObjectSpace._id2ref(id2))

test_equal(1, 0.object_id)
test_equal(3, 1.object_id)
test_equal(201, 100.object_id)
test_equal(-1, -1.object_id)
test_equal(-19, -10.object_id)

test_equal(0, false.object_id)
test_equal(2, true.object_id)
test_equal(4, nil.object_id)

test_equal(false, ObjectSpace._id2ref(0))
test_equal(true, ObjectSpace._id2ref(2))
test_equal(nil, ObjectSpace._id2ref(4))