diff options
author | Jarkko Hietaniemi <jhi@iki.fi> | 2001-09-06 01:41:03 +0000 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2001-09-06 01:41:03 +0000 |
commit | d020a79abca8a7921ca8873afa967fc2b6628b7d (patch) | |
tree | c295dd83c8c00711727cddad0ecd7f5ad8b5b1d3 /lib/Test/Simple/t/fail-like.t | |
parent | 5c7bc39a40ac58dc19b5fe33db234cae1e26293e (diff) | |
download | perl-d020a79abca8a7921ca8873afa967fc2b6628b7d.tar.gz |
Test-Simple syncup from Schwern.
p4raw-id: //depot/perl@11905
Diffstat (limited to 'lib/Test/Simple/t/fail-like.t')
-rw-r--r-- | lib/Test/Simple/t/fail-like.t | 65 |
1 files changed, 65 insertions, 0 deletions
diff --git a/lib/Test/Simple/t/fail-like.t b/lib/Test/Simple/t/fail-like.t new file mode 100644 index 0000000000..dee34e6845 --- /dev/null +++ b/lib/Test/Simple/t/fail-like.t @@ -0,0 +1,65 @@ +# qr// was introduced in 5.004-devel. Skip this test if we're not +# of high enough version. +BEGIN { + if( $] < 5.005 ) { + print "1..0\n"; + exit(0); + } +} + + +# There was a bug with like() involving a qr// not failing properly. +# This tests against that. + +use strict; + +# Can't use Test.pm, that's a 5.005 thing. +package My::Test; + +print "1..2\n"; + +my $test_num = 1; +# Utility testing functions. +sub ok ($;$) { + my($test, $name) = @_; + my $ok = ''; + $ok .= "not " unless $test; + $ok .= "ok $test_num"; + $ok .= " - $name" if defined $name; + $ok .= "\n"; + print $ok; + $test_num++; +} + + +package main; + +require Test::More; + +push @INC, 't/lib'; +require Test::Simple::Catch::More; +my($out, $err) = Test::Simple::Catch::More::caught(); + +Test::More->import(tests => 1); + +eval q{ like( "foo", qr/that/, 'is foo like that' ); }; + + +END { + My::Test::ok($$out eq <<OUT, 'failing output'); +1..1 +not ok 1 - is foo like that +OUT + + my $err_re = <<ERR; +# Failed test \\(.*\\) +# 'foo' +# doesn't match '\\(\\?-xism:that\\)' +# Looks like you failed 1 tests of 1\\. +ERR + + + My::Test::ok($$err =~ /^$err_re$/, 'failing errors'); + + exit(0); +} |