From da2497745e207c20b632ec14731397fb48a52fd2 Mon Sep 17 00:00:00 2001 From: nobu Date: Tue, 16 Feb 2010 10:03:02 +0000 Subject: * test/dl/test_{base,handle}.rb: use more verbose assertions. * test/dl/test_import.rb (DL::LIBC::BoundQsortCallback): renamed to get rid of overwriting warning. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@26680 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/dl/test_base.rb | 6 +++--- test/dl/test_handle.rb | 20 ++++++++++---------- test/dl/test_import.rb | 2 +- 3 files changed, 14 insertions(+), 14 deletions(-) (limited to 'test/dl') diff --git a/test/dl/test_base.rb b/test/dl/test_base.rb index e67f0795d5..b0e5e6fa11 100644 --- a/test/dl/test_base.rb +++ b/test/dl/test_base.rb @@ -66,11 +66,11 @@ module DL end def assert_match(expected, actual, message="") - assert(expected === actual, message) + assert_operator(expected, :===, actual, message) end def assert_positive(actual) - assert(actual > 0) + assert_operator(actual, :>, 0) end def assert_zero(actual) @@ -78,7 +78,7 @@ module DL end def assert_negative(actual) - assert(actual < 0) + assert_operator(actual, :<, 0) end def test_empty() diff --git a/test/dl/test_handle.rb b/test/dl/test_handle.rb index 7a7d5bd71c..0345e96e63 100644 --- a/test/dl/test_handle.rb +++ b/test/dl/test_handle.rb @@ -4,7 +4,7 @@ module DL class TestHandle < TestBase def test_to_i handle = DL::Handle.new(LIBC_SO) - assert handle.to_i + assert_kind_of Integer, handle.to_i end def test_static_sym_secure @@ -22,7 +22,7 @@ module DL end def test_static_sym - assert DL::Handle.sym('dlopen') + assert_not_nil DL::Handle.sym('dlopen') assert_equal DL::Handle.sym('dlopen'), DL::Handle['dlopen'] end @@ -57,8 +57,8 @@ module DL def test_sym handle = DL::Handle.new(LIBC_SO) - assert handle.sym('calloc') - assert handle['calloc'] + assert_not_nil handle.sym('calloc') + assert_not_nil handle['calloc'] end def test_handle_close @@ -98,12 +98,12 @@ module DL def test_initialize_noargs handle = DL::Handle.new - assert handle['rb_str_new'] + assert_not_nil handle['rb_str_new'] end def test_initialize_flags handle = DL::Handle.new(LIBC_SO, DL::RTLD_LAZY | DL::RTLD_GLOBAL) - assert handle['calloc'] + assert_not_nil handle['calloc'] end def test_enable_close @@ -134,7 +134,7 @@ module DL # library. # --- Ubuntu Linux 8.04 dlsym(3) handle = DL::Handle::NEXT - assert handle['malloc'] + assert_not_nil handle['malloc'] rescue # BSD # @@ -145,19 +145,19 @@ module DL # called from a shared library, all subsequent shared libraries are # searched. RTLD_NEXT is useful for implementing wrappers around library # functions. For example, a wrapper function getpid() could access the - # “real” getpid() with dlsym(RTLD_NEXT, "getpid"). (Actually, the dlfunc() + # "real" getpid() with dlsym(RTLD_NEXT, "getpid"). (Actually, the dlfunc() # interface, below, should be used, since getpid() is a function and not a # data object.) # --- FreeBSD 8.0 dlsym(3) require 'objspace' handle = DL::Handle::NEXT - assert handle['Init_objspace'] + assert_not_nil handle['Init_objspace'] end end def test_DEFAULT handle = DL::Handle::DEFAULT - assert handle['malloc'] + assert_not_nil handle['malloc'] end end end diff --git a/test/dl/test_import.rb b/test/dl/test_import.rb index e4af382abc..56a417f9ab 100644 --- a/test/dl/test_import.rb +++ b/test/dl/test_import.rb @@ -18,7 +18,7 @@ module DL extern "int gettimeofday(timeval*, timezone*)" rescue nil QsortCallback = bind("void *qsort_callback(void*, void*)", :temp) - BoundQsortCallback = bind("void *qsort_callback(void*, void*)"){|ptr1,ptr2| ptr1[0] <=> ptr2[0]} + BoundQsortCallback = bind("void *bound_qsort_callback(void*, void*)"){|ptr1,ptr2| ptr1[0] <=> ptr2[0]} Timeval = struct [ "long tv_sec", "long tv_usec", -- cgit v1.2.3