diff options
author | Brian Fraser <fraserbn@gmail.com> | 2011-10-05 17:57:20 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2011-10-06 13:01:14 -0700 |
commit | 2a0f5ef01a402461f9ced6933ebf587f84a75691 (patch) | |
tree | 4d09dce62fbdcf64e43730675c12b5ea7af516db /t/uni | |
parent | 812df045b04bae646407fcb5794e129676975394 (diff) | |
download | perl-2a0f5ef01a402461f9ced6933ebf587f84a75691.tar.gz |
sv.c: Make most warnings utf8-clean
Diffstat (limited to 't/uni')
-rw-r--r-- | t/uni/method.t | 58 |
1 files changed, 57 insertions, 1 deletions
diff --git a/t/uni/method.t b/t/uni/method.t index 5009a1c924..7c458b84f5 100644 --- a/t/uni/method.t +++ b/t/uni/method.t @@ -15,7 +15,7 @@ use utf8; use open qw( :utf8 :std ); no warnings 'once'; -plan(tests => 16); +plan(tests => 25); #Can't use bless yet, as it might not be clean @@ -40,3 +40,59 @@ ok $@, "Even if both stash and method are in UTF-8, lookup is nul-clean"; eval { my $ref = \my $var; $ref->method }; like $@, qr/Can't call method "method" on unblessed reference /u; + +{ + use utf8; + use open qw( :utf8 :std ); + + my $e; + + eval '$e = bless {}, "E::A"; E::A->foo()'; + like ($@, qr/^\QCan't locate object method "foo" via package "E::A" at/u); + eval '$e = bless {}, "E::B"; $e->foo()'; + like ($@, qr/^\QCan't locate object method "foo" via package "E::B" at/u); + eval 'E::C->foo()'; + like ($@, qr/^\QCan't locate object method "foo" via package "E::C" (perhaps /u); + + eval 'UNIVERSAL->E::D::foo()'; + like ($@, qr/^\QCan't locate object method "foo" via package "E::D" (perhaps /u); + eval 'my $e = bless {}, "UNIVERSAL"; $e->E::E::foo()'; + like ($@, qr/^\QCan't locate object method "foo" via package "E::E" (perhaps /u); + + $e = bless {}, "E::F"; # force package to exist + eval 'UNIVERSAL->E::F::foo()'; + like ($@, qr/^\QCan't locate object method "foo" via package "E::F" at/u); + eval '$e = bless {}, "UNIVERSAL"; $e->E::F::foo()'; + like ($@, qr/^\QCan't locate object method "foo" via package "E::F" at/u); +} + +is(do { use utf8; use open qw( :utf8 :std ); eval 'Foo->boogie()'; + $@ =~ /^\QCan't locate object method "boogie" via package "Foo" (perhaps /u ? 1 : $@}, 1); + +#This reimplements a bit of _fresh_perl() from test.pl, as we want to decode +#the output of that program before using it. +SKIP: { + skip_if_miniperl('no dynamic loading on miniperl, no Encode'); + + my $prog = q!use utf8; use open qw( :utf8 :std ); sub T::DESTROY { $x = $_[0]; } bless [], "T";!; + utf8::decode($prog); + + my $tmpfile = tempfile(); + my $runperl_args = {}; + $runperl_args->{progfile} = $tmpfile; + $runperl_args->{stderr} = 1; + + open TEST, '>', $tmpfile or die "Cannot open $tmpfile: $!"; + + print TEST $prog; + close TEST or die "Cannot close $tmpfile: $!"; + + my $results = runperl(%$runperl_args); + + require Encode; + $results = Encode::decode("UTF-8", $results); + + like($results, + qr/DESTROY created new reference to dead object 'T' during global destruction./u, + "DESTROY creating a new reference to the object generates a warning in UTF-8."); +} |