xref: /openbsd-src/gnu/usr.bin/perl/t/uni/goto.t (revision f2da64fbbbf1b03f09f390ab01267c93dfd77c4c)
1#!./perl -w
2
3BEGIN {
4    require './test.pl';
5}
6
7plan tests => 4;
8
9use utf8;
10use open qw( :utf8 :std );
11
12sub goto_baresub {
13    goto &問題の原因;
14}
15
16sub goto_softref {
17    goto &{"問題の原因"};
18}
19
20sub goto_softref_octal {
21    goto &{"\345\225\217\351\241\214\343\201\256\345\216\237\345\233\240"};
22}
23
24sub 問題の原因 {
25    1;
26}
27
28ok goto_baresub(), "Magical goto works on an UTF-8 sub,";
29ok goto_softref(), "..and an UTF-8 softref sub,";
30
31{
32    local $@;
33    eval { goto_softref_octal() };
34    like $@, qr/Goto undefined subroutine &main::\345\225\217\351\241\214\343\201\256\345\216\237\345\233\240/, "But does NOT find the softref sub when it's lacking the UTF-8 flag";
35}
36
37{
38    local $@;
39    eval { goto &因 };
40    like $@, qr/Goto undefined subroutine &main::因/, "goto undefined sub gets the right error message";
41}
42