ruby-changes:30829
From: nobu <ko1@a...>
Date: Wed, 11 Sep 2013 12:00:51 +0900 (JST)
Subject: [ruby-changes:30829] nobu:r42908 (trunk): test_sprintf_comb.rb: split tests
nobu 2013-09-11 12:00:42 +0900 (Wed, 11 Sep 2013) New Revision: 42908 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=42908 Log: test_sprintf_comb.rb: split tests * test/ruby/test_sprintf_comb.rb (test_format_integer), (test_format_float): split huge tests by the formats. Modified files: trunk/test/ruby/test_sprintf_comb.rb Index: test/ruby/test_sprintf_comb.rb =================================================================== --- test/ruby/test_sprintf_comb.rb (revision 42907) +++ test/ruby/test_sprintf_comb.rb (revision 42908) @@ -107,7 +107,9 @@ class TestSprintfComb < Test::Unit::Test https://github.com/ruby/ruby/blob/trunk/test/ruby/test_sprintf_comb.rb#L107 ] VS.reverse! - def combination(*args, &b) + FLAGS = [['', ' '], ['', '#'], ['', '+'], ['', '-'], ['', '0']] + + def self.combination(*args, &b) #AllPairs.exhaustive_each(*args, &b) AllPairs.each(*args, &b) end @@ -268,17 +270,8 @@ class TestSprintfComb < Test::Unit::Test https://github.com/ruby/ruby/blob/trunk/test/ruby/test_sprintf_comb.rb#L270 str end - def test_format_integer - combination( - %w[B b d o X x], - [nil, 0, 5, 20], - ["", ".", ".0", ".8", ".20"], - ['', ' '], - ['', '#'], - ['', '+'], - ['', '-'], - ['', '0']) {|type, width, precision, sp, hs, pl, mi, zr| - format = "%#{sp}#{hs}#{pl}#{mi}#{zr}#{width}#{precision}#{type}" + def self.assertions_format_integer(format) + proc { VS.each {|v| r = sprintf format, v e = emu_int format, v @@ -293,6 +286,14 @@ class TestSprintfComb < Test::Unit::Test https://github.com/ruby/ruby/blob/trunk/test/ruby/test_sprintf_comb.rb#L286 } end + combination(%w[B b d o X x], + [nil, 0, 5, 20], + ["", ".", ".0", ".8", ".20"], + *FLAGS) {|type, width, precision, sp, hs, pl, mi, zr| + format = "%#{sp}#{hs}#{pl}#{mi}#{zr}#{width}#{precision}#{type}" + define_method("test_format_integer(#{format})", assertions_format_integer(format)) + } + FLOAT_VALUES = [ -1e100, -123456789.0, @@ -526,17 +527,8 @@ class TestSprintfComb < Test::Unit::Test https://github.com/ruby/ruby/blob/trunk/test/ruby/test_sprintf_comb.rb#L527 end - def test_format_float - combination( - %w[e E f g G], - [nil, 0, 5, 20], - ["", ".", ".0", ".8", ".20", ".200"], - ['', ' '], - ['', '#'], - ['', '+'], - ['', '-'], - ['', '0']) {|type, width, precision, sp, hs, pl, mi, zr| - format = "%#{sp}#{hs}#{pl}#{mi}#{zr}#{width}#{precision}#{type}" + def self.assertions_format_float(format) + proc { FLOAT_VALUES.each {|v| r = sprintf format, v e = emu_float format, v @@ -550,4 +542,12 @@ class TestSprintfComb < Test::Unit::Test https://github.com/ruby/ruby/blob/trunk/test/ruby/test_sprintf_comb.rb#L542 } } end + + combination(%w[e E f g G], + [nil, 0, 5, 20], + ["", ".", ".0", ".8", ".20", ".200"], + *FLAGS) {|type, width, precision, sp, hs, pl, mi, zr| + format = "%#{sp}#{hs}#{pl}#{mi}#{zr}#{width}#{precision}#{type}" + define_method("test_format_float(#{format})", assertions_format_float(format)) + } end -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/