Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

ignore print -0 test errors on win32 #366

Open
rurban opened this Issue · 17 comments

6 participants

@rurban
Collaborator

The win32 msvcrt has a special limitation not to print -0 as -0, instead it prints 0.

openbsd seems to have the same problem. cygwin is not affected, since it uses newlib, which is similar to the glibc in this regard.

For now I fixed the failing tests, but there should be a workaround.

``` t\pmc\complex.t: not ok 380 – sinh of 0-2i

  1. Have: 0.000000-0.909297i
  2. Want: -0.000000-0.909297i not ok 381 – sinh of 0+2i
  3. Have: 0.000000+0.909297i
  4. Want: -0.000000+0.909297i

t\pmc\float.t: not ok 23 – neg 0

  1. Failed test ‘neg 0’
  2. at t\pmc\float.t line 509
  3. ‘0’
  4. doesn’t match ’/^-0/

t\op\arithmetics.t: not ok 7 – turn a native number into its negative

  1. Failed test ‘turn a native number into its negative’
  2. at t\op\arithmetics.t line 175.
  3. got: ’0
  4. 0
  5. -123.456789
  6. 123.456789
  7. 0
  8. 0
  9. -123.456789
  10. 123.456789
  11. expected: ’-0
  12. 0
  13. -123.456789
  14. 123.456789
  15. -0
  16. 0
  17. -123.456789
  18. 123.456789
  19. ’ ```

The internal numeric representation seems not to be affected. In detail, this patch does not help. It’s just the printer.

``` Index: parrot-svn/src/ops/math.ops =============== - parrot-svn.orig/src/ops/math.ops + parrot-svn/src/ops/math.ops @ -774,7 +774,17 @ inline op neg(inout INT) :base_core { }

inline op neg(inout NUM) :base_core {

+#ifdef WIN32 + /* The msvcrt is broken for neg -0.0 */ + if ($1 == -0.0) { + $1 = -0.0; + } + else { + $1 = – $1; + } +#else $1 = – $1; +#endif }

inline op neg(invar PMC) :base_core {

@ -786,7 +796,17 @ inline op neg(out INT, in INT) :base_cor }

inline op neg(out NUM, in NUM) :base_core {

+#ifdef WIN32 + /* The msvcrt is broken for neg -0.0 */ + if ($2 == -0.0) { + $1 = -0.0; + } + else { + $1 = – $1; + } +#else $1 = – $2; +#endif }

inline op neg(out PMC, invar PMC) :base_core {

```

Originally http://trac.parrot.org/parrot/ticket/313

@rurban
Collaborator

2399 byte attachment from rurban at http://trac.parrot.org/parrot/raw-attachment/ticket/313/tt313-win32-neg0.patch

```Index: parrot-svn/t/op/arithmetics.t =============== - parrot-svn.orig/t/op/arithmetics.t 2009-01-31 14:05:40.000000000 0100 ++ parrot-svn/t/op/arithmetics.t 2009-02-11 09:36:04.671875000 +0100 @ -169,10 +169,22 @

  1. Operations on a single NUMVAL #

-SKIP: { - skip ‘failing on your platform’ => 1 if $^O =~ m/openbsd/i; +my $output = <<OUTPUT; +-0 +0 +-123.456789 +123.456789 +-0 +0 +-123.456789 +123.456789 +OUTPUT + +if ($^O =~ m/openbsd|win32/i) { + $output =~ s/-0$/0/mg; +}

-pasm_output_is( <<‘CODE’, <<OUTPUT, “turn a native number into its negative” ); +pasm_output_is( <<‘CODE’, $output, “turn a native number into its negative” ); set N0, 0 neg N0 print N0 @ -208,17 +220,6 @ print “\n” end CODE —0 -0 —123.456789 -123.456789 —0 -0 —123.456789 -123.456789 -OUTPUT - -}

pasm_output_is( <<‘CODE’, <<OUTPUT, “take the absolute of a native number” ); set N0, 0

Index: parrot-svn/t/pmc/float.t =============== - parrot-svn.orig/t/pmc/float.t 2009-01-31 14:05:39.000000000 0100 ++ parrot-svn/t/pmc/float.t 2009-02-11 09:41:01.468750000 +0100 @ -503,20 +503,18 @ ok 2 OUTPUT

-SKIP: { - skip ‘failing on your platform’ => 1 if $^O =~ m/openbsd/i; +my $output = ‘-0’; +if ($^O =~ m/openbsd|win32/i) { + $output =~ s/-0$/0/mg; +}

-pasm_output_like( << ‘CODE’, << ‘OUTPUT’, “neg 0” ); +pasm_output_is( << ‘CODE’, $output, “neg 0” ); new P0, [‘Float’] set P0, 0.0 neg P0 print P0 end CODE -/^-0/ -OUTPUT - -}

pasm_output_is( << ‘CODE’, << ‘OUTPUT’, “Equality” ); new P0, [‘Float’]

Index: parrot-svn/t/pmc/complex.t =============== - parrot-svn.orig/t/pmc/complex.t 2009-01-31 14:05:39.000000000 0100 ++ parrot-svn/t/pmc/complex.t 2009-02-11 09:45:36.421875000 +0100 @ -1042,12 +1042,13 @ .complex_op_is(“-2-3i”, “3.590565-0.530921i”, ‘sinh’ )

eq osname, “openbsd”, fail

+ eq osname, “MSWin32”, fail .complex_op_is(“0-2i”, “-0.000000-0.909297i”, ‘sinh’ ) .complex_op_is(“0+2i”, “-0.000000+0.909297i”, ‘sinh’ ) .return()

fail:

- skip( 2, ‘failing on your platform’ ) + skip( 2, ‘sinh 0+2i, sinh 0-2i failing on your platform’ ) .end

.sub cosh_of_complex_numbers

```

@rurban
Collaborator

Fixed by r36574.

See e.g. for exact the same buildbot failures  http://smolder.plusthree.com/app/public_projects/report_details/17922

@chromatic

No, you didn’t “fix” these. A real fix would make the feature work, and the tests pass. That’s why we have tests — to give us confidence that features work.

Skipping failing tests that should pass is never acceptable. If you can’t make them pass, an acceptable alternative is marking the tests as TODO.

@rurban
Collaborator

changed by chromatic from skip to todo with r36575.

Marked -0.0 tests as TODO instead of failing on MSWin32 and OpenBSD, per comments on TT #313. This reverts and supersedes r36574. review: https://trac.parrot.org/parrot/changeset/36575/

This ticket will mark the openbsd and win32 workarounds to fix the printout. I’ll also seperate this case in the tests.

@rurban
Collaborator

18576 byte attachment from rurban at http://trac.parrot.org/parrot/raw-attachment/ticket/313/tt313-add-neg_0.patch

```Index: parrot-svn/lib/Parrot/Configure/Step/List.pm =============== - parrot-svn.orig/lib/Parrot/Configure/Step/List.pm 2009-01-02 12:48:36.000000000 0000 ++ parrot-svn/lib/Parrot/Configure/Step/List.pm 2009-02-11 18:48:35.444625000 0000 @ -50,6 +50,7 @ auto::memalign auto::signal auto::socklen_t + auto::neg_0 auto::env auto::gmp auto::readline Index: parrot-svn/t/op/arithmetics.t =============== - parrot-svn.orig/t/op/arithmetics.t 2009-02-11 17:37:36.913375000 +0000 ++ parrot-svn/t/op/arithmetics.t 2009-02-11 18:31:19.100875000 +0000 @ -33,29 +33,23 @ pasm_output_is( <<‘CODE’, <<OUTPUT, “take the negative of a native integer” ); set I0, 0 neg I0 - print I0 - print “\n” + say I0 set I0, 1234567890 neg I0 - print I0 - print “\n” + say I0 set I0, -1234567890 neg I0 - print I0 - print “\n” + say I0 set I0, 0 set I1, 0 neg I1, I0 - print I1 - print “\n” + say I1 set I0, 1234567890 neg I1, I0 - print I1 - print “\n” + say I1 set I0, -1234567890 neg I1, I0 - print I1 - print “\n” + say I1 end CODE 0 @ -69,29 +63,23 @ pasm_output_is( <<‘CODE’, <<OUTPUT, “take the absolute of a native integer” ); set I0, 0 abs I0 - print I0 - print “\n” + say I0 set I0, 1234567890 abs I0 - print I0 - print “\n” + say I0 set I0, -1234567890 abs I0 - print I0 - print “\n” + say I0 set I0, 0 set I1, 0 abs I1, I0 - print I1 - print “\n” + say I1 set I0, 1234567890 abs I1, I0 - print I1 - print “\n” + say I1 set I0, -1234567890 abs I1, I0 - print I1 - print “\n” + say I1 end CODE 0 @ -109,11 +97,9 @ set I0, 4000 set I1, -123 add I2, I0, I1 - print I2 - print “\n” + say I2 add I0, I0, I1 - print I0 - print “\n” + say I0 end CODE 3877 @ -124,11 +110,9 @ set I0, 4000 set I1, -123 sub I2, I0, I1 - print I2 - print “\n” + say I2 sub I0, I0, I1 - print I0 - print “\n” + say I0 end CODE 4123 @ -139,11 +123,9 @ set I0, 4000 set I1, -123 mul I2, I0, I1 - print I2 - print “\n” + say I2 mul I0, I0, I1 - print I0 - print “\n” + say I0 end CODE -492000 @ -154,11 +136,9 @ set I0, 4000 set I1, -123 div I2, I0, I1 - print I2 - print “\n” + say I2 div I0, I0, I1 - print I0 - print “\n” + say I0 end CODE -32 @ -177,21 +157,23 @ pasm_output_is( <<‘CODE’, <<OUTPUT, ‘negate -0.0’, @todo ); set N0, 0 neg N0 - print N0 - print “\n” + say N0 set N0, -0.0 neg N0 - print N0 - print “\n” + say N0 set N0, -0.0 neg N1, N0 - print N1 - print “\n” + say N1 + set N0, 0 + set N1, 1 + neg N1, N0 + say N1 + end CODE -0 0 —0 0 +-0 OUTPUT

}

@ -204,30 +186,20 @ pasm_output_is( <<‘CODE’, <<OUTPUT, ‘negate a native number’ ); set N0, 123.4567890 neg N0 - print N0 - print “\n” + say N0 set N0, -123.4567890 neg N0 - print N0 - print “\n” - set N0, 0 - set N1, 1 - neg N1, N0 - print N1 - print “\n” + say N0 set N0, 123.4567890 neg N1, N0 - print N1 - print “\n” + say N1 set N0, -123.4567890 neg N1, N0 - print N1 - print “\n” + say N1 end CODE -123.456789 123.456789 -0 -123.456789 123.456789 OUTPUT @ -235,40 +207,32 @ pasm_output_is( <<‘CODE’, <<OUTPUT, “take the absolute of a native number” ); set N0, 0 abs N0 - print N0 - print “\n” + say N0 set N0, -0.0 abs N0 - print N0 - print “\n” + say N0 set N0, 123.45678901 abs N0 - print N0 - print “\n” + say N0 set N0, -123.45678901 abs N0 - print N0 - print “\n” + say N0 set N0, 0 set N1, 1 abs N1, N0 - print N1 - print “\n” + say N1 set N0, 0.0 set N1, 1 abs N1, N0 - print N1 - print “\n” + say N1 set N0, 123.45678901 set N1, 1 abs N1, N0 - print N1 - print “\n” + say N1 set N0, -123.45678901 set N1, 1 abs N1, N0 - print N1 - print “\n” + say N1 end CODE 0 @ -284,56 +248,45 @ pasm_output_is( <<‘CODE’, <<OUTPUT, “ceil of a native number” ); set N0, 0 ceil N0 - print N0 - print “\n” + say N0 set N0, 123.45678901 ceil N0 - print N0 - print “\n” + say N0 set N0, -123.45678901 ceil N0 - print N0 - print “\n” + say N0 set N0, 0 set N1, 1 ceil N1, N0 - print N1 - print “\n” + say N1 set N0, 0.0 set N1, 1 ceil N1, N0 - print N1 - print “\n” + say N1 set N0, 123.45678901 set N1, 1 ceil N1, N0 - print N1 - print “\n” + say N1 set N0, -123.45678901 set N1, 1 ceil N1, N0 - print N1 - print “\n” + say N1 set N0, 0 set I1, 1 ceil I1, N0 - print I1 - print “\n” + say I1 set N0, 0.0 set I1, 1 ceil I1, N0 - print I1 - print “\n” + say I1 set N0, 123.45678901 set I1, 1 ceil I1, N0 - print I1 - print “\n” + say I1 set N0, -123.45678901 set I1, 1 ceil I1, N0 - print I1 - print “\n” + say I1 end CODE 0 @ -352,56 +305,45 @ pasm_output_is( <<‘CODE’, <<OUTPUT, “floor of a native number” ); set N0, 0 floor N0 - print N0 - print “\n” + say N0 set N0, 123.45678901 floor N0 - print N0 - print “\n” + say N0 set N0, -123.45678901 floor N0 - print N0 - print “\n” + say N0 set N0, 0 set N1, 1 floor N1, N0 - print N1 - print “\n” + say N1 set N0, 0.0 set N1, 1 floor N1, N0 - print N1 - print “\n” + say N1 set N0, 123.45678901 set N1, 1 floor N1, N0 - print N1 - print “\n” + say N1 set N0, -123.45678901 set N1, 1 floor N1, N0 - print N1 - print “\n” + say N1 set N0, 0 set I1, 1 floor I1, N0 - print I1 - print “\n” + say I1 set N0, 0.0 set I1, 1 floor I1, N0 - print I1 - print “\n” + say I1 set N0, 123.45678901 set I1, 1 floor I1, N0 - print I1 - print “\n” + say I1 set N0, -123.45678901 set I1, 1 floor I1, N0 - print I1 - print “\n” + say I1 end CODE 0 @ -424,14 +366,11 @ set I0, 4000 set N0, -123.123 add N1, N0, I0 - print N1 - print “\n” + say N1 add N0, N0, I0 - print N0 - print “\n” + say N0 add N0, I0 - print N0 - print “\n” + say N0 end CODE 3876.877 @ -443,14 +382,11 @ set I0, 4000 set N0, -123.123 sub N1, N0, I0 - print N1 - print “\n” + say N1 sub N0, N0, I0 - print N0 - print “\n” + say N0 sub N0, I0 - print N0 - print “\n” + say N0 end CODE -4123.123 @ -462,14 +398,11 @ set I0, 4000 set N0, -123.123 mul N1, N0, I0 - print N1 - print “\n” + say N1 mul N0, N0, I0 - print N0 - print “\n” + say N0 mul N0, -2 - print N0 - print “\n” + say N0 end CODE -492492 @ -481,21 +414,16 @ set I0, 4000 set N0, -123.123 div N1, N0, I0 - print N1 - print “\n” + say N1 div N0, N0, I0 - print N0 - print “\n” + say N0 div N0, 1 - print N0 - print “\n” + say N0 set N0, 100.000 div N0, 100 - print N0 - print “\n” + say N0 div N0, 0.01 - print N0 - print “\n” + say N0 end CODE -0.03078075 @ -512,11 +440,9 @ set N2, 4000.246 set N0, -123.123 add N1, N0, N2 - print N1 - print “\n” + say N1 add N0, N0, N2 - print N0 - print “\n” + say N0 end CODE 3877.123 @ -527,11 +453,9 @ set N2, 4000.246 set N0, -123.123 sub N1, N0, N2 - print N1 - print “\n” + say N1 sub N0, N0, N2 - print N0 - print “\n” + say N0 end CODE -4123.369 @ -542,11 +466,9 @ set N2, 4000.246 set N0, -123.123 mul N1, N0, N2 - print N1 - print “\n” + say N1 mul N0, N0, N2 - print N0 - print “\n” + say N0 end CODE -492522.288258 @ -557,11 +479,9 @ set N2, 4000.246 set N0, -123.123 div N1, N0, N2 - print N1 - print “\n” + say N1 div N0, N0, N2 - print N0 - print “\n” + say N0 end CODE -0.0307788571002883 @ -574,7 +494,7 @ lcm I2, I1, I0 eq I2, 10, OK1 print "not " -OK1: print “ok 1\n” +OK1: say “ok 1”

set I1, 17 lcm I2, I1, I0

Index: parrot-svn/config/auto/neg_0.pm =============== - parrot-svn.orig/config/auto/neg_0.pm 2009-02-11 17:59:09.000000000 0000 ++ parrot-svn/config/auto/neg_0.pm 2009-02-11 19:02:07.835250000 +0000 @ -1,5 +1,5 @ -# Copyright © 2006-2007, The Perl Foundation. -# $Id: neg_0.pm 30367 2008-08-20 02:21:59Z jkeenan $ +# Copyright © 2009, The Perl Foundation. +# $Id: neg_0.pm 30367 2008-08-20 02:21:59Z rurban $

=head1 NAME

@ -7,7 +7,7 @

=head1 DESCRIPTION

-Determines whether print -0.0 can print -0 or just 0. +Determines whether print -0.0 can print “-0” or just prints “0”

This needs workarounds on older win32 (msvcrt.dll) and openbsd.

@ -33,26 +33,30 @

sub runstep { my ( $self, $conf ) = @_;

- - my $d_negative_zero = probe_for_negative_zero($conf); - - $self→evaluate_negative_zero($conf, $d_negative_zero); + my ( $verbose ) = $conf→options→get(‘verbose’); + $conf→cc_gen(‘config/auto/neg_0/test_c.in’); + eval { $conf→cc_build( q{} ); }; + my $has_neg_0 = 0; + if ( !$@ ) { + my $test = $conf→cc_run(); + $has_neg_0 = $self→evaluate_cc_run($conf, $test, $has_neg_0, $verbose); + } + $conf→cc_clean(); + $conf→data→set( has_negativezero => $hasneg0 );

return 1; }

-sub probe_for_negative_zero { - my $conf = shift; - return $conf→data→get(‘has_negative_zero’) - || - $conf→data→get_p5(’d_negativezero’); -} - -sub evaluate_negative_zero { - my ($self, $conf, $d_negative_zero) = @_; - my $has_negative_zero = $d_negative_zero ? 1 : 0; - $self→set_result( $has_negative_zero ? ‘yes’ : ‘no’ ); - $conf→data→set( has_negative_zero => $has_negativezero ); +sub evaluate_cc_run { + my $self = shift; + my ($conf, $test, $has_neg_0, $verbose) = @_; + if ( $test =~ m/^-0/ ) { + $has_neg_0 = 1; + $self→set_result( $has_neg_0 ? ‘yes’ : ‘no’ ); + $conf→data→set( has_negative_zero => $has_neg_0 ); + print " (yes) " if $verbose; + } + return $has_neg0; }

1;

Index: parrot-svn/t/steps/auto_neg_0-01.t =============== - /dev/null 1970-01-01 00:00:00.000000000 0000 ++ parrot-svn/t/steps/auto_neg_0-01.t 2009-02-11 19:46:30.382125000 0000 @ -0,0 +1,106 @ +#! perl +# Copyright © 2009, The Perl Foundation. +# $Id: auto_socklen_t-01.t 30640 2008-08-29 23:09:28Z jkeenan $ +# auto_neg_0-01.t + +use strict; +use warnings; +use Test::More tests => 16; +use Carp; +use lib qw( lib t/configure/testlib ); +use_ok(‘config::auto::socklen_t’); +use Parrot::Configure; +use Parrot::Configure::Options qw( process_options ); +use Parrot::Configure::Test qw( + test_step_thru_runstep + rerun_defaults_for_testing + test_step_constructor_and_description +); +use IO::CaptureOutput qw| capture |; + +########### regular ########### + +my ($args, $step_list_ref) = process_options( + { + argv => [ ], + mode => q{configure}, + } +); + +my $conf = Parrot::Configure→new; + +my $pkg = q{auto::neg_0}; + +$conf→add_steps($pkg); + +my $serialized = $conf→pcfreeze(); + +$conf→options→set( %{$args} ); +my $step = test_step_constructor_and_description($conf); +my $ret = $step→runstep($conf); +ok( $ret, “runstep() returned true value” ); +ok(defined($step→result()), “A result has been defiined”); + +$conf→replenish($serialized); + +##### evaluate_neg_0_t() ##### + +($args, $step_list_ref) = process_options( + { + argv => [ ], + mode => q{configure}, + } +); +$conf→options→set( %{$args} ); +$step = test_step_constructor_and_description($conf); + +my $d_neg_zero; + +$d_neg_zero = q{-0}; +ok($step→evaluate_cc_run($conf, $d_neg_zero), + “_evaluate_cc_run() completed satisfactorily”); +is($step→result(), q{yes}, “Got expected result”); +is($conf→data→get(‘has_negative_zero’), 1, + “has_negative_zero set as expected”); + +$d_neg_zero = q{0}; +ok($step→evaluate_cc_run($conf, $d_neg_zero), + “_evaluate_cc_run() completed satisfactorily”); +is($step→result(), q{no}, “Got expected result”); +is($conf→data→get(‘has_negative_zero’), 0, + “has_negative_zero set as expected”); + +pass(“Completed all tests in $0”); + +################### DOCUMENTATION ################### + +=head1 NAME + +auto_neg_0-01.t – test auto::neg_0 + +=head1 SYNOPSIS + + % prove t/steps/auto_neg0-01.t + +=head1 DESCRIPTION + +The files in this directory test functionality used by F. + +The tests in this file test auto::neg0. + +=head1 AUTHOR + +Reini Urban + +=head1 SEE ALSO + +config::auto::neg0, F. + +=cut + +# Local Variables: +# mode: cperl +# cperl-indent-level: 4 +# fill-column: 100 +# End: +# vim: expandtab shiftwidth=4: Index: parrot-svn/MANIFEST =============== - parrot-svn.orig/MANIFEST 2009-02-11 11:09:51.000000000 +0000 ++ parrot-svn/MANIFEST 2009-02-11 19:20:21.725875000 0000 @ -273,6 +273,8 @ config/auto/memalign/test_c.in [] config/auto/msvc.pm [] config/auto/msvc/test_c.in [] +config/auto/neg_0.pm [] +config/auto/neg_0/test_c.in [] config/auto/opengl.pm [] config/auto/opengl/opengl_c.in [] config/auto/ops.pm [] @ -3247,6 +3249,7 @ t/steps/auto_macports-02.t [] t/steps/auto_memalign-01.t [] t/steps/auto_msvc-01.t [] +t/steps/auto_neg_0-01.t [] t/steps/auto_opengl-01.t [] t/steps/auto_ops-01.t [] t/steps/auto_pcre-01.t [] Index: parrot-svn/config/auto/neg_0/test_c.in =============== - /dev/null 1970-01-01 00:00:00.000000000 +0000 ++ parrot-svn/config/auto/neg_0/test_c.in 2009-02-11 18:18:18.038375000 0000 @ -0,0 +1,8 @ +#include + +int +main(int argc, char* argv[]) +{ + printf(“%.0f”, 0.0); + return 0; +} Index: parrot-svn/config/gen/config_h/feature_h.in =============== -- parrot-svn.orig/config/gen/config_h/feature_h.in 2008-12-06 00:10:10.000000000 +0000 ++ parrot-svn/config/gen/config_h/feature_h.in 2009-02-11 18:58:27.663375000 +0000 @ -154,6 +154,15 @

print OUT <<‘END_PRINT’;

+/* from config/auto/neg_0 */ +END_PRINT +if (has_negative_zero) { + print OUT <<‘END_PRINT’; +#define PARROT_HAS_NEGATIVE_ZERO 1 +END_PRINT +} + +print OUT <<‘END_PRINT’;

#endif /* PARROT_FEATURE_H_GUARD */ END_PRINT

Index: parrot-svn/src/ops/io.ops =============== - parrot-svn.orig/src/ops/io.ops 2009-02-03 20:00:26.000000000 0000 ++ parrot-svn/src/ops/io.ops 2009-02-11 19:10:47.085250000 +0000 @ -152,7 +152,17 @ }

inline op print(in NUM) :base_io {

+#ifdef PARROT_HAS_NEGATIVE_ZERO Parrot_io_printf(interp, FLOATVAL_FMT, $1); +#else + /* Workaround for older msvcrt and openbsd. TT #313 */ + if ($1 == -0.0) { + Parrot_io_printf(interp, “-0”); + } + else { + Parrot_io_printf(interp, FLOATVAL_FMT, $1); + } +#endif }

op print(in STR) :base_io {

@ -185,7 +195,17 @ }

inline op say(in NUM) :base_io {

+#ifdef PARROT_HAS_NEGATIVE_ZERO Parrot_io_printf(interp, FLOATVAL_FMT “\n”, $1); +#else + /* Workaround for older msvcrt and openbsd. TT #313 */ + if ($1 == -0.0) { + Parrot_io_printf(interp, “-0\n”); + } + else { + Parrot_io_printf(interp, FLOATVAL_FMT “\n”, $1); + } +#endif }

op say(in STR) :base_io {

```

@rurban
Collaborator

As discussed on irc the new feature has_negative_zero is checked in auto::neg_0 and used in io.ops for the -0.0 special case.

See tt313-add-neg_0.patch

Tested with has_negative_zero=1 on cygwin, debian-gcc and solaris-64-cc. But on (has_negative_zero=0) mingw, msvc6 there’s more work to be done.

Looks like x == -0.0 compare fails in this libc also.

@rurban
Collaborator

See  http://gcc.gnu.org/ml/gcc/2007-06/msg00196.html

Current problem:

0 == -0.0 => 1 on mingw/msvc

@ghost

Correct. You should find 0.0 == -0.0 on any reasonable compiler. (Explicit testing on icc would be useful!) If it’s available, the best test to use is signbit(). This has come up many times before. There is much more background in the RT tickets [RT #60312] (which includes a useful starting point for a patch) [RT #28170] and [RT #30737] (incorrectly marked as rejected, but that’s ok since it’s duplicated by 60312).

@rurban
Collaborator

Fixed by r36638.

- add has_negative_zero feature, - fix print_n and say_n for the platforms failing the new has_negative_zero

configure test

- enable the failing tests again

This print -0.0 is a long-standing problem and finally fixes [perl #28170], [perl #30737], [perl #19183], [perl #60312].

Note that special yet untested platforms, like arm might also fail the “has_negative_zero” test and might fail the signbit workaround we use. long double -0.0 will also need a workaround code like this. There’s a patch to generate the signbit() fallback at RT #30737.

Many thanks to Andy Dougherty for pointing me to the old tickets and for the solution which was there for 5 years.

M MANIFEST A config/auto/neg_0.pm M config/gen/config_h/feature_h.in M lib/Parrot/Configure/Step/List.pm M t/op/arithmetics.t M t/pmc/complex.t M t/pmc/float.t A t/steps/auto_neg_0-01.t

@ghost

I still don’t see how this is “fixed”. I don’t see any changes to print_n and say_n. (Nor do I understand why you’d try to fix it there rather than in src/spf_render.c). I see a new symbol PARROT_HAS_NEGATIVE_ZERO, but I don’t see any code anywhere that does anything with it.

I am still confused.

@rurban
Collaborator

Oops, thanks. Added with r36660.

Which cases are handled by spf_render, which are not handled in print_n and say_n? These cases need to be added to the tests.

@zhuomingliang
Collaborator

Is It fixed by r36660? It still failed to me.

@rurban
Collaborator

Another msvcrt.dll problem on another machine with msvc6 only with r36632. mingw passes all tests there though.

t\op\arithmetics....NOK 29#   Failed test 'Inf/NaN - basic arith'
#   in t\op\arithmetics.t at line 846.
#          got: 'Inf
# -0
# '
#     expected: 'Inf
# NaN
# '
# Looks like you failed 1 test of 29.
@rurban
Collaborator

Todo the failing pmc tests with r36681.

Need to check src/spf_render.c as they are failing there.

@Infinoid
Collaborator

In r39864, I've just un-TODOed a test on openbsd (test #4 in t/op/arithmetics.t) which had a comment mentioning this ticket. Apparently some floating point fixes to openbsd itself have improved the state of things for that particular test.

Mark

@coke
Owner

Related RT at  http://rt.perl.org/rt3/Ticket/Display.html?id=37993 (That ticket is closed in favor of this ticket.)

@Util
Owner

In r42533, TODOed t/op/number.t test 131 (neg 0.0) where has_negative_zero is false.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.