This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Test $x=wait under arybase
[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
FC
5
6use Test::More tests => 7;
7
8sub outside_base_scope { return "${'['}" }
9
10$[ = 3;
11my $base = \$[;
12is "$$base", 3, 'retval of $[';
13is outside_base_scope, 0, 'retval of $[ outside its scope';
14
15${'['} = 3;
16pass('run-time $[ = 3 assignment (in $[ = 3 scope)');
17{
18 $[ = 0;
19 ${'['} = 0;
20 pass('run-time $[ = 0 assignment (in $[ = 3 scope)');
21}
22
23eval { ${'['} = 1 }; my $f = __FILE__; my $l = __LINE__;
24is $@, "That use of \$[ is unsupported at $f line $l.\n",
25 "error when setting $[ to integer other than current base at run-time";
26
27$[ = 6.7;
28is "$[", 6, '$[ is an integer';
29
30eval { my $x = 45; $[ = \$x }; $l = __LINE__;
31is $@, "That use of \$[ is unsupported at $f line $l.\n",
32 'error when setting $[ to ref';
33
41e1edf5
FC
34sub foo { my $x; $x = wait } # compilation of this routine used to crash
35
b82b06b8 361;