summaryrefslogtreecommitdiff
path: root/test/soap
diff options
context:
space:
mode:
Diffstat (limited to 'test/soap')
-rw-r--r--test/soap/marshal/test_digraph.rb4
-rw-r--r--test/soap/marshal/test_marshal.rb59
2 files changed, 53 insertions, 10 deletions
diff --git a/test/soap/marshal/test_digraph.rb b/test/soap/marshal/test_digraph.rb
index c83238748a..d7f30654f8 100644
--- a/test/soap/marshal/test_digraph.rb
+++ b/test/soap/marshal/test_digraph.rb
@@ -36,7 +36,9 @@ class TestDigraph < Test::Unit::TestCase
f = File.open("digraph_marshalled_string.soap", "wb")
SOAP::Marshal.dump(@n1, f)
f.close
- str = File.read("digraph_marshalled_string.soap")
+ f = File.open("digraph_marshalled_string.soap")
+ str = f.read
+ f.close
newnode = SOAP::Marshal.unmarshal(str)
assert_equal(newnode.first.first.__id__, newnode.second.first.__id__)
assert_equal(newnode.first.first.first.first.__id__, newnode.second.first.second.first.__id__)
diff --git a/test/soap/marshal/test_marshal.rb b/test/soap/marshal/test_marshal.rb
index 2763fa8bcf..9ae08c68d8 100644
--- a/test/soap/marshal/test_marshal.rb
+++ b/test/soap/marshal/test_marshal.rb
@@ -78,13 +78,18 @@ module MarshalTestLib
}
end
- class MyArray < Array; def initialize(v, *args) super args; @v = v; end end
+ class MyArray < Array
+ def initialize(v, args)
+ super(args)
+ @v = v
+ end
+ end
def test_array
- marshal_equal([1,2,3])
+ marshal_equal(5)
end
def test_array_subclass
- marshal_equal(MyArray.new(0, 1,2,3))
+ marshal_equal(MyArray.new(0, 3))
end
def test_array_ivar
@@ -166,7 +171,8 @@ module MarshalTestLib
end
def test_fixnum
- marshal_equal(-0x4000_0000)
+ #marshal_equal(-0x4000_0000) # not fixnum under 1.6...
+ marshal_equal(-0x3fff_ffff)
marshal_equal(-1)
marshal_equal(0)
marshal_equal(1)
@@ -253,7 +259,7 @@ module MarshalTestLib
end
def test_string_ivar
- o1 = String.new
+ o1 = ""
o1.instance_eval { @iv = 1 }
marshal_equal(o1) {|o| o.instance_eval { @iv }}
end
@@ -281,12 +287,31 @@ module MarshalTestLib
end
MyStruct = Struct.new("MyStruct", :a, :b)
+ if RUBY_VERSION < "1.8.0"
+ # Struct#== is not defined in ruby/1.6
+ class MyStruct
+ def ==(rhs)
+ return true if __id__ == rhs.__id__
+ return false unless rhs.is_a?(::Struct)
+ return false if self.class != rhs.class
+ members.each do |member|
+ return false if self.__send__(member) != rhs.__send__(member)
+ end
+ return true
+ end
+ end
+ end
class MySubStruct < MyStruct; def initialize(v, *args) super(*args); @v = v; end end
def test_struct
marshal_equal(MyStruct.new(1,2))
end
def test_struct_subclass
+ if RUBY_VERSION < "1.8.0"
+ # Substruct instance cannot be dumped in ruby/1.6
+ # ::Marshal.dump(MySubStruct.new(10, 1, 2)) #=> uninitialized struct
+ return false
+ end
marshal_equal(MySubStruct.new(10,1,2))
end
@@ -379,6 +404,7 @@ module MarshalTestLib
def <=>(other); true; end
end
def test_range_cyclic
+ return unless CyclicRange.respond_to?(:allocate) # test for 1.8
o1 = CyclicRange.allocate
o1.instance_eval { initialize(o1, o1) }
o2 = marshaltest(o1)
@@ -413,14 +439,14 @@ module MarshalTestLib
end
def test_extend_string
- o = String.new
+ o = ""
o.extend Mod1
marshal_equal(o) { |obj| obj.kind_of? Mod1 }
- o = String.new
+ o = ""
o.extend Mod1
o.extend Mod2
marshal_equal(o) {|obj| class << obj; ancestors end}
- o = String.new
+ o = ""
o.extend Module.new
assert_raises(TypeError) { marshaltest(o) }
end
@@ -447,8 +473,23 @@ module MarshalTestLib
end
MyStruct2 = Struct.new(:a, :b)
+ if RUBY_VERSION < "1.8.0"
+ # Struct#== is not defined in ruby/1.6
+ class MyStruct2
+ def ==(rhs)
+ return true if __id__ == rhs.__id__
+ return false unless rhs.is_a?(::Struct)
+ return false if self.class != rhs.class
+ members.each do |member|
+ return false if self.__send__(member) != rhs.__send__(member)
+ end
+ return true
+ end
+ end
+ end
def test_struct_toplevel
- marshal_equal(MyStruct2.new(1,2))
+ o = MyStruct2.new(1,2)
+ marshal_equal(o)
end
end