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