mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* test/scanf/test_scanf.rb (ScanfTests#each_test): yield in order.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@27786 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
30f637024b
commit
fa086089fb
1 changed files with 10 additions and 7 deletions
|
@ -287,18 +287,23 @@ module ScanfTests
|
|||
|
||||
]
|
||||
end
|
||||
|
||||
def each_test
|
||||
i = "0" * (Math.log(self.tests.size, 10).floor+1)
|
||||
self.tests.each do |test|
|
||||
yield test, i.succ!
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class TestStringScanf
|
||||
include Scanf
|
||||
extend ScanfTests
|
||||
|
||||
i = 1
|
||||
self.tests.each do |test|
|
||||
self.each_test do |test, i|
|
||||
define_method("test_#{i}") do ||
|
||||
assert_equal(test[2], test[1].scanf(test[0]))
|
||||
end
|
||||
i += 1
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -308,8 +313,7 @@ class TestIOScanf
|
|||
|
||||
tmpfilename = "#{Dir.tmpdir}/iotest.dat.#{$$}"
|
||||
|
||||
i = 1
|
||||
self.tests.each do |test|
|
||||
self.each_test do |test, i|
|
||||
define_method("test_#{i}") do ||
|
||||
File.open(tmpfilename, "w") {|fh| fh.print test[1]}
|
||||
File.open(tmpfilename, "r") { |fh|
|
||||
|
@ -317,6 +321,5 @@ class TestIOScanf
|
|||
}
|
||||
File.delete(tmpfilename)
|
||||
end
|
||||
i += 1
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue