summaryrefslogtreecommitdiffstats
path: root/test/ruby/test_sprintf_comb.rb
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-03-01 04:12:13 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2008-03-01 04:12:13 +0000
commit4c8148385c7fd5638c25b9394ac350bd8389c130 (patch)
tree16c3b20fdeef94d7040d42c49340b08711fda2de /test/ruby/test_sprintf_comb.rb
parent1060968df79dfa1f775a212149afc3ee8d9865c8 (diff)
downloadruby-4c8148385c7fd5638c25b9394ac350bd8389c130.tar.gz
ruby-4c8148385c7fd5638c25b9394ac350bd8389c130.tar.xz
ruby-4c8148385c7fd5638c25b9394ac350bd8389c130.zip
* 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: http://svn.ruby-lang.org/repos/ruby/trunk@15658 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_sprintf_comb.rb')
-rw-r--r--test/ruby/test_sprintf_comb.rb18
1 files changed, 4 insertions, 14 deletions
diff --git a/test/ruby/test_sprintf_comb.rb b/test/ruby/test_sprintf_comb.rb
index 644a1dd0f..3a7b65a7e 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)