Integrate mainline
[p5sagit/p5-mst-13.2.git] / t / pragma / overload.t
index 2cf937b..d075062 100755 (executable)
@@ -494,7 +494,7 @@ test($c, "bareword");       # 135
   sub STORE { 
     my $obj = shift; 
     $#$obj = 1; 
-    @$obj->[0,1] = ('=', shift);
+    $obj->[1] = shift;
   }
 }
 
@@ -615,7 +615,7 @@ test($c, "bareword");       # 135
   sub STORE { 
     my $obj = shift; 
     $#$obj = 1; 
-    @$obj->[0,1] = ('=', shift);
+    $obj->[1] = shift;
   }
 }
 
@@ -1016,7 +1016,35 @@ unless ($aaa) {
   main::test($x+0 =~ /Recurse=ARRAY/);         # 221
 }
 
+# BugID 20010422.003
+package Foo;
+
+use overload
+  'bool' => sub { return !$_[0]->is_zero() || undef; }
+;
+sub is_zero
+  {
+  my $self = shift;
+  return $self->{var} == 0;
+  }
+
+sub new
+  {
+  my $class = shift;
+  my $self =  {};
+  $self->{var} = shift;
+  bless $self,$class;
+  }
+
+package main;
+
+use strict;
+
+my $r = Foo->new(8);
+$r = Foo->new(0);
 
+test(($r || 0) == 0); # 222
 
 # Last test is:
-sub last {221}
+sub last {222}