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,5 +1,7 @@
|
|||
require 'test/unit'
|
||||
require 'stringio'
|
||||
require 'require_relative'
|
||||
require_relative 'allpairs'
|
||||
|
||||
class TestM17NComb < Test::Unit::TestCase
|
||||
def assert_encoding(encname, actual, message=nil)
|
||||
|
@ -113,20 +115,8 @@ class TestM17NComb < Test::Unit::TestCase
|
|||
#"aaa".force_encoding("utf-32be"),
|
||||
]
|
||||
|
||||
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 encdump(str)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue