This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
fix VMS test fail
[perl5.git] / t / uni / opcroak.t
1 #!./perl
2
3 #
4 # tests for op.c generated croaks
5 #
6
7 BEGIN {
8     chdir 't' if -d 't';
9     require './test.pl';
10     set_up_inc(qw '../lib ../dist/base/lib');
11 }
12
13 use utf8;
14 use open qw( :utf8 :std );
15 use warnings;
16
17 plan( tests => 5 );
18
19 eval qq!sub \x{30cb} (\$) {} \x{30cb}()!;
20 like $@, qr/Not enough arguments for main::\x{30cb}/u, "Not enough arguments croak is UTF-8 clean";
21
22 eval qq!sub \x{30cc} (\$) {} \x{30cc}(1, 2)!;
23 like $@, qr/Too many arguments for main::\x{30cc}/u, "Too many arguments croak is UTF-8 clean";
24
25 eval qq!sub \x{30cd} (\Q\%\E) { 1 } \x{30cd}(1);!;
26 like $@, qr/Type of arg 1 to main::\x{30cd} must be/u, "bad type croak is UTF-8 clean";
27
28     eval <<'END_FIELDS';
29     {
30         package FŌŌ {
31             use fields qw( a b );
32             sub new { bless {}, shift }
33         }
34     }
35 END_FIELDS
36
37 die $@ if $@;
38
39 for (
40         [ element => 'my FŌŌ $bàr = FŌŌ->new; $bàr->{クラス};' ],
41         [ slice => 'my FŌŌ $bàr = FŌŌ->new; @{$bàr}{ qw( a クラス ) };' ]
42     ) {
43     eval $_->[1];
44     
45     like $@, qr/No such class field "クラス" in variable \$bàr of type FŌŌ/, "$_->[0]: no such field error is UTF-8 clean";
46 }