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 ) { |
30e302f8 |
5 | print "1..0 # Skipped Test requires qr//\n"; |
3f2ec160 |
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 | |
33459055 |
25 | |
3f2ec160 |
26 | # Can't use Test.pm, that's a 5.005 thing. |
27 | package My::Test; |
28 | |
b1ddf169 |
29 | # This has to be a require or else the END block below runs before |
30 | # Test::Builder's own and the ending diagnostics don't come out right. |
31 | require Test::Builder; |
32 | my $TB = Test::Builder->create; |
33 | $TB->plan(tests => 2); |
34 | |
35 | |
36 | require Test::Simple::Catch; |
37 | my($out, $err) = Test::Simple::Catch::caught(); |
38 | local $ENV{HARNESS_ACTIVE} = 0; |
3f2ec160 |
39 | |
40 | |
41 | package main; |
d020a79a |
42 | |
3f2ec160 |
43 | require Test::More; |
3f2ec160 |
44 | Test::More->import(tests => 1); |
45 | |
46 | eval q{ like( "foo", qr/that/, 'is foo like that' ); }; |
47 | |
48 | |
49 | END { |
b1ddf169 |
50 | $TB->is_eq($$out, <<OUT, 'failing output'); |
3f2ec160 |
51 | 1..1 |
52 | not ok 1 - is foo like that |
53 | OUT |
54 | |
55 | my $err_re = <<ERR; |
b1ddf169 |
56 | # Failed test 'is foo like that' |
b7f9bbeb |
57 | # at .* line 1\. |
3f2ec160 |
58 | # 'foo' |
59 | # doesn't match '\\(\\?-xism:that\\)' |
30e302f8 |
60 | # Looks like you failed 1 test of 1\\. |
3f2ec160 |
61 | ERR |
62 | |
63 | |
b1ddf169 |
64 | $TB->like($$err, qr/^$err_re$/, 'failing errors'); |
3f2ec160 |
65 | |
66 | exit(0); |
67 | } |