This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Re: [perl #38710] localised stash slice
[perl5.git] / t / comp / our.t
CommitLineData
cb1ce608
YST
1#!./perl
2
3BEGIN {
4 chdir 't';
5 @INC = '../lib';
6 require './test.pl';
7}
8
8716503d 9print "1..7\n";
cb1ce608
YST
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
30tie $x, 'TieAll';
31tie @x, 'TieAll';
32tie %x, 'TieAll';
33
34{our $x;}
35is(TieAll->calls, '', 'our $x has no runtime effect');
c754c3d7 36
cb1ce608
YST
37{our ($x);}
38is(TieAll->calls, '', 'our ($x) has no runtime effect');
c754c3d7 39
cb1ce608
YST
40{our %x;}
41is(TieAll->calls, '', 'our %x has no runtime effect');
42
c754c3d7
YST
43{our (%x);}
44is(TieAll->calls, '', 'our (%x) has no runtime effect');
45
46{our @x;}
47is(TieAll->calls, '', 'our @x has no runtime effect');
48
49{our (@x);}
50is(TieAll->calls, '', 'our (@x) has no runtime effect');
8716503d
DM
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}