[ruby-oci8-commit] [406] branches/ruby-oci8-2.0: * ruby-oci8/lib/oci8/object.rb: fix an error when SDO_GEOMETRY is used

nobody at rubyforge.org nobody at rubyforge.org
Mon Aug 23 11:33:20 EDT 2010


Revision: 406
Author:   kubo
Date:     2010-08-23 11:33:20 -0400 (Mon, 23 Aug 2010)

Log Message:
-----------
* ruby-oci8/lib/oci8/object.rb: fix an error when SDO_GEOMETRY is used
    and $VERBOSE is set.
* ruby-oci8/test/test_oranumber.rb: change a testcase for ruby 1.9.2.
    Math::atan2(0, 0) behaviour was changed in 1.9.2.

Modified Paths:
--------------
    branches/ruby-oci8-2.0/ChangeLog
    branches/ruby-oci8-2.0/lib/oci8/object.rb
    branches/ruby-oci8-2.0/test/test_oranumber.rb

Modified: branches/ruby-oci8-2.0/ChangeLog
===================================================================
--- branches/ruby-oci8-2.0/ChangeLog	2010-08-15 12:33:14 UTC (rev 405)
+++ branches/ruby-oci8-2.0/ChangeLog	2010-08-23 15:33:20 UTC (rev 406)
@@ -1,3 +1,9 @@
+2010-08-24  KUBO Takehiro  <kubo at jiubao.org>
+	* ruby-oci8/lib/oci8/object.rb: fix an error when SDO_GEOMETRY is used
+	    and $VERBOSE is set.
+	* ruby-oci8/test/test_oranumber.rb: change a testcase for ruby 1.9.2.
+	    Math::atan2(0, 0) behaviour was changed in 1.9.2.
+
 2010-08-15  KUBO Takehiro  <kubo at jiubao.org>
 	* ext/oci8/lob.c, ext/oci8/object.c, ext/oci8/oci8.h,
 	  lib/oci8/object.rb: support LOB datatypes in Oracle objects.

Modified: branches/ruby-oci8-2.0/lib/oci8/object.rb
===================================================================
--- branches/ruby-oci8-2.0/lib/oci8/object.rb	2010-08-15 12:33:14 UTC (rev 405)
+++ branches/ruby-oci8-2.0/lib/oci8/object.rb	2010-08-23 15:33:20 UTC (rev 406)
@@ -394,7 +394,7 @@
             @class_methods[type_method.name.downcase.intern] = result_type
           end
         else
-          warn "unsupported return type (#{schema_name}.#{name}.#{type_method.name})" if $VERBOSE
+          warn "unsupported return type (#{metadata.schema_name}.#{metadata.name}.#{type_method.name})" if $VERBOSE
         end
       end
     end

Modified: branches/ruby-oci8-2.0/test/test_oranumber.rb
===================================================================
--- branches/ruby-oci8-2.0/test/test_oranumber.rb	2010-08-15 12:33:14 UTC (rev 405)
+++ branches/ruby-oci8-2.0/test/test_oranumber.rb	2010-08-23 15:33:20 UTC (rev 406)
@@ -238,11 +238,28 @@
 
   # OCI8::Math.atan2(y, x) -> ocinumber
   def test_math_atan2
+    # Prior to ruby 1.9.2:
+    #   Following method calls' return values depend on the underneath C library
+    #   implementation.
+    #
+    #     Math::atan2(+0.0, +0.0)
+    #     Math::atan2(-0.0, +0.0)
+    #     Math::atan2(+0.0, -0.0)
+    #     Math::atan2(-0.0, -0.0)
+    #
+    #   They are +0.0, -0.0, +PI and -PI respectively as far as I checked them on
+    #   Windows and Linux.
+    #
+    # After ruby 1.9.2:
+    #   They all raise a Math::DomainError exception.
+    #
+    # In contrast to Math::atan2, OCI8::Math::atan2(0, 0) allways returns 0 because
+    # OraNumber doesn't have the difference between +0 and -0.
     compare_with_float2(SMALL_RANGE_VALUES, SMALL_RANGE_VALUES,
-                        Proc.new {|x, y| Math::atan2(x, y.to_f)},
+                        Proc.new {|x, y| (x.to_f == 0 && y.to_f == 0) ? 0 : Math::atan2(x, y.to_f)},
                         Proc.new {|x, y| OCI8::Math::atan2(x, y.to_f)})
     compare_with_float2(SMALL_RANGE_VALUES, SMALL_RANGE_VALUES,
-                        Proc.new {|x, y| Math::atan2(y.to_f, x)},
+                        Proc.new {|x, y| (x.to_f == 0 && y.to_f == 0) ? 0 : Math::atan2(y.to_f, x)},
                         Proc.new {|x, y| OCI8::Math::atan2(y.to_f, x)})
   end
 




More information about the ruby-oci8-commit mailing list