From: Dominic Dunlop Date: Fri, 14 Mar 2008 14:45:39 +0000 (+0100) Subject: Re: Tests failed on PPC64 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=02eafbe222bf49be10da28fb9c8c34dd786eaa91;p=p5sagit%2Fp5-mst-13.2.git Re: Tests failed on PPC64 Message-Id: <53E6407E-B87C-4D6A-A6E7-D842BDF30292@mac.com> Date: Fri, 14 Mar 2008 14:45:39 +0100 p4raw-id: //depot/perl@33594 --- diff --git a/t/op/reg_namedcapture.t b/t/op/reg_namedcapture.t index b9315cc..e3a8374 100644 --- a/t/op/reg_namedcapture.t +++ b/t/op/reg_namedcapture.t @@ -3,9 +3,13 @@ BEGIN { chdir 't' if -d 't'; @INC = '../lib'; + unless ( -r "$INC[0]/Errno.pm") { + print "1..0 # Skip: Errno.pm not yet available\n"; + exit 0; + } } -# WARNING: Do not use anymodules as part of this test code. +# WARNING: Do not directly use any modules as part of this test code. # We could get action at a distance that would invalidate the tests. print "1..2\n"; @@ -15,6 +19,8 @@ print "1..2\n"; 'X'=~/(?X)/; print eval '*X{HASH}{X} || 1' ? "" :"not ","ok ",++$test,"\n"; -# And since its a similar case we check %! as well +# And since it's a similar case we check %! as well. Note that +# this can't be done until ../lib/Errno.pm is in place, as the +# glob hits $!, which needs that module. *Y = *!; print 0 sub{"string value of obj"}; - - use overload "~~" => sub { - my ($self, $other, $reversed) = @_; - if ($reversed) { - $self->{left} = $other; - $self->{right} = $self; - $self->{reversed} = 1; - } else { - $self->{left} = $self; - $self->{right} = $other; - $self->{reversed} = 0; - } - $self->{called} = 1; - return $self->{retval}; - }; +SKIP: { + skip "Scalar/Util.pm not yet available", 20 + unless -r "$INC[0]/Scalar/Util.pm"; + # Test overloading + { package OverloadTest; + + use overload '""' => sub{"string value of obj"}; + + use overload "~~" => sub { + my ($self, $other, $reversed) = @_; + if ($reversed) { + $self->{left} = $other; + $self->{right} = $self; + $self->{reversed} = 1; + } else { + $self->{left} = $self; + $self->{right} = $other; + $self->{reversed} = 0; + } + $self->{called} = 1; + return $self->{retval}; + }; - sub new { - my ($pkg, $retval) = @_; - bless { - called => 0, - retval => $retval, - }, $pkg; - } -} - -{ - my $test = "Overloaded obj in given (true)"; - my $obj = OverloadTest->new(1); - my $matched; - given($obj) { - when ("other arg") {$matched = 1} - default {$matched = 0} - } + sub new { + my ($pkg, $retval) = @_; + bless { + called => 0, + retval => $retval, + }, $pkg; + } + } + + { + my $test = "Overloaded obj in given (true)"; + my $obj = OverloadTest->new(1); + my $matched; + given($obj) { + when ("other arg") {$matched = 1} + default {$matched = 0} + } - is($obj->{called}, 1, "$test: called"); - ok($matched, "$test: matched"); - is($obj->{left}, "string value of obj", "$test: left"); - is($obj->{right}, "other arg", "$test: right"); - ok(!$obj->{reversed}, "$test: not reversed"); -} - -{ - my $test = "Overloaded obj in given (false)"; - my $obj = OverloadTest->new(0); - my $matched; - given($obj) { - when ("other arg") {$matched = 1} - } + is($obj->{called}, 1, "$test: called"); + ok($matched, "$test: matched"); + is($obj->{left}, "string value of obj", "$test: left"); + is($obj->{right}, "other arg", "$test: right"); + ok(!$obj->{reversed}, "$test: not reversed"); + } + + { + my $test = "Overloaded obj in given (false)"; + my $obj = OverloadTest->new(0); + my $matched; + given($obj) { + when ("other arg") {$matched = 1} + } - is($obj->{called}, 1, "$test: called"); - ok(!$matched, "$test: not matched"); - is($obj->{left}, "string value of obj", "$test: left"); - is($obj->{right}, "other arg", "$test: right"); - ok(!$obj->{reversed}, "$test: not reversed"); -} - -{ - my $test = "Overloaded obj in when (true)"; - my $obj = OverloadTest->new(1); - my $matched; - given("topic") { - when ($obj) {$matched = 1} - default {$matched = 0} - } + is($obj->{called}, 1, "$test: called"); + ok(!$matched, "$test: not matched"); + is($obj->{left}, "string value of obj", "$test: left"); + is($obj->{right}, "other arg", "$test: right"); + ok(!$obj->{reversed}, "$test: not reversed"); + } + + { + my $test = "Overloaded obj in when (true)"; + my $obj = OverloadTest->new(1); + my $matched; + given("topic") { + when ($obj) {$matched = 1} + default {$matched = 0} + } - is($obj->{called}, 1, "$test: called"); - ok($matched, "$test: matched"); - is($obj->{left}, "topic", "$test: left"); - is($obj->{right}, "string value of obj", "$test: right"); - ok($obj->{reversed}, "$test: reversed"); -} - -{ - my $test = "Overloaded obj in when (false)"; - my $obj = OverloadTest->new(0); - my $matched; - given("topic") { - when ($obj) {$matched = 1} - default {$matched = 0} - } + is($obj->{called}, 1, "$test: called"); + ok($matched, "$test: matched"); + is($obj->{left}, "topic", "$test: left"); + is($obj->{right}, "string value of obj", "$test: right"); + ok($obj->{reversed}, "$test: reversed"); + } + + { + my $test = "Overloaded obj in when (false)"; + my $obj = OverloadTest->new(0); + my $matched; + given("topic") { + when ($obj) {$matched = 1} + default {$matched = 0} + } - is($obj->{called}, 1, "$test: called"); - ok(!$matched, "$test: not matched"); - is($obj->{left}, "topic", "$test: left"); - is($obj->{right}, "string value of obj", "$test: right"); - ok($obj->{reversed}, "$test: reversed"); + is($obj->{called}, 1, "$test: called"); + ok(!$matched, "$test: not matched"); + is($obj->{left}, "topic", "$test: left"); + is($obj->{right}, "string value of obj", "$test: right"); + ok($obj->{reversed}, "$test: reversed"); + } } - # Okay, that'll do for now. The intricacies of the smartmatch # semantics are tested in t/op/smartmatch.t __END__