Commit | Line | Data |
c963b151 |
1 | #!./perl |
2 | |
3 | # Test // and friends. |
4 | |
5 | BEGIN { |
6 | chdir 't' if -d 't'; |
7 | @INC = '../lib'; |
8 | } |
9 | |
10 | package main; |
11 | require './test.pl'; |
12 | |
13 | plan( tests => 9 ); |
14 | |
15 | my($x); |
16 | |
17 | $x=1; |
18 | is($x // 0, 1, ' // : left-hand operand defined'); |
19 | |
20 | $x = undef; |
21 | is($x // 1, 1, ' // : left-hand operand undef'); |
22 | |
23 | $x=''; |
24 | is($x // 0, '', ' // : left-hand operand defined but empty'); |
25 | |
26 | $x=1; |
27 | is(($x err 0), 1, ' err: left-hand operand defined'); |
28 | |
29 | $x = undef; |
30 | is(($x err 1), 1, ' err: left-hand operand undef'); |
31 | |
32 | $x=''; |
33 | is(($x err 0), '', ' err: left-hand operand defined but empty'); |
34 | |
35 | $x=undef; |
36 | $x //= 1; |
37 | is($x, 1, ' //=: left-hand operand undefined'); |
38 | |
39 | $x //= 0; |
40 | is($x, 1, ' //=: left-hand operand defined'); |
41 | |
42 | $x = ''; |
43 | $x //= 0; |
44 | is($x, '', ' //=: left-hand operand defined but empty'); |