Changeset 1030
- Timestamp:
- 11/02/03 20:53:35 (5 years ago)
- Files:
-
- trunk/test/soap/marshal/test_marshal.rb (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/test/soap/marshal/test_marshal.rb
r1027 r1030 288 288 289 289 MyStruct = Struct.new("MyStruct", :a, :b) 290 if RUBY_VERSION < "1.8.0" 291 # Struct#== is not defined in ruby/1.6 292 class MyStruct 293 def ==(rhs) 294 return true if __id__ == rhs.__id__ 295 return false unless rhs.is_a?(::Struct) 296 return false if self.class != rhs.class 297 members.each do |member| 298 return false if self.__send__(member) != rhs.__send__(member) 299 end 300 return true 301 end 302 end 303 end 290 304 class MySubStruct < MyStruct; def initialize(v, *args) super(*args); @v = v; end end 291 305 def test_struct … … 294 308 295 309 def test_struct_subclass 310 if RUBY_VERSION < "1.8.0" 311 # Substruct instance cannot be dumped in ruby/1.6 312 # ::Marshal.dump(MySubStruct.new(10, 1, 2)) #=> uninitialized struct 313 return false 314 end 296 315 marshal_equal(MySubStruct.new(10,1,2)) 297 316 end … … 455 474 456 475 MyStruct2 = Struct.new(:a, :b) 476 if RUBY_VERSION < "1.8.0" 477 # Struct#== is not defined in ruby/1.6 478 class MyStruct2 479 def ==(rhs) 480 return true if __id__ == rhs.__id__ 481 return false unless rhs.is_a?(::Struct) 482 return false if self.class != rhs.class 483 members.each do |member| 484 return false if self.__send__(member) != rhs.__send__(member) 485 end 486 return true 487 end 488 end 489 end 457 490 def test_struct_toplevel 458 marshal_equal(MyStruct2.new(1,2)) 491 o = MyStruct2.new(1,2) 492 marshal_equal(o) 459 493 end 460 494 end