~ubuntu-branches/ubuntu/raring/jruby/raring

« back to all changes in this revision

Viewing changes to test/externals/ruby1.9/dl/test_cptr.rb

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Delafond
  • Date: 2010-05-12 15:56:25 UTC
  • mfrom: (1.2.1 upstream) (4.1.1 maverick)
  • Revision ID: james.westby@ubuntu.com-20100512155625-sgdfaj1hn8k84090
Tags: 1.5.0~rc3-1
New upstream release (Closes: #581360).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
require_relative 'test_base'
 
2
require_relative '../ruby/envutil'
 
3
 
 
4
module DL
 
5
  class TestCPtr < TestBase
 
6
    def test_free
 
7
      ptr = CPtr.malloc(4)
 
8
      assert_nil ptr.free
 
9
    end
 
10
 
 
11
    def test_free=
 
12
      assert_normal_exit(<<-"End", '[ruby-dev:39269]')
 
13
        require 'dl'
 
14
        DL::LIBC_SO = #{DL::LIBC_SO.dump}
 
15
        DL::LIBM_SO = #{DL::LIBM_SO.dump}
 
16
        include DL
 
17
        @libc = dlopen(LIBC_SO)
 
18
        @libm = dlopen(LIBM_SO)
 
19
        free = CFunc.new(@libc['free'], TYPE_VOID, 'free')
 
20
        ptr = CPtr.malloc(4)
 
21
        ptr.free = free
 
22
        free.ptr
 
23
        ptr.free.ptr
 
24
      End
 
25
 
 
26
      free = CFunc.new(@libc['free'], TYPE_VOID, 'free')
 
27
      ptr = CPtr.malloc(4)
 
28
      ptr.free = free
 
29
 
 
30
      assert_equal free.ptr, ptr.free.ptr
 
31
    end
 
32
  end
 
33
end