xref: /openbsd/gnu/usr.bin/perl/t/uni/opcroak.t (revision 4bdff4be)
1#!./perl
2
3#
4# tests for op.c generated croaks
5#
6
7BEGIN {
8    chdir 't' if -d 't';
9    require './test.pl';
10    set_up_inc(qw '../lib ../dist/base/lib');
11}
12
13use utf8;
14use open qw( :utf8 :std );
15use warnings;
16
17plan( tests => 5 );
18
19eval qq!sub \x{30cb} (\$) {} \x{30cb}()!;
20like $@, qr/Not enough arguments for main::\x{30cb}/u, "Not enough arguments croak is UTF-8 clean";
21
22eval qq!sub \x{30cc} (\$) {} \x{30cc}(1, 2)!;
23like $@, qr/Too many arguments for main::\x{30cc}/u, "Too many arguments croak is UTF-8 clean";
24
25eval qq!sub \x{30cd} (\Q\%\E) { 1 } \x{30cd}(1);!;
26like $@, 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    }
35END_FIELDS
36
37die $@ if $@;
38
39for (
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}
47