From 00bf4e8a84c59f051b87c1a613fe8544b86c5aa6 Mon Sep 17 00:00:00 2001 From: akr Date: Sat, 1 Mar 2008 04:12:13 +0000 Subject: * test/ruby/allpairs.rb: new file for all pairs method. * test/ruby/test_m17n_comb.rb: use allpairs.rb to reduce test cases. * test/ruby/test_sprintf_comb.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@15658 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_sprintf_comb.rb | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) (limited to 'test/ruby/test_sprintf_comb.rb') diff --git a/test/ruby/test_sprintf_comb.rb b/test/ruby/test_sprintf_comb.rb index 644a1dd0f4..3a7b65a7e3 100644 --- a/test/ruby/test_sprintf_comb.rb +++ b/test/ruby/test_sprintf_comb.rb @@ -1,4 +1,6 @@ require 'test/unit' +require 'require_relative' +require_relative 'allpairs' class TestSprintfComb < Test::Unit::TestCase VS = [ @@ -106,20 +108,8 @@ class TestSprintfComb < Test::Unit::TestCase ] VS.reverse! - def combination(*args) - args = args.map {|a| a.to_a } - i = 0 - while true - n = i - as = [] - args.reverse_each {|a| - n, m = n.divmod(a.length) - as.unshift a[m] - } - break if 0 < n - yield as - i += 1 - end + def combination(*args, &b) + AllPairs.each(*args, &b) end def emu(format, v) -- cgit v1.2.3