This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Brendan Byrd is now a perl AUTHOR
[perl5.git] / ext / arybase / t / arybase.t
CommitLineData
b82b06b8
FC
1#!perl
2
3# Basic tests for $[ as a variable
41e1edf5 4# plus miscellaneous bug fix tests
b82b06b8 5
36b2db7e 6no warnings 'deprecated';
b82b06b8
FC
7use Test::More tests => 7;
8
9sub outside_base_scope { return "${'['}" }
10
11$[ = 3;
12my $base = \$[;
13is "$$base", 3, 'retval of $[';
14is outside_base_scope, 0, 'retval of $[ outside its scope';
15
16${'['} = 3;
17pass('run-time $[ = 3 assignment (in $[ = 3 scope)');
18{
19 $[ = 0;
20 ${'['} = 0;
21 pass('run-time $[ = 0 assignment (in $[ = 3 scope)');
22}
23
24eval { ${'['} = 1 }; my $f = __FILE__; my $l = __LINE__;
25is $@, "That use of \$[ is unsupported at $f line $l.\n",
26 "error when setting $[ to integer other than current base at run-time";
27
28$[ = 6.7;
29is "$[", 6, '$[ is an integer';
30
31eval { my $x = 45; $[ = \$x }; $l = __LINE__;
32is $@, "That use of \$[ is unsupported at $f line $l.\n",
33 'error when setting $[ to ref';
34
41e1edf5
FC
35sub foo { my $x; $x = wait } # compilation of this routine used to crash
36
b82b06b8 371;