You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@thrift.apache.org by kc...@apache.org on 2008/06/18 03:18:15 UTC

svn commit: r669016 - in /incubator/thrift/trunk/lib/rb: lib/thrift/types.rb spec/spec_helper.rb spec/types_spec.rb

Author: kclark
Date: Tue Jun 17 18:18:14 2008
New Revision: 669016

URL: http://svn.apache.org/viewvc?rev=669016&view=rev
Log:
rb: Don't type-check when given a nil value.

Turn on type-checking for all specs

Modified:
    incubator/thrift/trunk/lib/rb/lib/thrift/types.rb
    incubator/thrift/trunk/lib/rb/spec/spec_helper.rb
    incubator/thrift/trunk/lib/rb/spec/types_spec.rb

Modified: incubator/thrift/trunk/lib/rb/lib/thrift/types.rb
URL: http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/rb/lib/thrift/types.rb?rev=669016&r1=669015&r2=669016&view=diff
==============================================================================
--- incubator/thrift/trunk/lib/rb/lib/thrift/types.rb (original)
+++ incubator/thrift/trunk/lib/rb/lib/thrift/types.rb Tue Jun 17 18:18:14 2008
@@ -26,7 +26,7 @@
   end
 
   def self.check_type(value, type)
-    return unless Thrift.type_checking
+    return unless Thrift.type_checking and not value.nil?
     klasses = case type
               when Types::VOID
                 NilClass

Modified: incubator/thrift/trunk/lib/rb/spec/spec_helper.rb
URL: http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/rb/spec/spec_helper.rb?rev=669016&r1=669015&r2=669016&view=diff
==============================================================================
--- incubator/thrift/trunk/lib/rb/spec/spec_helper.rb (original)
+++ incubator/thrift/trunk/lib/rb/spec/spec_helper.rb Tue Jun 17 18:18:14 2008
@@ -21,3 +21,9 @@
     self
   end
 end
+
+Spec::Runner.configure do |configuration|
+  configuration.before(:each) do
+    Thrift.type_checking = true
+  end
+end

Modified: incubator/thrift/trunk/lib/rb/spec/types_spec.rb
URL: http://svn.apache.org/viewvc/incubator/thrift/trunk/lib/rb/spec/types_spec.rb?rev=669016&r1=669015&r2=669016&view=diff
==============================================================================
--- incubator/thrift/trunk/lib/rb/spec/types_spec.rb (original)
+++ incubator/thrift/trunk/lib/rb/spec/types_spec.rb Tue Jun 17 18:18:14 2008
@@ -16,12 +16,13 @@
     it "should check types properly" do
       Thrift.type_checking = true
       begin
-        lambda { Thrift.check_type(nil, Types::STOP) }.should raise_error(TypeError)
+        # lambda { Thrift.check_type(nil, Types::STOP) }.should raise_error(TypeError)
+        lambda { Thrift.check_type(3, Types::STOP) }.should raise_error(TypeError)
         lambda { Thrift.check_type(nil, Types::VOID) }.should_not raise_error(TypeError)
         lambda { Thrift.check_type(3, Types::VOID) }.should raise_error(TypeError)
         lambda { Thrift.check_type(true, Types::BOOL) }.should_not raise_error(TypeError)
         lambda { Thrift.check_type(3, Types::BOOL) }.should raise_error(TypeError)
-        lambda { Thrift.check_type(nil, Types::BOOL) }.should raise_error(TypeError)
+        # lambda { Thrift.check_type(nil, Types::BOOL) }.should raise_error(TypeError)
         lambda { Thrift.check_type(42, Types::BYTE) }.should_not raise_error(TypeError)
         lambda { Thrift.check_type(42, Types::I16) }.should_not raise_error(TypeError)
         lambda { Thrift.check_type(42, Types::I32) }.should_not raise_error(TypeError)