File: goto.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 (42 lines) | stat: -rw-r--r-- 861 bytes parent folder | download | duplicates (6)
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
#!./perl -w

BEGIN {
    chdir 't' if -d 't';
    require './test.pl';
}

plan tests => 4;

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

sub goto_baresub {
    goto &問題の原因;
}

sub goto_softref {
    goto &{"問題の原因"};
}

sub goto_softref_octal {
    goto &{"\345\225\217\351\241\214\343\201\256\345\216\237\345\233\240"};
}

sub 問題の原因 {
    1;
}

ok goto_baresub(), "Magical goto works on an UTF-8 sub,";
ok goto_softref(), "..and an UTF-8 softref sub,";

{
    local $@;
    eval { goto_softref_octal() };
    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";
}

{
    local $@;
    eval { goto &因 };
    like $@, qr/Goto undefined subroutine &main::因/, "goto undefined sub gets the right error message";
}