Improve compatibility with the old Hash-style set.
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
diff --git a/lib/rb/lib/thrift/struct.rb b/lib/rb/lib/thrift/struct.rb
index be46341..92ce937 100644
--- a/lib/rb/lib/thrift/struct.rb
+++ b/lib/rb/lib/thrift/struct.rb
@@ -1,3 +1,5 @@
+require 'set'
+
module Thrift
module Struct
def initialize(d={})
@@ -121,8 +123,8 @@
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
diff --git a/test/rb/integration/test_simple_handler.rb b/test/rb/integration/test_simple_handler.rb
index 7dd2fbc..fa52c0f 100644
--- a/test/rb/integration/test_simple_handler.rb
+++ b/test/rb/integration/test_simple_handler.rb
@@ -114,9 +114,9 @@
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