diff options
-rw-r--r-- | lib/rb/lib/thrift/union.rb | 9 | ||||
-rw-r--r-- | lib/rb/spec/union_spec.rb | 5 |
2 files changed, 8 insertions, 6 deletions
diff --git a/lib/rb/lib/thrift/union.rb b/lib/rb/lib/thrift/union.rb index a7058f2c4..490c55c40 100644 --- a/lib/rb/lib/thrift/union.rb +++ b/lib/rb/lib/thrift/union.rb @@ -87,12 +87,9 @@ module Thrift end def ==(other) - other != nil && @setfield == other.get_set_field && @value == other.get_value - end - - def eql?(other) - self.class == other.class && self == other + other.equal?(self) || other.instance_of?(self.class) && @setfield == other.get_set_field && @value == other.get_value end + alias_method :eql?, :== def hash [self.class.name, @setfield, @value].hash @@ -176,4 +173,4 @@ module Thrift end end end -end
\ No newline at end of file +end diff --git a/lib/rb/spec/union_spec.rb b/lib/rb/spec/union_spec.rb index dd84906ae..a4270906d 100644 --- a/lib/rb/spec/union_spec.rb +++ b/lib/rb/spec/union_spec.rb @@ -53,6 +53,11 @@ describe 'Union' do union.should_not == nil end + it "should not be equal with an empty String" do + union = SpecNamespace::My_union.new + union.should_not == '' + end + it "should not equate two different unions, i32 vs. string" do union = SpecNamespace::My_union.new(:integer32, 25) other_union = SpecNamespace::My_union.new(:some_characters, "blah!") |