This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
t/op/auto.pl using test.pl
[perl5.git] / t / op / auto.t
CommitLineData
8d063cd8
LW
1#!./perl
2
c9866f46
DL
3BEGIN {
4 chdir 't' if -d 't';
5 @INC = qw(. ../lib);
6}
7
8require "test.pl";
9plan( tests => 37 );
8d063cd8
LW
10
11$x = 10000;
c9866f46
DL
12cmp_ok(0 + ++$x - 1,'==',10000,'scalar ++x - 1');
13cmp_ok(0 + $x-- - 1,'==',10000,'scalar x-- - 1');
14cmp_ok(1 * $x, '==',10000,'scalar 1 * x');
15cmp_ok(0 + $x-- - 0,'==',10000,'scalar x-- - 0');
16cmp_ok(1 + $x, '==',10000,'scalar 1 + x');
17cmp_ok(1 + $x++, '==',10000,'scalar 1 + x++');
18cmp_ok(0 + $x, '==',10000,'scalar x');
19cmp_ok(0 + --$x + 1,'==',10000,'scalar --x + 1');
20cmp_ok(0 + ++$x + 0,'==',10000,'scalar ++x + 0');
21cmp_ok($x, '==',10000,'scalar x final');
8d063cd8
LW
22
23$x[0] = 10000;
c9866f46
DL
24cmp_ok(0 + ++$x[0] - 1,'==',10000,'aelem ++x - 1');
25cmp_ok(0 + $x[0]-- - 1,'==',10000,'aelem x-- - 1');
26cmp_ok(1 * $x[0], '==',10000,'aelem 1 * x');
27cmp_ok(0 + $x[0]-- - 0,'==',10000,'aelem x-- - 0');
28cmp_ok(1 + $x[0], '==',10000,'aelem 1 + x');
29cmp_ok(1 + $x[0]++, '==',10000,'aelem 1 + x++');
30cmp_ok(0 + $x[0], '==',10000,'aelem x');
31cmp_ok(0 + --$x[0] + 1,'==',10000,'aelem --x + 1');
32cmp_ok(0 + ++$x[0] + 0,'==',10000,'aelem ++x + 0');
33cmp_ok($x[0], '==',10000,'aelem x final');
8d063cd8
LW
34
35$x{0} = 10000;
c9866f46
DL
36cmp_ok(0 + ++$x{0} - 1,'==',10000,'helem ++x - 1');
37cmp_ok(0 + $x{0}-- - 1,'==',10000,'helem x-- - 1');
38cmp_ok(1 * $x{0}, '==',10000,'helem 1 * x');
39cmp_ok(0 + $x{0}-- - 0,'==',10000,'helem x-- - 0');
40cmp_ok(1 + $x{0}, '==',10000,'helem 1 + x');
41cmp_ok(1 + $x{0}++, '==',10000,'helem 1 + x++');
42cmp_ok(0 + $x{0}, '==',10000,'helem x');
43cmp_ok(0 + --$x{0} + 1,'==',10000,'helem --x + 1');
44cmp_ok(0 + ++$x{0} + 0,'==',10000,'helem ++x + 0');
45cmp_ok($x{0}, '==',10000,'helem x final');
378cc40b
LW
46
47# test magical autoincrement
48
c9866f46
DL
49cmp_ok(++($foo = '99'), 'eq','100','99 incr 100');
50cmp_ok(++($foo = 'a0'), 'eq','a1','a0 incr a1');
51cmp_ok(++($foo = 'Az'), 'eq','Ba','Az incr Ba');
52cmp_ok(++($foo = 'zz'), 'eq','aaa','zzz incr aaa');
53cmp_ok(++($foo = 'A99'),'eq','B00','A99 incr B00');
54cmp_ok(++($foo = 'zi'), 'eq','zj','zi incr zj (EBCDIC i,j non-contiguous check)');
55cmp_ok(++($foo = 'zr'), 'eq','zs','zr incr zs (EBCDIC r,s non-contiguous check)');