sub test {
$test++;
if (@_ > 1) {
+ my $comment = "";
+ $comment = " # " . $_ [2] if @_ > 2;
if ($_[0] eq $_[1]) {
- print "ok $test\n";
+ print "ok $test$comment\n";
} else {
- print "not ok $test: '$_[0]' ne '$_[1]'\n";
+ $comment .= ": '$_[0]' ne '$_[1]'";
+ print "not ok $test$comment\n";
}
} else {
if (shift) {
package main;
my $a = Foo->new;
$a->xet('b', 42);
-print $a->xet('b') == 42 ? "ok 225\n" : "not ok 225\n";
-print defined eval { $a->{b} } ? "not ok 226\n" : "ok 226\n";
-print $@ =~ /zap/ ? "ok 227\n" : "not ok 227\n";
+test ($a->xet('b'), 42);
+test (!defined eval { $a->{b} });
+test ($@ =~ /zap/);
-print overload::StrVal(qr/a/) =~ /^Regexp=SCALAR\(0x[0-9a-f]+\)$/ ? "ok 228\n" : "not ok 228\n";
+test (overload::StrVal(qr/a/) =~ /^Regexp=SCALAR\(0x[0-9a-f]+\)$/);
{
package t229;
my $y = $x;
eval { $y++ };
}
- print $warn ? "not ok 229\n" : "ok 229\n";
+ main::test (!$warn);
+}
+
+{
+ my ($int, $out1, $out2);
+ {
+ BEGIN { $int = 0; overload::constant 'integer' => sub {$int++; 17}; }
+ $out1 = 0;
+ $out2 = 1;
+ }
+ test($int, 2, "#24313"); # 230
+ test($out1, 17, "#24313"); # 231
+ test($out2, 17, "#24313"); # 232
}
# Last test is:
-sub last {229}
+sub last {232}
UV u = 0;
I32 shift;
bool overflowed = FALSE;
+ bool just_zero = TRUE; /* just plain 0 or binary number? */
static NV nvshift[5] = { 1.0, 2.0, 4.0, 8.0, 16.0 };
static char* bases[5] = { "", "binary", "", "octal",
"hexadecimal" };
if (s[1] == 'x') {
shift = 4;
s += 2;
+ just_zero = FALSE;
} else if (s[1] == 'b') {
shift = 1;
s += 2;
+ just_zero = FALSE;
}
/* check for a decimal in disguise */
else if (s[1] == '.' || s[1] == 'e' || s[1] == 'E')
*/
digit:
+ just_zero = FALSE;
if (!overflowed) {
x = u << shift; /* make room for the digit */
#endif
sv_setuv(sv, u);
}
- if (PL_hints & HINT_NEW_BINARY)
+ if (just_zero && (PL_hints & HINT_NEW_INTEGER))
+ sv = new_constant(start, s - start, "integer",
+ sv, Nullsv, NULL);
+ else if (PL_hints & HINT_NEW_BINARY)
sv = new_constant(start, s - start, "binary", sv, Nullsv, NULL);
}
break;