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