3 # Basic tests for $[ as a variable
4 # plus miscellaneous bug fix tests
6 use Test::More tests => 7;
8 sub outside_base_scope { return "${'['}" }
12 is "$$base", 3, 'retval of $[';
13 is outside_base_scope, 0, 'retval of $[ outside its scope';
16 pass('run-time $[ = 3 assignment (in $[ = 3 scope)');
20 pass('run-time $[ = 0 assignment (in $[ = 3 scope)');
23 eval { ${'['} = 1 }; my $f = __FILE__; my $l = __LINE__;
24 is $@, "That use of \$[ is unsupported at $f line $l.\n",
25 "error when setting $[ to integer other than current base at run-time";
28 is "$[", 6, '$[ is an integer';
30 eval { my $x = 45; $[ = \$x }; $l = __LINE__;
31 is $@, "That use of \$[ is unsupported at $f line $l.\n",
32 'error when setting $[ to ref';
34 sub foo { my $x; $x = wait } # compilation of this routine used to crash