3 # Test || in weird situations.
15 my $instance = shift || undef;
16 return bless \$instance => $class;
20 print "# FETCH! ${$_[0]}\n";
35 my $a_str = sprintf "%s", $a;
36 my $a_num = sprintf "%d", $a;
40 is($c, $a_str, "comparison of string equality");
41 is($c+0, $a_num, "comparison of numeric equality"); # force numeric context.
43 $a =~ /./g or die "Match failed for some reason"; # Make $a magic
47 is($c, $a_str, "comparison of string equality");
48 is($c+0, $a_num, "comparison of numeric equality"); # force numeric context.
53 is($c, 3, "|| short-circuited as expected");
55 tie $a, 'Countdown', $val;
58 is($c, 3, 'Single FETCH on tied scalar');
61 is($c, 2, ' $tied = $var');
66 local $TODO = 'Double FETCH';
67 is($c, 1, ' $tied || $var');
71 for (pos $x || pos $y) {
74 is(pos($y) || $@, 1, "|| propagates lvaluish context to its rhs");
78 for (pos $x || pos $y) {
81 is(pos($x) || $@, 2, "|| propagates lvaluish context to its lhs");
83 for ($h{k} || $h{l}) {}
85 "|| does not propagate lvaluish cx to a subscript on its lhs");
87 "|| does not propagate lvaluish cx to a subscript on its rhs");
93 # Well, really testing OP_DOR I guess
94 unless ($aa || $bb // $cc) {
97 is($res, 0, "res is 0 after mixed OR/DOR");
100 unless ($aa // $bb || $cc) {
103 is($res, 0, "res is 0 after mixed DOR/OR");