diff options
-rw-r--r-- | ext/dl/cptr.c | 5 | ||||
-rw-r--r-- | test/dl/test_cptr.rb | 6 |
2 files changed, 11 insertions, 0 deletions
diff --git a/ext/dl/cptr.c b/ext/dl/cptr.c index 488b312025..555236f2ad 100644 --- a/ext/dl/cptr.c +++ b/ext/dl/cptr.c @@ -197,6 +197,11 @@ rb_dlptr_to_i(VALUE self) return PTR2NUM(data->ptr); } +/* + * call-seq: to_value + * + * Cast this CPtr to a ruby object. + */ VALUE rb_dlptr_to_value(VALUE self) { diff --git a/test/dl/test_cptr.rb b/test/dl/test_cptr.rb index 4157f83361..461b7d27d4 100644 --- a/test/dl/test_cptr.rb +++ b/test/dl/test_cptr.rb @@ -3,6 +3,12 @@ require_relative '../ruby/envutil' module DL class TestCPtr < TestBase + def test_to_value + ary = [0,1,2,4,5] + addr = CPtr.new(dlwrap(ary)) + assert_equal ary, addr.to_value + end + def test_free ptr = CPtr.malloc(4) assert_nil ptr.free |