From: Nicholas Clark Date: Wed, 16 Apr 2008 15:15:20 +0000 (+0000) Subject: Use like() rather than is() to get better failure diagnostics. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2f90724352f52b809834d375ef5bab2c674fdad4;p=p5sagit%2Fp5-mst-13.2.git Use like() rather than is() to get better failure diagnostics. (One step beyond Jarkko's change 15735) p4raw-id: //depot/perl@33700 --- diff --git a/t/op/method.t b/t/op/method.t index aaf29be..46c4642 100755 --- a/t/op/method.t +++ b/t/op/method.t @@ -183,23 +183,23 @@ is(defined(@{"unknown_package::ISA"}) ? "defined" : "undefined", "undefined"); # test error messages if method loading fails -is(do { eval '$e = bless {}, "E::A"; E::A->foo()'; - $@ =~ /^\QCan't locate object method "foo" via package "E::A" at/ ? 1 : $@}, 1); -is(do { eval '$e = bless {}, "E::B"; $e->foo()'; - $@ =~ /^\QCan't locate object method "foo" via package "E::B" at/ ? 1 : $@}, 1); -is(do { eval 'E::C->foo()'; - $@ =~ /^\QCan't locate object method "foo" via package "E::C" (perhaps / ? 1 : $@}, 1); - -is(do { eval 'UNIVERSAL->E::D::foo()'; - $@ =~ /^\QCan't locate object method "foo" via package "E::D" (perhaps / ? 1 : $@}, 1); -is(do { eval '$e = bless {}, "UNIVERSAL"; $e->E::E::foo()'; - $@ =~ /^\QCan't locate object method "foo" via package "E::E" (perhaps / ? 1 : $@}, 1); +eval '$e = bless {}, "E::A"; E::A->foo()'; +like ($@, qr/^\QCan't locate object method "foo" via package "E::A" at/); +eval '$e = bless {}, "E::B"; $e->foo()'; +like ($@, qr/^\QCan't locate object method "foo" via package "E::B" at/); +eval 'E::C->foo()'; +like ($@, qr/^\QCan't locate object method "foo" via package "E::C" (perhaps /); + +eval 'UNIVERSAL->E::D::foo()'; +like ($@, qr/^\QCan't locate object method "foo" via package "E::D" (perhaps /); +eval '$e = bless {}, "UNIVERSAL"; $e->E::E::foo()'; +like ($@, qr/^\QCan't locate object method "foo" via package "E::E" (perhaps /); $e = bless {}, "E::F"; # force package to exist -is(do { eval 'UNIVERSAL->E::F::foo()'; - $@ =~ /^\QCan't locate object method "foo" via package "E::F" at/ ? 1 : $@}, 1); -is(do { eval '$e = bless {}, "UNIVERSAL"; $e->E::F::foo()'; - $@ =~ /^\QCan't locate object method "foo" via package "E::F" at/ ? 1 : $@}, 1); +eval 'UNIVERSAL->E::F::foo()'; +like ($@, qr/^\QCan't locate object method "foo" via package "E::F" at/); +eval '$e = bless {}, "UNIVERSAL"; $e->E::F::foo()'; +like ($@, qr/^\QCan't locate object method "foo" via package "E::F" at/); # TODO: we need some tests for the SUPER:: pseudoclass