Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re^6: Avoiding perl's Atof when assigning floating point values

by aitap (Curate)
on Jul 29, 2018 at 12:19 UTC ( [id://1219428]=note: print w/replies, xml ) Need Help??


in reply to Re^5: Avoiding perl's Atof when assigning floating point values
in thread Avoiding perl's Atof when assigning floating point values

I've managed to reproduce the lib/locale.t failure on my Ubuntu-16.04 box by switching locale to LANG=de_DE.UTF-8.
I wonder if it's possible to force a particular LC_NUMERIC which has decimal_point   "<U002C>" in /usr/share/i18n/locales/$locale for the lib/locale.t test set, while keeping it C for other categories as a way of verifying the cause of the failures.

make distclean sh Configure -des -Dusedevel -Duse64bitall -Ud_strtod && make && make +test
lib/locale.t passes, but other tests don't:
Failed 2 tests out of 2458, 99.92% okay. ../ext/POSIX/t/posix.t run/locale.t
But that's not too mysterious:
aitap@scratch:~/blead_patched/t$ ./perl harness ../ext/POSIX/t/posix.t ../ext/POSIX/t/posix.t .. 11/93 POSIX::strtod not implemented on this +architecture at t/posix.t line 184. # Looks like your test exited with 255 just after 16. ../ext/POSIX/t/posix.t .. Dubious, test returned 255 (wstat 65280, 0xf +f00) Failed 77/93 subtests (less 2 skipped subtests: 14 okay) Test Summary Report ------------------- ../ext/POSIX/t/posix.t (Wstat: 65280 Tests: 16 Failed: 0) Non-zero exit status: 255 Parse errors: Bad plan. You planned 93 tests but ran 16. Files=1, Tests=16, 3 wallclock secs ( 0.01 usr 0.00 sys + 0.06 cusr + 0.00 csys = 0.07 CPU) Result: FAIL aitap@scratch:~/blead_patched/t$ ./perl -I../lib ../utils/prove -I../l +ib -v run/locale.t Label not found for "last SKIP" at ./test.pl line 522. run/locale.t .. ok 1 - /il matching of [bracketed] doesn't skip POSIX class if fails i +ndivid char ok 2 - /l matching of [bracketed] doesn't skip non-first POSIX class ok 3 - retrieving current non-C LC_NUMERIC doesn't give 'C' ok 4 - retrieving current non-C LC_ALL doesn't give 'C' ok 5 - no locales where LC_NUMERIC breaks ok 6 - LC_NUMERIC without environment nor setlocale() has no effect in + any locale ok 7 # skip no UTF-8 locale available where LC_NUMERIC radix isn't ASC +II # using the 'ru_RU.utf8' locale for LC_NUMERIC tests ok 8 - format() does not look at LC_NUMERIC without 'use locale' ok 9 - format() looks at LC_NUMERIC with 'use locale' ok 10 - localeconv() looks at LC_NUMERIC with and without 'use locale' ok 11 - format() does not look at LC_NUMERIC with 'use locale qw(:coll +ate :characters :collate :ctype :monetary :time)' ok 12 - format() looks at LC_NUMERIC with 'use locale' ok 13 - format() looks at LC_NUMERIC with 'use locale ":!collate"' ok 14 - format() looks at LC_NUMERIC with 'use locale ":not_collate"' ok 15 - format() looks at LC_NUMERIC with 'use locale ":!characters"' ok 16 - format() looks at LC_NUMERIC with 'use locale ":not_characters +"' ok 17 - format() looks at LC_NUMERIC with 'use locale ":!collate"' ok 18 - format() looks at LC_NUMERIC with 'use locale ":not_collate"' ok 19 - format() looks at LC_NUMERIC with 'use locale ":!ctype"' ok 20 - format() looks at LC_NUMERIC with 'use locale ":not_ctype"' ok 21 - format() looks at LC_NUMERIC with 'use locale ":!monetary"' ok 22 - format() looks at LC_NUMERIC with 'use locale ":not_monetary"' ok 23 - format() looks at LC_NUMERIC with 'use locale ":!time"' ok 24 - format() looks at LC_NUMERIC with 'use locale ":not_time"' ok 25 - format() looks at LC_NUMERIC with 'use locale ":numeric"' ok 26 - too late to look at the locale at write() time ok 27 - too late to ignore the locale at write() time ok 28 - version does not clobber version ok 29 - version does not clobber version (via eval) ok 30 - sprintf() and printf() look at LC_NUMERIC regardless of consta +nt folding ok 31 - Uses the above test to verify that on Windows the system defau +lt locale has lower priority than LC_NUMERIC ok 32 - LANG is used if LC_ALL, LC_NUMERIC are invalid ok 33 - C locale is used if LC_ALL, LC_NUMERIC, LANG are invalid ok 34 - No compile error on v-strings when setting the locale to non-d +ot radix at compile time when default environment has non-dot radix ok 35 - Radix print properly in locale scope, and without ok 36 - Can do math when radix is a comma ok 37 # skip no strtod() Dubious, test returned 255 (wstat 65280, 0xff00) All 37 subtests passed (less 2 skipped subtests: 35 okay) Test Summary Report ------------------- run/locale.t (Wstat: 65280 Tests: 37 Failed: 0) Non-zero exit status: 255 Parse errors: No plan found in TAP output Files=1, Tests=37, 1 wallclock secs ( 0.02 usr 0.00 sys + 0.36 cusr + 0.04 csys = 0.42 CPU) Result: FAIL
In particular, with those patches:
--- - 2018-07-29 12:13:19.135366517 +0000 +++ blead_patched/t/run/locale.t 2018-07-29 12:11:11.460779426 ++0000 @@ -438,6 +438,7 @@ EOF "1,5\n2,5", { stderr => 'devnull' }, "Can do math whe +n radix is a comma"); # [perl 115800] + SKIP: { unless ($have_strtod) { skip("no strtod()", 1); } @@ -451,6 +452,7 @@ EOF "1.5", { stderr => 'devnull' }, "POSIX::strtod() uses + underlying locale"); } + } } } --- - 2018-07-29 12:15:30.325048593 +0000 +++ blead_patched/ext/POSIX/t/posix.t 2018-07-29 12:14:55.656784754 ++0000 @@ -174,6 +174,7 @@ SKIP: { skip("strtold() not present", 2) unless $Config{d_strtold}; + skip("strtod() not present", 2) unless $Config{d_strtod}; if (locales_enabled('LC_NUMERIC')) { $lc = &POSIX::setlocale(&POSIX::LC_NUMERIC);
all tests pass.

Replies are listed 'Best First'.
Re^7: Avoiding perl's Atof when assigning floating point values
by syphilis (Archbishop) on Jul 29, 2018 at 13:38 UTC
    Failed 2 tests out of 2458, 99.92% okay. ../ext/POSIX/t/posix.t run/locale.t

    Yes, the first thing I tried when I discovered I could reproduce the failures was to test a build configured with -Ud_strtod.
    I got the same results as you.

    I apologise for not having tried a bit harder to reproduce the lib/locale.t failure.
    I assumed that Carlos' smoker would be using the same locale setting for all of the systems that it tested. That is, I assumed that the reason that some systems passed and others didn't was because of some difference in the systems.
    But, of course, it was the difference in the locale settings. It was a bad assumption on my part. (They always are.)

    As I mentioned in my last post, I'm confident that the correct fix is to modify lib/locale.t and that's the solution I'll be pushing when I get things organized.
    Here's the patch:
    --- git/bleadperl/lib/locale.t 2018-07-15 10:33:46 +1000 +++ locale.t 2018-07-29 22:21:25 +1000 @@ -2167,8 +2167,8 @@ my $first_c_test = $locales_test_number; $test_names{++$locales_test_number} = 'Verify that a different lo +cale radix works when doing "==" with a constant'; - if ($Config{usequadmath}) { - print "# Skip: no locale radix with usequadmath ($test_names{ +$locales_test_number})\n"; + if ($Config{usequadmath} || ($Config{uselongdouble} && $Config{d_ +strtold}) || (!$Config{uselongdouble} && $Config{d_strtod})) { + print "# Skip: no locale radix with Perl_strtod ($test_names{ +$locales_test_number})\n"; report_result($Locale, $locales_test_number, 1); } else { report_result($Locale, $locales_test_number, $ok3); @@ -2176,8 +2176,8 @@ } $test_names{++$locales_test_number} = 'Verify that a different lo +cale radix works when doing "==" with a scalar'; - if ($Config{usequadmath}) { - print "# Skip: no locale radix with usequadmath ($test_names{ +$locales_test_number})\n"; + if ($Config{usequadmath} || ($Config{uselongdouble} && $Config{d_ +strtold}) || (!$Config{uselongdouble} && $Config{d_strtod})) { + print "# Skip: no locale radix with Perl_strtod ($test_names{ +$locales_test_number})\n"; report_result($Locale, $locales_test_number, 1); } else { report_result($Locale, $locales_test_number, $ok4); @@ -2198,8 +2198,8 @@ $test_names{$locales_test_number} = 'Verify that "==" with a scal +ar still works in inner no locale'; $test_names{++$locales_test_number} = 'Verify that "==" with a sc +alar and an intervening sprintf still works in inner no locale'; - if ($Config{usequadmath}) { - print "# Skip: no locale radix with usequadmath ($test_names{ +$locales_test_number})\n"; + if ($Config{usequadmath} || ($Config{uselongdouble} && $Config{d_ +strtold}) || (!$Config{uselongdouble} && $Config{d_strtod})) { + print "# Skip: no locale radix with Perl_strtod ($test_names{ +$locales_test_number})\n"; report_result($Locale, $locales_test_number, 1); } else { report_result($Locale, $locales_test_number, $ok8); @@ -2218,8 +2218,8 @@ $problematical_tests{$locales_test_number} = 1; $test_names{++$locales_test_number} = 'Verify that after a no-loc +ale block, a different locale radix still works when doing "==" with +a scalar and an intervening sprintf'; - if ($Config{usequadmath}) { - print "# Skip: no locale radix with usequadmath ($test_names{ +$locales_test_number})\n"; + if ($Config{usequadmath} || ($Config{uselongdouble} && $Config{d_ +strtold}) || (!$Config{uselongdouble} && $Config{d_strtod})) { + print "# Skip: no locale radix with Perl_strtod ($test_names{ +$locales_test_number})\n"; report_result($Locale, $locales_test_number, 1); } else { report_result($Locale, $locales_test_number, $ok11); @@ -2465,8 +2465,8 @@ } } - if ($Config{usequadmath}) { - print "# Skip: no locale radix with usequadmath ($Locale) +\n"; + if ($Config{usequadmath} || ($Config{uselongdouble} && $Confi +g{d_strtold}) || (!$Config{uselongdouble} && $Config{d_strtod})) { + print "# Skip: no locale radix with Perl_strtod ($Locale) +\n"; report_result($Locale, $locales_test_number, 1); } else { report_result($Locale, $locales_test_number, @f == 0);
    (Safest to avoid line wrapping by electing to "download")

    If you apply that patch to the lib/locale.t that shipped with blead_patched.tar.gz then all tests should (hopefully) pass.

    Thanks again for the help you've provided. I much appreciate it.

    Cheers,
    Rob
Re^7: Avoiding perl's Atof when assigning floating point values
by syphilis (Archbishop) on Jul 29, 2018 at 23:59 UTC
    UPDATE: Patches for t/run/locale.t and ext/POSIX/t/posix.t have been submitted to perlbug - see https://rt.perl.org/Ticket/Display.html?id=133417
    UPDATE 2: Those patches to t/run/locale.t and ext/POSIX/t/posix.t have now been applied to bleadperl.

    Oh ... I failed to specifically thank you for providing those 2 patches.
    I'll certainly be including them as I think that -Ud_strtod builds should be supported.
    With current perl source there's no point in building with -Ud_strtod (or -Ud_strtold) but with the patches I'm proposing, those switches provide the simplest way to resort to using perl's Atof for assigning floating point values.
    I don't expect that anyone in their right mind would want to opt for using perl's Atof, but I think the option should remain and the test suite should pass all tests.

    Cheers,
    Rob

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1219428]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (7)
As of 2024-04-18 22:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found