summaryrefslogtreecommitdiffstats
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
commitdc4fbc46861900429d621ae7b00b76593df88719 (patch)
tree66b89b3193821ffe6d545828de5f40b88c1d2bae /test
parent6a4674205b9065c04b6be13280c66ebe11d51876 (diff)
downloadruby-dc4fbc46861900429d621ae7b00b76593df88719.tar.gz
ruby-dc4fbc46861900429d621ae7b00b76593df88719.tar.xz
ruby-dc4fbc46861900429d621ae7b00b76593df88719.zip
* 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: http://svn.ruby-lang.org/repos/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 a69770663..676953930 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