summaryrefslogtreecommitdiff
path: root/gnu/usr.bin/perl/t/uni/opcroak.t
blob: 29909d7cd6bab02c840a1dc4cf2144c9f5d14853 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!./perl

#
# tests for op.c generated croaks
#

BEGIN {
    chdir 't' if -d 't';
    @INC = '../lib';
    require './test.pl';
}

use utf8;
use open qw( :utf8 :std );
use warnings;

plan( tests => 5 );

eval qq!sub \x{30cb} (\$) {} \x{30cb}()!;
like $@, qr/Not enough arguments for main::\x{30cb}/u, "Not enough arguments croak is UTF-8 clean";

eval qq!sub \x{30cc} (\$) {} \x{30cc}(1, 2)!;
like $@, qr/Too many arguments for main::\x{30cc}/u, "Too many arguments croak is UTF-8 clean";

eval qq!sub \x{30cd} (\Q\%\E) { 1 } \x{30cd}(1);!;
like $@, qr/Type of arg 1 to main::\x{30cd} must be/u, "bad type croak is UTF-8 clean";

    eval <<'END_FIELDS';
    {
        package FŌŌ {
            use fields qw( a b );
            sub new { bless {}, shift }
        }
    }
END_FIELDS

for (
        [ element => 'my FŌŌ $bàr = FŌŌ->new; $bàr->{クラス};' ],
        [ slice => 'my FŌŌ $bàr = FŌŌ->new; @{$bàr}{ qw( a クラス ) };' ]
    ) {
    eval $_->[1];
    
    like $@, qr/No such class field "クラス" in variable \$bàr of type FŌŌ/, "$_->[0]: no such field error is UTF-8 clean";
}