capture the current behavior of perlprimtypes.swg is more detail
This commit is contained in:
parent
19a20c794b
commit
8ac4a8147b
2 changed files with 80 additions and 2 deletions
|
|
@ -1,7 +1,7 @@
|
|||
#!/usr/bin/perl
|
||||
use strict;
|
||||
use warnings;
|
||||
use Test::More tests => 5;
|
||||
use Test::More tests => 27;
|
||||
BEGIN { use_ok('wrapmacro') }
|
||||
require_ok('wrapmacro');
|
||||
|
||||
|
|
@ -12,3 +12,44 @@ my $b = -1;
|
|||
is(wrapmacro::maximum($a,$b), 2);
|
||||
is(wrapmacro::maximum($a/7.0, -$b*256), 256);
|
||||
is(wrapmacro::GUINT16_SWAP_LE_BE_CONSTANT(1), 256);
|
||||
|
||||
# some of this section is duplication of above tests, but I want to see
|
||||
# parity with the coverage in overload_simple_runme.pl.
|
||||
|
||||
sub check {
|
||||
my($args, $rslt) = @_;
|
||||
my $s = defined $rslt ? $rslt : '*boom*';
|
||||
is(eval("wrapmacro::maximum($args)"), $rslt, "max($args) => $s");
|
||||
}
|
||||
|
||||
# normal use patterns
|
||||
check("0, 11", 11);
|
||||
check("0, 11.0", 11);
|
||||
check("0, '11'", 11);
|
||||
check("0, '11.0'", 11);
|
||||
check("11, -13", 11);
|
||||
check("11, -13.0", 11);
|
||||
{ local $TODO = 'strtoull() handles /^\s*-\d+$/ amusingly';
|
||||
check("11, '-13'", 11);
|
||||
}
|
||||
check("11, '-13.0'", 11);
|
||||
|
||||
# TypeError explosions
|
||||
check("0, ' '", undef);
|
||||
check("0, ' 11 '", undef);
|
||||
check("0, \\*STDIN", undef);
|
||||
check("0, []", undef);
|
||||
check("0, {}", undef);
|
||||
check("0, sub {}", undef);
|
||||
|
||||
# regression cases
|
||||
{ local $TODO = 'strtol() and friends have edge cases we should guard against';
|
||||
check("-11, ''", undef);
|
||||
check("0, ' 11'", undef);
|
||||
check("0, ' 11.0'", undef);
|
||||
check("-13, ' -11.0'", undef);
|
||||
check("0, \"11\x{0}\"", undef);
|
||||
check("0, \"\x{0}\"", undef);
|
||||
check("0, \"\x{9}11\x{0}this is not eleven.\"", undef);
|
||||
check("0, \"\x{9}11.0\x{0}this is also not eleven.\"", undef);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue