~ubuntu-branches/ubuntu/hardy/ruby1.8/hardy-updates

« back to all changes in this revision

Viewing changes to test/ruby/test_objectspace.rb

  • Committer: Bazaar Package Importer
  • Author(s): akira yamada
  • Date: 2007-03-13 22:11:58 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20070313221158-h3oql37brlaf2go2
Tags: 1.8.6-1
* new upstream version, 1.8.6.
* libruby1.8 conflicts with libopenssl-ruby1.8 (< 1.8.6) (closes: #410018)
* changed packaging style to cdbs from dbs.

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_same(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