1# qr// was introduced in 5.004-devel. Skip this test if we're not 2# of high enough version. 3BEGIN { 4 if( $] < 5.005 ) { 5 print "1..0\n"; 6 exit(0); 7 } 8} 9 10BEGIN { 11 if( $ENV{PERL_CORE} ) { 12 chdir 't'; 13 @INC = ('../lib', 'lib'); 14 } 15 else { 16 unshift @INC, 't/lib'; 17 } 18} 19 20# There was a bug with like() involving a qr// not failing properly. 21# This tests against that. 22 23use strict; 24 25require Test::Simple::Catch; 26my($out, $err) = Test::Simple::Catch::caught(); 27 28 29# Can't use Test.pm, that's a 5.005 thing. 30package My::Test; 31 32print "1..2\n"; 33 34my $test_num = 1; 35# Utility testing functions. 36sub ok ($;$) { 37 my($test, $name) = @_; 38 my $ok = ''; 39 $ok .= "not " unless $test; 40 $ok .= "ok $test_num"; 41 $ok .= " - $name" if defined $name; 42 $ok .= "\n"; 43 print $ok; 44 $test_num++; 45} 46 47 48package main; 49 50require Test::More; 51Test::More->import(tests => 1); 52 53eval q{ like( "foo", qr/that/, 'is foo like that' ); }; 54 55 56END { 57 My::Test::ok($$out eq <<OUT, 'failing output'); 581..1 59not ok 1 - is foo like that 60OUT 61 62 my $err_re = <<ERR; 63# Failed test \\(.*\\) 64# 'foo' 65# doesn't match '\\(\\?-xism:that\\)' 66# Looks like you failed 1 tests of 1\\. 67ERR 68 69 70 My::Test::ok($$err =~ /^$err_re$/, 'failing errors'); 71 72 exit(0); 73} 74