String#% with 'g/G/e/E' patterns produces incorrect output different from MRI
-----------------------------------------------------------------------------
Key: JRUBY-1774
URL: http://jira.codehaus.org/browse/JRUBY-1774
Project: JRuby
Issue Type: Bug
Components: Core Classes/Modules
Affects Versions: JRuby 1.x
Environment: Latest JRuby 1.1b1 built from the trunk
Reporter: Vladimir Sizikov
Attachments: string-modulo-e-E-g-G.patch, testString-failed.rb
Consider the following tests (also attached):
{noformat}
require 'test/minirunit'
test_equal("1.000000E+01", "%E" % 10)
test_equal("1.000000e+99", "%e" % 1e99)
test_equal("1.000202E+06", "%E" % 1000202)
test_equal("1.000000E+05", "%E" % 1e5)
test_equal("1.000000E+06", "%E" % 1000000)
test_equal("1.000000e+99", "%e" % 1e99)
test_equal("1.000202E+06", "%E" % 1000202)
test_equal(" 1.00E+03", "%10.2E" % 1001)
test_equal("1.0010E+03", "%10.4E" % 1001)
test_equal(" 1.00E+03","%#10.2E" % 1001)
test_equal("1.00E+03", "%#7.2E" % 1001)
test_equal("1.0E+03", "%#7.1E" % 1001)
test_equal("2.0001E+05", "%.4E" % 200011)
test_equal("2.0001E+05", "%#.4E" % 200011)
test_equal("1.000E+03", "%7.3E" % 1000)
test_equal("1.0000000000E+03", "%-#7.10E" % 1000)
test_equal(" 1.11E+03", "%10.2E" % 1111)
test_equal("1.00E+04", "%#.2E" % 1E4)
test_equal("1.00000E+05", "%#.5E" % 1E5)
test_equal("1.00000E+05 ", "%-#20.5E" % 1E5)
test_equal(" 1.00000E+05", "%#20.5E" % 1E5)
test_equal("00001.01000E+06", "%0#15.5E" % 10.1E5)
test_equal("1E+06", "%G" % 1000000)
test_equal("1e+99", "%g" % 1e99)
test_equal(" 1E+100", "% G" % 1e100)
test_equal("1.0002E+06", "%G" % 1000202)
test_equal(" 1E+03", "%10.2G" % 1001)
test_equal(" 1.0E+03","%#10.2G" % 1001)
test_equal("1.0E+03", "%#7.2G" % 1001)
test_equal(" 1.E+03", "%#7.1G" % 1001)
test_equal("2E+05", "%.4G" % 200011)
test_equal("2.000E+05", "%#.4G" % 200011)
test_equal(" 1E+03", "%7.3G" % 1000)
test_equal("1000.000000", "%-#7.10G" % 1000)
test_equal(" 1.1E+03", "%10.2G" % 1111)
test_equal("1.0E+04", "%#.2G" % 1E4)
test_equal("1.0000E+05", "%#.5G" % 1E5)
test_equal("1.0000E+05 ", "%-#20.5G" % 1E5)
test_equal(" 1.0000E+05", "%#20.5G" % 1E5)
test_equal("000001.0100E+06", "%0#15.5G" % 10.1E5)
{noformat}
*ALL* these tests will fail with JRuby, but will pass with MRI 1.8, 1.9.
(Most of tests will pass on Rubinius as well).
This also leads to a one Rubinius spec failure:
13)
String#% supports float formats using %E FAILED
Expected "1.000000E+001" to equal "1.000000E+01":
./mspec/expectations.rb:10:in `fail_with'
./mspec/matchers/base.rb:8:in `=='
/opt/work/rubinius/./spec/core/string/modulo_spec.rb:322:in `=='
/opt/work/rubinius/./spec/core/string/modulo_spec.rb:321:in `call'
./mspec/runner/runner.rb:136:in `describe'
./mspec/runner/runner.rb:135:in `each'
./mspec/runner/runner.rb:130:in `describe'
./mspec/runner/runner.rb:135:in `describe'
/opt/work/rubinius/./spec/core/string/modulo_spec.rb:4:in `describe'
/opt/work/rubinius/./spec/core/string/modulo_spec.rb:4:in `load'
tmp/last_mspec.rb:15:in `load'
tmp/last_mspec.rb:9:in `each'
tmp/last_mspec.rb:9:in `each'
The proposed patch (with lots of regression tests as well) corrects the problem
and fixes all the mentioned failures.
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://jira.codehaus.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe from this list please visit:
http://xircles.codehaus.org/manage_email