ruby-changes:14533
From: mame <ko1@a...>
Date: Fri, 22 Jan 2010 01:08:59 +0900 (JST)
Subject: [ruby-changes:14533] Ruby:r26370 (trunk): * test/ruby/test_bignum.rb, test/ruby/test_class.rb,
mame 2010-01-22 01:08:40 +0900 (Fri, 22 Jan 2010) New Revision: 26370 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=26370 Log: * test/ruby/test_bignum.rb, test/ruby/test_class.rb, test/ruby/test_defined.rb, test/ruby/test_hash.rb, test/ruby/test_primitive.rb, test/ruby/test_variable.rb: add some tests (for coverage). Modified files: trunk/ChangeLog trunk/test/ruby/test_bignum.rb trunk/test/ruby/test_class.rb trunk/test/ruby/test_defined.rb trunk/test/ruby/test_hash.rb trunk/test/ruby/test_primitive.rb trunk/test/ruby/test_variable.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 26369) +++ ChangeLog (revision 26370) @@ -1,3 +1,10 @@ +Fri Jan 22 01:07:16 2010 Yusuke Endoh <mame@t...> + + * test/ruby/test_bignum.rb, test/ruby/test_class.rb, + test/ruby/test_defined.rb, test/ruby/test_hash.rb, + test/ruby/test_primitive.rb, test/ruby/test_variable.rb: add some + tests (for coverage). + Fri Jan 22 01:03:28 2010 Yusuke Endoh <mame@t...> * test/ruby/test_require.rb (test_define_class): expect TypeError Index: test/ruby/test_bignum.rb =================================================================== --- test/ruby/test_bignum.rb (revision 26369) +++ test/ruby/test_bignum.rb (revision 26370) @@ -420,6 +420,7 @@ b = 1E+300.to_i assert_equal(b, (b ** 2).fdiv(b)) assert(@big.fdiv(0.0 / 0.0).nan?) + assert_in_delta(1E+300, (10**500).fdiv(1E+200), 1E+285) end def test_obj_fdiv Index: test/ruby/test_variable.rb =================================================================== --- test/ruby/test_variable.rb (revision 26369) +++ test/ruby/test_variable.rb (revision 26370) @@ -81,4 +81,8 @@ def test_global_variable_0 assert_in_out_err(["-e", "$0='t'*1000;print $0"], "", /\At+\z/, []) end + + def test_global_variable_poped + assert_nothing_raised { eval("$foo; 1") } + end end Index: test/ruby/test_defined.rb =================================================================== --- test/ruby/test_defined.rb (revision 26369) +++ test/ruby/test_defined.rb (revision 26370) @@ -12,6 +12,10 @@ end def baz(f) end + attr_accessor :attr + def attrasgn_test + yield(defined?(self.attr = 1)) + end end def defined_test @@ -32,6 +36,7 @@ assert(defined?(::Array)) # toplevel constant assert(defined?(File::Constants)) # nested constant assert(defined?(Object.new)) # method + assert(defined?(Object::new)) # method assert(!defined?(Object.print)) # private method assert(defined?(1 == 2)) # operator expression @@ -45,6 +50,8 @@ assert_nil(defined?(f.quux(x))) assert(defined?(print(x))) assert_nil(defined?(quux(x))) + assert(defined?(f.attr = 1)) + f.attrasgn_test { |v| assert(v) } assert(defined_test) # not iterator assert(!defined_test{}) # called as iterator Index: test/ruby/test_primitive.rb =================================================================== --- test/ruby/test_primitive.rb (revision 26369) +++ test/ruby/test_primitive.rb (revision 26370) @@ -228,6 +228,12 @@ assert_equal 7, a[0] a[0] ||= 3 assert_equal 7, a[0] + + a = [0, 1, nil, 3, 4] + a[*[2]] ||= :foo + assert_equal [0, 1, :foo, 3, 4], a + a[*[1,3]] &&= [:bar] + assert_equal [0, :bar, 4], a end def test_opassign_and_or Index: test/ruby/test_hash.rb =================================================================== --- test/ruby/test_hash.rb (revision 26369) +++ test/ruby/test_hash.rb (revision 26370) @@ -871,4 +871,8 @@ def o.hash; 2<<100; end assert_equal({x=>1}.hash, {x=>1}.hash) end + + def test_hash_poped + assert_nothing_raised { eval("a = 1; {a => a}; a") } + end end Index: test/ruby/test_class.rb =================================================================== --- test/ruby/test_class.rb (revision 26369) +++ test/ruby/test_class.rb (revision 26370) @@ -209,4 +209,13 @@ c = eval("class C\u{df}; self; end") assert_equal("TestClass::C\u{df}", c.name, '[ruby-core:24600]') end + + def test_invalid_jump_from_class_definition + assert_raise(SyntaxError) { eval("class C; next; end") } + assert_raise(SyntaxError) { eval("class C; break; end") } + assert_raise(SyntaxError) { eval("class C; redo; end") } + assert_raise(SyntaxError) { eval("class C; retry; end") } + assert_raise(SyntaxError) { eval("class C; return; end") } + assert_raise(SyntaxError) { eval("class C; yield; end") } + end end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/