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
CommitLineData
ce16c625
BF
1#!./perl
2
3#
4# tests for op.c generated croaks
5#
6
7BEGIN {
8 chdir 't' if -d 't';
ce16c625 9 require './test.pl';
624c42e2 10 set_up_inc(qw '../lib ../dist/base/lib');
ce16c625
BF
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
98739cd3
FC
37die $@ if $@;
38
ce16c625
BF
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}