ruby-changes:14514
From: mame <ko1@a...>
Date: Tue, 19 Jan 2010 02:05:17 +0900 (JST)
Subject: [ruby-changes:14514] Ruby:r26351 (trunk): * test/ruby/test_array.rb: add some tests (for coverage).
mame 2010-01-19 02:03:16 +0900 (Tue, 19 Jan 2010) New Revision: 26351 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=26351 Log: * test/ruby/test_array.rb: add some tests (for coverage). * test/ruby/test_bignum.rb: ditto. Modified files: trunk/ChangeLog trunk/test/ruby/test_array.rb trunk/test/ruby/test_bignum.rb Index: ChangeLog =================================================================== --- ChangeLog (revision 26350) +++ ChangeLog (revision 26351) @@ -1,3 +1,9 @@ +Tue Jan 19 02:02:32 2010 Yusuke Endoh <mame@t...> + + * test/ruby/test_array.rb: add some tests (for coverage). + + * test/ruby/test_bignum.rb: ditto. + Tue Jan 19 01:57:12 2010 Yusuke Endoh <mame@t...> * test/ruby/test_bignum.rb: some coerce definitions (for test) was Index: test/ruby/test_array.rb =================================================================== --- test/ruby/test_array.rb (revision 26350) +++ test/ruby/test_array.rb (revision 26351) @@ -760,6 +760,40 @@ assert_match(/reentered/, e.message, '[ruby-dev:34798]') end + def test_permutation_with_callcc + respond_to?(:callcc, true) or require 'continuation' + n = 1000 + cont = nil + ary = [1,2,3] + begin + ary.permutation { + callcc {|k| cont = k} unless cont + } + rescue => e + end + n -= 1 + cont.call if 0 < n + assert_instance_of(RuntimeError, e) + assert_match(/reentered/, e.message) + end + + def test_combination_with_callcc + respond_to?(:callcc, true) or require 'continuation' + n = 1000 + cont = nil + ary = [1,2,3] + begin + ary.combination(2) { + callcc {|k| cont = k} unless cont + } + rescue => e + end + n -= 1 + cont.call if 0 < n + assert_instance_of(RuntimeError, e) + assert_match(/reentered/, e.message) + end + def test_hash a1 = @cls[ 'cat', 'dog' ] a2 = @cls[ 'cat', 'dog' ] @@ -1140,6 +1174,9 @@ a = @cls[1, 2, 3, 4, 5] assert_equal(nil, a.slice!(-6,2)) assert_equal(@cls[1, 2, 3, 4, 5], a) + + assert_raise(ArgumentError) { @cls[1].slice! } + assert_raise(ArgumentError) { @cls[1].slice!(0, 0, 0) } end def test_sort @@ -1150,6 +1187,8 @@ assert_equal(@cls[4, 3, 2, 1], a.sort { |x, y| y <=> x} ) assert_equal(@cls[4, 1, 2, 3], a) + assert_equal(@cls[1, 2, 3, 4], a.sort { |x, y| (x - y) * (2**100) }) + a.fill(1) assert_equal(@cls[1, 1, 1, 1], a.sort) @@ -1417,6 +1456,7 @@ assert_raise(IndexError) { [0][-2] = 1 } assert_raise(IndexError) { [0][LONGP] = 2 } assert_raise(IndexError) { [0][(LONGP + 1) / 2 - 1] = 2 } + assert_raise(IndexError) { [0][LONGP..-1] = 2 } a = [0] a[2] = 4 assert_equal([0, nil, 4], a) Index: test/ruby/test_bignum.rb =================================================================== --- test/ruby/test_bignum.rb (revision 26350) +++ test/ruby/test_bignum.rb (revision 26351) @@ -175,6 +175,8 @@ def test_to_f assert_nothing_raised { T31P.to_f.to_i } assert_raise(FloatDomainError) { (1024**1024).to_f.to_i } + assert_equal(1, (2**50000).to_f.infinite?) + assert_equal(-1, (-(2**50000)).to_f.infinite?) end def test_cmp @@ -414,4 +416,15 @@ assert_in_delta(1.0, @fmax2.fdiv(@fmax2), 0.01) end + def test_float_fdiv + b = 1E+300.to_i + assert_equal(b, (b ** 2).fdiv(b)) + assert(@big.fdiv(0.0 / 0.0).nan?) + end + + def test_obj_fdiv + o = Object.new + def o.coerce(x); [x, 2**100]; end + assert_equal((2**200).to_f, (2**300).fdiv(o)) + end end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/