mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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
This commit is contained in:
parent
fe7d645eed
commit
00bf4e8a84
4 changed files with 119 additions and 28 deletions
|
@ -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)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue