This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
arybase.xs: Always check the op type in ck_*
[perl5.git] / ext / arybase / t / arybase.t
CommitLineData
b82b06b8
FC
1#!perl
2
3# Basic tests for $[ as a variable
4
5use Test::More tests => 7;
6
7sub outside_base_scope { return "${'['}" }
8
9$[ = 3;
10my $base = \$[;
11is "$$base", 3, 'retval of $[';
12is outside_base_scope, 0, 'retval of $[ outside its scope';
13
14${'['} = 3;
15pass('run-time $[ = 3 assignment (in $[ = 3 scope)');
16{
17 $[ = 0;
18 ${'['} = 0;
19 pass('run-time $[ = 0 assignment (in $[ = 3 scope)');
20}
21
22eval { ${'['} = 1 }; my $f = __FILE__; my $l = __LINE__;
23is $@, "That use of \$[ is unsupported at $f line $l.\n",
24 "error when setting $[ to integer other than current base at run-time";
25
26$[ = 6.7;
27is "$[", 6, '$[ is an integer';
28
29eval { my $x = 45; $[ = \$x }; $l = __LINE__;
30is $@, "That use of \$[ is unsupported at $f line $l.\n",
31 'error when setting $[ to ref';
32
331;