File: opcroak.t

package info (click to toggle)
perl 5.42.0-2
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 128,392 kB
  • sloc: perl: 534,963; ansic: 240,563; sh: 72,042; pascal: 6,934; xml: 2,428; yacc: 1,360; makefile: 1,197; cpp: 208; lisp: 1
file content (46 lines) | stat: -rw-r--r-- 1,166 bytes parent folder | download | duplicates (5)
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
45
46
#!./perl

#
# tests for op.c generated croaks
#

BEGIN {
    chdir 't' if -d 't';
    require './test.pl';
    set_up_inc(qw '../lib ../dist/base/lib');
}

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

die $@ if $@;

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";
}