Improve compatibility with the old Hash-style set.
authorKevin Clark <kclark@apache.org>
Wed, 18 Jun 2008 01:09:28 +0000 (01:09 +0000)
committerKevin Clark <kclark@apache.org>
Wed, 18 Jun 2008 01:09:28 +0000 (01:09 +0000)
Fix the integration test for the Set change

git-svn-id: https://svn.apache.org/repos/asf/incubator/thrift/trunk@668960 13f79535-47bb-0310-9956-ffa450edef68

lib/rb/lib/thrift/struct.rb
test/rb/integration/test_simple_handler.rb

index be46341..92ce937 100644 (file)
@@ -1,3 +1,5 @@
+require 'set'
+
 module Thrift
   module Struct
     def initialize(d={})
@@ -121,8 +123,8 @@ module Thrift
         oprot.write_list_end
       elsif field[:type] == Types::SET
         oprot.write_set_begin(field[:element][:type], value.size)
-        value.each do |k, v|
-          write_data(oprot, k, field[:element])
+        value.each do |v,| # the , is to preserve compatibility with the old Hash-style sets
+          write_data(oprot, v, field[:element])
         end
         oprot.write_set_end
       else
index 7dd2fbc..fa52c0f 100644 (file)
@@ -114,9 +114,9 @@ class TestThrift < Test::Unit::TestCase
   end
 
   def test_set
-    val = {1 => true, 2 => true, 3 => true}
-    assert_equal(@client.testSet(val), val)
-    assert_kind_of(Hash, @client.testSet(val))
+    val = Set.new([1, 2, 3])
+    assert_equal(val, @client.testSet(val))
+    assert_kind_of(Set, @client.testSet(val))
   end
 
   def get_struct