From 41c0a0266b9e3fb0432a9b927f9ddb46a15d6f26 Mon Sep 17 00:00:00 2001 From: Kevin Clark Date: Wed, 18 Jun 2008 01:09:28 +0000 Subject: [PATCH] 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 --- lib/rb/lib/thrift/struct.rb | 6 ++++-- test/rb/integration/test_simple_handler.rb | 6 +++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/lib/rb/lib/thrift/struct.rb b/lib/rb/lib/thrift/struct.rb index be46341f..92ce9375 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 @@ 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 diff --git a/test/rb/integration/test_simple_handler.rb b/test/rb/integration/test_simple_handler.rb index 7dd2fbc2..fa52c0f8 100644 --- a/test/rb/integration/test_simple_handler.rb +++ b/test/rb/integration/test_simple_handler.rb @@ -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 -- 2.17.1