This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
count-only transliteration needlessly makes copy-on-write
[perl5.git] / t / comp / our.t
1 #!./perl
2
3 BEGIN {
4     chdir 't';
5     @INC = '../lib';
6     require './test.pl';
7 }
8
9 print "1..7\n";
10
11 {
12     package TieAll;
13     # tie, track, and report what calls are made
14     my @calls;
15     sub AUTOLOAD {
16         for ($AUTOLOAD =~ /TieAll::(.*)/) {
17             if (/TIE/) { return bless {} }
18             elsif (/calls/) { return join ',', splice @calls }
19             else {
20                push @calls, $_;
21                # FETCHSIZE doesn't like undef
22                # if FIRSTKEY, see if NEXTKEY is also called
23                return 1 if /FETCHSIZE|FIRSTKEY/;
24                return;
25             }
26         }
27     }
28 }
29
30 tie $x, 'TieAll';
31 tie @x, 'TieAll';
32 tie %x, 'TieAll';
33
34 {our $x;}
35 is(TieAll->calls, '', 'our $x has no runtime effect');
36
37 {our ($x);}
38 is(TieAll->calls, '', 'our ($x) has no runtime effect');
39
40 {our %x;}
41 is(TieAll->calls, '', 'our %x has no runtime effect');
42
43 {our (%x);}
44 is(TieAll->calls, '', 'our (%x) has no runtime effect');
45
46 {our @x;}
47 is(TieAll->calls, '', 'our @x has no runtime effect');
48
49 {our (@x);}
50 is(TieAll->calls, '', 'our (@x) has no runtime effect');
51
52
53 $y = 1;
54 {
55     my $y = 2;
56     {
57         our $y = $y;
58         is($y, 2, 'our shouldnt be visible until introduced')
59     }
60 }