Change 13092 by jhi@alpha on 2001/11/19 14:05:21

        Subject: [PATCH MANIFEST t/op/or.t] Double FETCH test
        From: Michael G Schwern <[EMAIL PROTECTED]>
        Date: Mon, 19 Nov 2001 03:42:56 -0500
        Message-ID: <20011119034256.I786@blackrider>

Affected files ...

.... //depot/perl/MANIFEST#625 edit
.... //depot/perl/t/op/or.t#1 add

Differences ...

==== //depot/perl/MANIFEST#625 (text) ====
Index: perl/MANIFEST
--- perl/MANIFEST.~1~   Mon Nov 19 07:15:05 2001
+++ perl/MANIFEST       Mon Nov 19 07:15:05 2001
@@ -2182,6 +2182,7 @@
 t/op/nothr5005.t               local @_ test which does not work under use5005threads
 t/op/numconvert.t              See if accessing fields does not change numeric values
 t/op/oct.t                     See if oct and hex work
+t/op/or.t                       See if || works in weird situations
 t/op/ord.t                     See if ord works
 t/op/override.t                        See if operator overriding works
 t/op/pack.t                    See if pack and unpack work

==== //depot/perl/t/op/or.t#1 (text) ====
Index: perl/t/op/or.t
--- perl/t/op/or.t.~1~  Mon Nov 19 07:15:05 2001
+++ perl/t/op/or.t      Mon Nov 19 07:15:05 2001
@@ -0,0 +1,68 @@
+#!./perl
+
+# Test || in weird situations.
+
+BEGIN {
+    chdir 't' if -d 't';
+    @INC = '../lib';
+}
+
+
+package Countdown;
+
+sub TIESCALAR {
+  my $class = shift;
+  my $instance = shift || undef;
+  return bless \$instance => $class;
+}
+
+sub FETCH {
+  print "# FETCH!  ${$_[0]}\n";
+  return ${$_[0]}--;
+}
+
+
+package main;
+require './test.pl';
+
+plan( tests => 8 );
+
+
+my ($a, $b, $c);
+
+$! = 1;
+$a = $!;
+my $a_str = sprintf "%s", $a;
+my $a_num = sprintf "%d", $a;
+
+$c = $a || $b;
+
+is($c, $a_str);
+is($c+0, $a_num);   # force numeric context.
+
+$a =~ /./g or die "Match failed for some reason"; # Make $a magic
+
+$c = $a || $b;
+
+is($c, $a_str);
+is($c+0, $a_num);   # force numeric context.
+
+my $val = 3;
+
+$c = $val || $b;
+is($c, 3);
+
+tie $a, 'Countdown', $val;
+
+$c = $a;
+is($c, 3,       'Single FETCH on tied scalar');
+
+$c = $a;
+is($c, 2,       '   $tied = $var');
+
+$c = $a || $b;
+
+{
+    local $TODO = 'Double FETCH';
+    is($c, 1,   '   $tied || $var');
+}
End of Patch.

Reply via email to