diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-10-04 10:30:56 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-10-04 10:30:56 +0000 |
commit | f6f89b880a80c1f47e6fcb6caf46d6ed35da3089 (patch) | |
tree | 66b89b3193821ffe6d545828de5f40b88c1d2bae /test/ruby/test_marshal.rb | |
parent | f517fb54c76e2510b9bc0167ad64a5726bd3926c (diff) | |
download | ruby-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/ruby/test_marshal.rb')
-rw-r--r-- | test/ruby/test_marshal.rb | 41 |
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 |