From 7db8714f1745a8bf9fbf94b21672ba5e3577fd4f Mon Sep 17 00:00:00 2001 From: Nicholas Clark Date: Sat, 12 Mar 2011 21:37:58 +0000 Subject: [PATCH] In t/op/inc.t, inline check_some_code() into its only call point. --- t/op/inc.t | 66 ++++++++++++++++++++++++++++++-------------------------------- 1 file changed, 32 insertions(+), 34 deletions(-) diff --git a/t/op/inc.t b/t/op/inc.t index d0d3563..88a34b2 100644 --- a/t/op/inc.t +++ b/t/op/inc.t @@ -200,39 +200,6 @@ ok ($a == 2147483647, $a); # 80 bit long doubles have a 64 bit mantissa # sparcs have a 112 bit mantissa for their long doubles. Just to be awkward :-) -sub check_some_code { - my ($warn, $start, $action, $description) = @_; - my $warn_line = ($warn ? 'use' : 'no') . " warnings 'imprecision';"; - my @warnings; - local $SIG{__WARN__} = sub {push @warnings, "@_"}; - - print "# checking $action under $warn_line\n"; - my $code = <<"EOC"; -$warn_line -my \$i = \$start; -for(0 .. 3) { - my \$a = $action; -} -1; -EOC - eval $code or die "# $@\n$code"; - - if ($warn) { - unless (ok (scalar @warnings == 2, scalar @warnings)) { - print STDERR "# $_" foreach @warnings; - } - foreach (@warnings) { - unless (ok (/Lost precision when incrementing \d+/, $_)) { - print STDERR "# $_" - } - } - } else { - unless (ok (scalar @warnings == 0)) { - print STDERR "# @$_" foreach @warnings; - } - } -} - my $h_uv_max = 1 + (~0 >> 1); my $found; for my $n (47..113) { @@ -259,8 +226,39 @@ for my $n (47..113) { foreach ([$start_p, '++$i', 'pre-inc'], [$start_p, '$i++', 'post-inc'], [$start_n, '--$i', 'pre-dec'], [$start_n, '$i--', 'post-dec']) { + my ($start, $action, $description) = @$_; foreach my $warn (0, 1) { - check_some_code($warn, @$_); + my $warn_line = ($warn ? 'use' : 'no') . " warnings 'imprecision';"; + + print "# checking $action under $warn_line\n"; + my $code = <<"EOC"; +$warn_line +my \$i = \$start; +for(0 .. 3) { + my \$a = $action; +} +1; +EOC + my @warnings; + { + local $SIG{__WARN__} = sub {push @warnings, "@_"}; + eval $code or die "# $@\n$code"; + } + + if ($warn) { + unless (ok (scalar @warnings == 2, scalar @warnings)) { + print STDERR "# $_" foreach @warnings; + } + foreach (@warnings) { + unless (ok (/Lost precision when incrementing \d+/, $_)) { + print STDERR "# $_" + } + } + } else { + unless (ok (scalar @warnings == 0)) { + print STDERR "# @$_" foreach @warnings; + } + } } } -- 2.7.4