File: package.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 (122 lines) | stat: -rw-r--r-- 2,768 bytes parent folder | download
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
#!./perl

# Checks if 'package' work as intended.

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

plan (tests => 18);

# Works on either ASCII or EBCDIC
my $prefix = ("a" lt "A") ? "bar:BEGIN" : "BEGIN:bar";

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

package Føø::Bær { }

package クラス { }

package ฟọ::バッズ { }

ok 1, "sanity check. If we got this far, UTF-8 in package names is legal.";

#The next few come from comp/package.t
{

    $ㄅĽuṞfⳐ = 123;
    
    package ꑭʑ;

    sub ニュー {bless [];}
    $bar = 4;
    {
        package 압Ƈ;
        $ㄅĽuṞfⳐ = 5;
    }
    
    {
        no warnings qw(syntax deprecated);
        $압Ƈ'd읯ⱪ = 6;        #'
    }
    
    $ꑭʑ = 2;
    
    $ꑭʑ = join(':', sort(keys %ꑭʑ::));
    $압Ƈ = join(':', sort(keys %압Ƈ::));
    
    ::is $ꑭʑ, "$prefix:ニュー:ꑭʑ:압Ƈ", "comp/stash.t test 1";
    ::is $압Ƈ, "d읯ⱪ:ㄅĽuṞfⳐ", "comp/stash.t test 2";

    {
        no warnings qw(syntax deprecated);
        ::is $main'ㄅĽuṞfⳐ, 123, "comp/stash.t test 3";
    }

    package 압Ƈ;

    ::is $ㄅĽuṞfⳐ, 5, "comp/stash.t test 4";
    eval '::is $ㄅĽuṞfⳐ, 5, "comp/stash.t test 5";';
    eval 'package main; is $ㄅĽuṞfⳐ, 123, "comp/stash.t test 6";';
    ::is $ㄅĽuṞfⳐ, 5, "comp/stash.t test 7";

    #This is actually pretty bad, as caller() wasn't clean to begin with.
    package main;
    sub ㄘ { caller(0) }
    
    sub ƒஓ {
    my $s = shift;
    if ($s) {
            package ᛔQR;
            main::ㄘ();
    }
    }
    
    is((ƒஓ(1))[0], 'ᛔQR', "comp/stash.t test 8");
    
    my $Q = ꑭʑ->ニュー();
    undef %ꑭʑ::;
    eval { $a = *ꑭʑ::ニュー{PACKAGE}; };
    is $a, "__ANON__", "comp/stash.t test 9";

    {
        local $@;
        eval { $Q->param; };
        like $@, qr/^Can't use anonymous symbol table for method lookup/, "comp/stash.t test 10";
    }
    
    like "$Q", qr/^__ANON__=/, "comp/stash.t test 11";

    is ref $Q, "__ANON__", "comp/stash.t test 12";

    package bugⅲⅱⅴⅵⅱ { #not really latin, but bear with me, I'm not Damian.
        ::is( __PACKAGE__,   'bugⅲⅱⅴⅵⅱ', "comp/stash.t test 13");
        ::is( eval('__PACKAGE__'), 'bugⅲⅱⅴⅵⅱ', "comp/stash.t test 14");
    }
}

#This comes from comp/package_block.t
{
    local $@;
    eval q[package ᕘ {];
    like $@, qr/\AMissing right curly /, "comp/package_block.t test";
}

# perl #105922

{
   my $latin_1 = "þackage";
   my $utf8    = "þackage";
   utf8::downgrade($latin_1);
   utf8::upgrade($utf8);

   local $@;
   eval { $latin_1->can("yadda") };
   ok(!$@, "latin1->meth works");

   local $@;
   eval { $utf8->can("yadda") };
   ok(!$@, "utf8->meth works");
}