[前][次][番号順一覧][スレッド一覧]

ruby-changes:14817

From: nobu <ko1@a...>
Date: Tue, 16 Feb 2010 19:03:21 +0900 (JST)
Subject: [ruby-changes:14817] Ruby:r26680 (trunk): * test/dl/test_{base,handle}.rb: use more verbose assertions.

nobu	2010-02-16 19:03:02 +0900 (Tue, 16 Feb 2010)

  New Revision: 26680

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=26680

  Log:
    * 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.

  Modified files:
    trunk/ChangeLog
    trunk/ext/dl/cfunc.c
    trunk/ext/dl/cptr.c
    trunk/test/dl/test_base.rb
    trunk/test/dl/test_handle.rb
    trunk/test/dl/test_import.rb
    trunk/test/dl/test_method.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 26679)
+++ ChangeLog	(revision 26680)
@@ -1,3 +1,10 @@
+Tue Feb 16 19:02:59 2010  Nobuyoshi Nakada  <nobu@r...>
+
+	* 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.
+
 Tue Feb 16 11:03:19 2010  Aaron Patterson <aaron@t...>
 
 	* ext/dl/method.c: Adding DL::Method as a superclass for DL::Function
Index: ext/dl/cfunc.c
===================================================================
--- ext/dl/cfunc.c	(revision 26679)
+++ ext/dl/cfunc.c	(revision 26680)
@@ -147,12 +147,12 @@
     struct cfunc_data *data;
     void *saddr;
     const char *sname;
-    
+
     rb_scan_args(argc, argv, "13", &addr, &type, &name, &calltype);
-    
+
     saddr = (void*)(NUM2PTR(rb_Integer(addr)));
     sname = NIL_P(name) ? NULL : StringValuePtr(name);
-    
+
     TypedData_Get_Struct(self, struct cfunc_data, &dlcfunc_data_type, data);
     if( data->name ) xfree(data->name);
     data->ptr  = saddr;
@@ -286,9 +286,9 @@
     char  *str;
     int str_size;
     struct cfunc_data *cfunc;
-    
+
     TypedData_Get_Struct(self, struct cfunc_data, &dlcfunc_data_type, cfunc);
-    
+
     str_size = (cfunc->name ? strlen(cfunc->name) : 0) + 100;
     str = ruby_xmalloc(str_size);
     snprintf(str, str_size - 1,
@@ -339,14 +339,14 @@
 
     memset(stack, 0, sizeof(DLSTACK_TYPE) * DLSTACK_SIZE);
     Check_Type(ary, T_ARRAY);
-    
+
     TypedData_Get_Struct(self, struct cfunc_data, &dlcfunc_data_type, cfunc);
 
     if( cfunc->ptr == 0 ){
 	rb_raise(rb_eDLError, "can't call null-function");
 	return Qnil;
     }
-    
+
     for( i = 0; i < RARRAY_LEN(ary); i++ ){
 	if( i >= DLSTACK_SIZE ){
 	    rb_raise(rb_eDLError, "too many arguments (stack overflow)");
@@ -354,7 +354,7 @@
 	rb_check_safe_obj(RARRAY_PTR(ary)[i]);
 	stack[i] = NUM2LONG(RARRAY_PTR(ary)[i]);
     }
-    
+
     /* calltype == CFUNC_CDECL */
     if( cfunc->calltype == CFUNC_CDECL
 #ifndef FUNC_STDCALL
Index: ext/dl/cptr.c
===================================================================
--- ext/dl/cptr.c	(revision 26679)
+++ ext/dl/cptr.c	(revision 26680)
@@ -104,7 +104,7 @@
     else{
 	rb_raise(rb_eTypeError, "DL::PtrData was expected");
     }
-    
+
     return ptr;
 }
 

Property changes on: test/dl/test_method.rb
___________________________________________________________________
Name: svn:eol-style
   + LF

Index: test/dl/test_base.rb
===================================================================
--- test/dl/test_base.rb	(revision 26679)
+++ test/dl/test_base.rb	(revision 26680)
@@ -66,11 +66,11 @@
     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 @@
     end
 
     def assert_negative(actual)
-      assert(actual < 0)
+      assert_operator(actual, :<, 0)
     end
 
     def test_empty()
Index: test/dl/test_import.rb
===================================================================
--- test/dl/test_import.rb	(revision 26679)
+++ test/dl/test_import.rb	(revision 26680)
@@ -18,7 +18,7 @@
     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",
Index: test/dl/test_handle.rb
===================================================================
--- test/dl/test_handle.rb	(revision 26679)
+++ test/dl/test_handle.rb	(revision 26680)
@@ -4,7 +4,7 @@
   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 @@
     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 @@
 
     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 @@
 
     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 @@
         # 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 @@
         # 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
-        # ealgetpid() 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

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]