1*0Sstevel@tonic-gate#!./perl 2*0Sstevel@tonic-gate 3*0Sstevel@tonic-gate# Test || in weird situations. 4*0Sstevel@tonic-gate 5*0Sstevel@tonic-gateBEGIN { 6*0Sstevel@tonic-gate chdir 't' if -d 't'; 7*0Sstevel@tonic-gate @INC = '../lib'; 8*0Sstevel@tonic-gate} 9*0Sstevel@tonic-gate 10*0Sstevel@tonic-gate 11*0Sstevel@tonic-gatepackage Countdown; 12*0Sstevel@tonic-gate 13*0Sstevel@tonic-gatesub TIESCALAR { 14*0Sstevel@tonic-gate my $class = shift; 15*0Sstevel@tonic-gate my $instance = shift || undef; 16*0Sstevel@tonic-gate return bless \$instance => $class; 17*0Sstevel@tonic-gate} 18*0Sstevel@tonic-gate 19*0Sstevel@tonic-gatesub FETCH { 20*0Sstevel@tonic-gate print "# FETCH! ${$_[0]}\n"; 21*0Sstevel@tonic-gate return ${$_[0]}--; 22*0Sstevel@tonic-gate} 23*0Sstevel@tonic-gate 24*0Sstevel@tonic-gate 25*0Sstevel@tonic-gatepackage main; 26*0Sstevel@tonic-gaterequire './test.pl'; 27*0Sstevel@tonic-gate 28*0Sstevel@tonic-gateplan( tests => 8 ); 29*0Sstevel@tonic-gate 30*0Sstevel@tonic-gate 31*0Sstevel@tonic-gatemy ($a, $b, $c); 32*0Sstevel@tonic-gate 33*0Sstevel@tonic-gate$! = 1; 34*0Sstevel@tonic-gate$a = $!; 35*0Sstevel@tonic-gatemy $a_str = sprintf "%s", $a; 36*0Sstevel@tonic-gatemy $a_num = sprintf "%d", $a; 37*0Sstevel@tonic-gate 38*0Sstevel@tonic-gate$c = $a || $b; 39*0Sstevel@tonic-gate 40*0Sstevel@tonic-gateis($c, $a_str); 41*0Sstevel@tonic-gateis($c+0, $a_num); # force numeric context. 42*0Sstevel@tonic-gate 43*0Sstevel@tonic-gate$a =~ /./g or die "Match failed for some reason"; # Make $a magic 44*0Sstevel@tonic-gate 45*0Sstevel@tonic-gate$c = $a || $b; 46*0Sstevel@tonic-gate 47*0Sstevel@tonic-gateis($c, $a_str); 48*0Sstevel@tonic-gateis($c+0, $a_num); # force numeric context. 49*0Sstevel@tonic-gate 50*0Sstevel@tonic-gatemy $val = 3; 51*0Sstevel@tonic-gate 52*0Sstevel@tonic-gate$c = $val || $b; 53*0Sstevel@tonic-gateis($c, 3); 54*0Sstevel@tonic-gate 55*0Sstevel@tonic-gatetie $a, 'Countdown', $val; 56*0Sstevel@tonic-gate 57*0Sstevel@tonic-gate$c = $a; 58*0Sstevel@tonic-gateis($c, 3, 'Single FETCH on tied scalar'); 59*0Sstevel@tonic-gate 60*0Sstevel@tonic-gate$c = $a; 61*0Sstevel@tonic-gateis($c, 2, ' $tied = $var'); 62*0Sstevel@tonic-gate 63*0Sstevel@tonic-gate$c = $a || $b; 64*0Sstevel@tonic-gate 65*0Sstevel@tonic-gate{ 66*0Sstevel@tonic-gate local $TODO = 'Double FETCH'; 67*0Sstevel@tonic-gate is($c, 1, ' $tied || $var'); 68*0Sstevel@tonic-gate} 69