ruby-changes:5348
From: mame <ko1@a...>
Date: Thu, 5 Jun 2008 23:57:34 +0900 (JST)
Subject: [ruby-changes:5348] Ruby:r16849 (trunk): * test/ruby/test_gc.rb: add tests to achieve over 90% test coverage of
mame 2008-06-05 23:57:05 +0900 (Thu, 05 Jun 2008)
New Revision: 16849
Modified files:
trunk/ChangeLog
trunk/test/ruby/test_gc.rb
trunk/test/ruby/test_marshal.rb
trunk/test/ruby/test_objectspace.rb
Log:
* test/ruby/test_gc.rb: add tests to achieve over 90% test coverage of
gc.c.
* test/ruby/test_objectspace.rb: ditto.
* test/ruby/test_marshal.rb: ditto.
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/ChangeLog?r1=16849&r2=16848&diff_format=u
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/test/ruby/test_marshal.rb?r1=16849&r2=16848&diff_format=u
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/test/ruby/test_gc.rb?r1=16849&r2=16848&diff_format=u
http://svn.ruby-lang.org/cgi-bin/viewvc.cgi/trunk/test/ruby/test_objectspace.rb?r1=16849&r2=16848&diff_format=u
Index: ChangeLog
===================================================================
--- ChangeLog (revision 16848)
+++ ChangeLog (revision 16849)
@@ -1,3 +1,12 @@
+Thu Jun 5 23:56:18 2008 Yusuke Endoh <mame@t...>
+
+ * test/ruby/test_gc.rb: add tests to achieve over 90% test coverage of
+ gc.c.
+
+ * test/ruby/test_objectspace.rb: ditto.
+
+ * test/ruby/test_marshal.rb: ditto.
+
Thu Jun 5 23:40:08 2008 Yusuke Endoh <mame@t...>
* gc.c (rb_objspace_alloc): this function is needed only when
Index: test/ruby/test_objectspace.rb
===================================================================
--- test/ruby/test_objectspace.rb (revision 16848)
+++ test/ruby/test_objectspace.rb (revision 16849)
@@ -1,4 +1,5 @@
require 'test/unit'
+require_relative 'envutil'
class TestObjectSpace < Test::Unit::TestCase
def self.deftest_id2ref(obj)
@@ -53,4 +54,18 @@
assert_same(h0, h)
assert_equal(0, h0[:T_FOO])
end
+
+ def test_finalizer
+ EnvUtil.rubyexec("-e", <<-END) do |w, r, e|
+ a = []
+ ObjectSpace.define_finalizer(a) { p :ok }
+ b = a.dup
+ ObjectSpace.define_finalizer(a) { p :ok }
+ END
+ assert_equal("", e.read)
+ assert_equal(":ok\n:ok\n:ok\n:ok\n", r.read)
+
+ assert_raise(ArgumentError) { ObjectSpace.define_finalizer([], Object.new) }
+ end
+ end
end
Index: test/ruby/test_marshal.rb
===================================================================
--- test/ruby/test_marshal.rb (revision 16848)
+++ test/ruby/test_marshal.rb (revision 16849)
@@ -152,4 +152,20 @@
eval("C3 = Struct.new(:foo, :baz)")
assert_raise(TypeError) { Marshal.load(m) }
end
+
+ class C4
+ def initialize(gc)
+ @gc = gc
+ end
+ def _dump(s)
+ GC.start if @gc
+ "foo"
+ end
+ end
+
+ def test_gc
+ assert_nothing_raised do
+ Marshal.dump((0..1000).map {|x| C4.new(x % 50 == 25) })
+ end
+ end
end
Index: test/ruby/test_gc.rb
===================================================================
--- test/ruby/test_gc.rb (revision 16848)
+++ test/ruby/test_gc.rb (revision 16849)
@@ -32,4 +32,23 @@
GC.stress = prev_stress
end
+
+ def test_enable_disable
+ GC.enable
+ assert_equal(false, GC.enable)
+ assert_equal(false, GC.disable)
+ assert_equal(true, GC.disable)
+ assert_equal(true, GC.disable)
+ assert_nil(GC.start)
+ assert_equal(true, GC.enable)
+ assert_equal(false, GC.enable)
+ ensure
+ GC.enable
+ end
+
+ def test_count
+ c = GC.count
+ GC.start
+ assert_operator(c, :<, GC.count)
+ end
end
--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/