File Coverage

File:config/auto/neg_0.pm
Coverage:98.0%

linestmtbrancondsubcode
1# Copyright (C) 2009, Parrot Foundation.
2
3 - 13
=head1 NAME

config/auto/neg_0.pm - can print negative zero

=head1 DESCRIPTION

Determines whether print -0.0 can print "-0" or just prints "0"

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

=cut
14
15package auto::neg_0;
16
17
2
2
2
use strict;
18
2
2
2
use warnings;
19
20
21
2
2
2
use base qw(Parrot::Configure::Step);
22
23
2
2
2
use Parrot::Configure::Utils ':auto';
24
25sub _init {
26
4
    my $self = shift;
27
4
    my %data;
28
4
    $data{description} = q{Determine whether negative zero can be printed};
29
4
    $data{result} = q{};
30
4
    return \%data;
31}
32
33sub runstep {
34
2
    my ( $self, $conf ) = @_;
35
2
    $conf->cc_gen('config/auto/neg_0/test_c.in');
36
2
2
    eval { $conf->cc_build( q{} ); };
37
2
    my $has_neg_0 = 0;
38
2
    if ( !$@ ) {
39
2
        my $test = $conf->cc_run();
40
2
        $has_neg_0 = $self->_evaluate_cc_run(
41            $conf,
42            $test,
43            $has_neg_0,
44        );
45    }
46
2
    $conf->cc_clean();
47
2
    $conf->data->set( has_negative_zero => $has_neg_0 );
48
49
2
    return 1;
50}
51
52sub _evaluate_cc_run {
53
6
    my $self = shift;
54
6
    my ($conf, $test, $has_neg_0) = @_;
55
6
    $has_neg_0 = ($test =~ m/^-0/ ? 1 : 0);
56
6
    $self->set_result( $has_neg_0 ? 'yes' : 'no' );
57
6
    my $output = $has_neg_0 ? ' (yes) ' : ' (no) ';
58
6
    $conf->debug($output);
59
6
    return $has_neg_0;
60}
61
621;
63
64# Local Variables:
65# mode: cperl
66# cperl-indent-level: 4
67# fill-column: 100
68# End:
69# vim: expandtab shiftwidth=4: