From: Jan Dubois Date: Mon, 3 Apr 2006 18:06:24 +0000 (-0700) Subject: threads.pm should overload != operator X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=67698975b531393432f9df883ede410d0a406d7a;p=p5sagit%2Fp5-mst-13.2.git threads.pm should overload != operator From: "Jan Dubois" Message-ID: <02fc01c65783$fe4820f0$2217a8c0@candy> p4raw-id: //depot/perl@27712 --- diff --git a/ext/threads/t/basic.t b/ext/threads/t/basic.t index 3a9ab17..8892bce 100755 --- a/ext/threads/t/basic.t +++ b/ext/threads/t/basic.t @@ -15,7 +15,7 @@ BEGIN { use ExtUtils::testlib; -BEGIN { $| = 1; print "1..30\n" }; +BEGIN { $| = 1; print "1..32\n" }; use threads; @@ -131,28 +131,31 @@ my $thr1 = threads->create(sub {}); my $thr2 = threads->create(sub {}); my $thr3 = threads->object($thr1->tid()); -ok(20, $thr1 != $thr2, 'Treads not equal'); -ok(21, $thr1 == $thr3, 'Threads equal'); +# Make sure both overloaded '==' and '!=' are working correctly +ok(20, $thr1 != $thr2, 'Treads not equal'); +ok(21, !($thr1 == $thr2), 'Treads not equal'); +ok(22, $thr1 == $thr3, 'Threads equal'); +ok(23, !($thr1 != $thr3), 'Threads equal'); -ok(22, $thr1->_handle(), 'Handle method'); -ok(23, $thr2->_handle(), 'Handle method'); +ok(24, $thr1->_handle(), 'Handle method'); +ok(25, $thr2->_handle(), 'Handle method'); -ok(24, threads->object($thr1->tid())->tid() == 11, 'Object method'); -ok(25, threads->object($thr2->tid())->tid() == 12, 'Object method'); +ok(26, threads->object($thr1->tid())->tid() == 11, 'Object method'); +ok(27, threads->object($thr2->tid())->tid() == 12, 'Object method'); $thr1->join(); $thr2->join(); -my $sub = sub { ok(26, shift() == 1, "Test code ref"); }; +my $sub = sub { ok(28, shift() == 1, "Test code ref"); }; threads->create($sub, 1)->join(); my $thrx = threads->object(99); -ok(27, ! defined($thrx), 'No object'); +ok(29, ! defined($thrx), 'No object'); $thrx = threads->object(); -ok(28, ! defined($thrx), 'No object'); +ok(30, ! defined($thrx), 'No object'); $thrx = threads->object(undef); -ok(29, ! defined($thrx), 'No object'); +ok(31, ! defined($thrx), 'No object'); $thrx = threads->object(0); -ok(30, ! defined($thrx), 'No object'); +ok(32, ! defined($thrx), 'No object'); # EOF diff --git a/ext/threads/threads.pm b/ext/threads/threads.pm index 78d328e..25916f4 100755 --- a/ext/threads/threads.pm +++ b/ext/threads/threads.pm @@ -29,6 +29,7 @@ EOF use overload '==' => \&equal, + '!=' => sub { !equal(@_) }, 'fallback' => 1; BEGIN { @@ -38,7 +39,7 @@ BEGIN { if($threads::shared::threads_shared); } -our $VERSION = '1.18'; +our $VERSION = '1.18_01'; # Load the XS code