~ubuntu-branches/ubuntu/trusty/ruby1.9/trusty

« back to all changes in this revision

Viewing changes to test/ruby/test_objectspace.rb

  • Committer: Bazaar Package Importer
  • Author(s): Lucas Nussbaum
  • Date: 2006-05-08 22:23:12 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20060508222312-w2wqeaz030ifi59j
Tags: 1.9.0+20060423-3ubuntu1
* Resynchronized with Debian.
* Only change from Debian is the addition of
  debian/patches/903_sparc_fix_define.patch to fix illegal instructions
  at runtime on sparc. (change from 1.9.0+20050921-1ubuntu1)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
require 'test/unit'
 
2
 
 
3
class TestObjectSpace < Test::Unit::TestCase
 
4
  def self.deftest_id2ref(obj)
 
5
    /:(\d+)/ =~ caller[0]
 
6
    file = $`
 
7
    line = $1.to_i
 
8
    code = <<"End"
 
9
    define_method("test_id2ref_#{line}") {\
 
10
      o = ObjectSpace._id2ref(obj.object_id);\
 
11
      assert_equal(obj, o, "didn't round trip: \#{obj.inspect}");\
 
12
    }
 
13
End
 
14
    eval code, binding, file, line
 
15
  end
 
16
 
 
17
  deftest_id2ref(-0x4000000000000001)
 
18
  deftest_id2ref(-0x4000000000000000)
 
19
  deftest_id2ref(-0x40000001)
 
20
  deftest_id2ref(-0x40000000)
 
21
  deftest_id2ref(-1)
 
22
  deftest_id2ref(0)
 
23
  deftest_id2ref(1)
 
24
  deftest_id2ref(0x3fffffff)
 
25
  deftest_id2ref(0x40000000)
 
26
  deftest_id2ref(0x3fffffffffffffff)
 
27
  deftest_id2ref(0x4000000000000000)
 
28
  deftest_id2ref(:a)
 
29
  deftest_id2ref(:abcdefghijilkjl)
 
30
  deftest_id2ref(:==)
 
31
  deftest_id2ref(Object.new)
 
32
  deftest_id2ref(self)
 
33
  deftest_id2ref(true)
 
34
  deftest_id2ref(false)
 
35
  deftest_id2ref(nil)
 
36
end