Welcome to the "trac"-ing site of soap4r!
[soap4r] [httpclient] [openpgp4u] [pkcs1] [logger] [csv] [vtr]

Changeset 1030

Show
Ignore:
Timestamp:
11/02/03 20:53:35 (5 years ago)
Author:
nahi
Message:

better 1.6 support.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/test/soap/marshal/test_marshal.rb

    r1027 r1030  
    288288 
    289289  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 
    290304  class MySubStruct < MyStruct; def initialize(v, *args) super(*args); @v = v; end end 
    291305  def test_struct 
     
    294308 
    295309  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 
    296315    marshal_equal(MySubStruct.new(10,1,2)) 
    297316  end 
     
    455474 
    456475  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 
    457490  def test_struct_toplevel 
    458     marshal_equal(MyStruct2.new(1,2)) 
     491    o = MyStruct2.new(1,2) 
     492    marshal_equal(o) 
    459493  end 
    460494end