aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-10-04 10:30:56 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-10-04 10:30:56 +0000
commitf6f89b880a80c1f47e6fcb6caf46d6ed35da3089 (patch)
tree66b89b3193821ffe6d545828de5f40b88c1d2bae /test
parentf517fb54c76e2510b9bc0167ad64a5726bd3926c (diff)
downloadruby-f6f89b880a80c1f47e6fcb6caf46d6ed35da3089.tar.gz
* marshal.c (struct {dump,load}_arg): manage with dfree, instead
of using local variable which may be moved by context switch. [ruby-dev:39425] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@25230 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_marshal.rb41
1 files changed, 41 insertions, 0 deletions
diff --git a/test/ruby/test_marshal.rb b/test/ruby/test_marshal.rb
index a697706632..6769539303 100644
--- a/test/ruby/test_marshal.rb
+++ b/test/ruby/test_marshal.rb
@@ -212,4 +212,45 @@ class TestMarshal < Test::Unit::TestCase
c = [/#{a}/, /#{b}/]
assert_equal(c, Marshal.load(Marshal.dump(c)))
end
+
+ class DumpTest
+ def marshal_dump
+ @@block.call(:marshal_dump)
+ end
+
+ def dump_each(&block)
+ @@block = block
+ Marshal.dump(self)
+ end
+ end
+
+ class LoadTest
+ def marshal_dump
+ nil
+ end
+ def marshal_load(obj)
+ @@block.call(:marshal_load)
+ end
+ def self.load_each(m, &block)
+ @@block = block
+ Marshal.load(m)
+ end
+ end
+
+ def test_context_switch
+ o = DumpTest.new
+ e = o.enum_for(:dump_each)
+ assert_equal(:marshal_dump, e.next)
+ GC.start
+ assert(true, '[ruby-dev:39425]')
+ assert_raise(StopIteration) {e.next}
+
+ o = LoadTest.new
+ m = Marshal.dump(o)
+ e = LoadTest.enum_for(:load_each, m)
+ assert_equal(:marshal_load, e.next)
+ GC.start
+ assert(true, '[ruby-dev:39425]')
+ assert_raise(StopIteration) {e.next}
+ end
end