capture the current behavior of perlprimtypes.swg is more detail

This commit is contained in:
Robert Stone 2015-08-08 11:32:55 -07:00
commit 8ac4a8147b
2 changed files with 80 additions and 2 deletions

View file

@ -2,7 +2,7 @@
use overload_simple;
use vars qw/$DOWARN/;
use strict;
use Test::More tests => 75;
use Test::More tests => 97;
pass("loaded");
@ -196,3 +196,40 @@ is(overload_simple::int_object(1), 1, "int_object(1)");
is(overload_simple::int_object(0), 0, "int_object(0)");
is(overload_simple::int_object(undef), 999, "int_object(Spam*)");
is(overload_simple::int_object($s), 999, "int_object(Spam*)");
# some of this section is duplication of above tests, but I want to see
# parity with the coverage in wrapmacro_runme.pl.
sub check {
my($args, $want) = @_;
my($s, $rslt) = defined $want ? ($want, "bar:$want") : ('*boom*', undef);
is(eval("overload_simple::Spam::bar($args)"), $rslt, "bar($args) => $s");
}
# normal use patterns
check("11", 'int');
check("11.0", 'double');
check("'11'", 'char *');
check("'11.0'", 'char *');
check("-13", 'int');
check("-13.0", 'double');
check("'-13'", 'char *');
check("'-13.0'", 'char *');
check("' '", 'char *');
check("' 11 '", 'char *');
# TypeError explosions
check("\\*STDIN", undef);
check("[]", undef);
check("{}", undef);
check("sub {}", undef);
# regression cases
check("''", 'char *');
check("' 11'", 'char *');
check("' 11.0'", 'char *');
check("' -11.0'", 'char *');
check("\"11\x{0}\"", 'char *');
check("\"\x{0}\"", 'char *');
check("\"\x{9}11\x{0}this is not eleven.\"", 'char *');
check("\"\x{9}11.0\x{0}this is also not eleven.\"", 'char *');