Commit | Line | Data |
---|---|---|
ccbd73a4 | 1 | #!/usr/bin/perl -w |
3f2ec160 | 2 | |
a9153838 MS |
3 | BEGIN { |
4 | if( $ENV{PERL_CORE} ) { | |
5 | chdir 't'; | |
6 | @INC = ('../lib', 'lib'); | |
7 | } | |
8 | else { | |
9 | unshift @INC, 't/lib'; | |
10 | } | |
11 | } | |
3f2ec160 JH |
12 | |
13 | # There was a bug with like() involving a qr// not failing properly. | |
14 | # This tests against that. | |
15 | ||
33459055 | 16 | use strict; |
33459055 | 17 | |
33459055 | 18 | |
3f2ec160 JH |
19 | # Can't use Test.pm, that's a 5.005 thing. |
20 | package My::Test; | |
21 | ||
b1ddf169 RGS |
22 | # This has to be a require or else the END block below runs before |
23 | # Test::Builder's own and the ending diagnostics don't come out right. | |
24 | require Test::Builder; | |
25 | my $TB = Test::Builder->create; | |
ccbd73a4 | 26 | $TB->plan(tests => 4); |
b1ddf169 RGS |
27 | |
28 | ||
29 | require Test::Simple::Catch; | |
30 | my($out, $err) = Test::Simple::Catch::caught(); | |
31 | local $ENV{HARNESS_ACTIVE} = 0; | |
3f2ec160 JH |
32 | |
33 | ||
34 | package main; | |
d020a79a | 35 | |
3f2ec160 | 36 | require Test::More; |
3f2ec160 JH |
37 | Test::More->import(tests => 1); |
38 | ||
ccbd73a4 SP |
39 | { |
40 | eval q{ like( "foo", qr/that/, 'is foo like that' ); }; | |
3f2ec160 | 41 | |
ccbd73a4 | 42 | $TB->is_eq($out->read, <<OUT, 'failing output'); |
3f2ec160 JH |
43 | 1..1 |
44 | not ok 1 - is foo like that | |
45 | OUT | |
46 | ||
47 | my $err_re = <<ERR; | |
b1ddf169 | 48 | # Failed test 'is foo like that' |
b7f9bbeb | 49 | # at .* line 1\. |
3f2ec160 JH |
50 | # 'foo' |
51 | # doesn't match '\\(\\?-xism:that\\)' | |
3f2ec160 JH |
52 | ERR |
53 | ||
ccbd73a4 SP |
54 | $TB->like($err->read, qr/^$err_re$/, 'failing errors'); |
55 | } | |
3f2ec160 | 56 | |
ccbd73a4 | 57 | { |
3e887aae | 58 | # line 59 |
ccbd73a4 SP |
59 | like("foo", "not a regex"); |
60 | $TB->is_eq($out->read, <<OUT); | |
61 | not ok 2 | |
62 | OUT | |
3f2ec160 | 63 | |
ccbd73a4 | 64 | $TB->is_eq($err->read, <<OUT); |
3e887aae | 65 | # Failed test at $0 line 59. |
ccbd73a4 SP |
66 | # 'not a regex' doesn't look much like a regex to me. |
67 | OUT | |
68 | ||
69 | } | |
70 | ||
71 | END { | |
72 | # Test::More thinks it failed. Override that. | |
73 | exit(scalar grep { !$_ } $TB->summary); | |
3f2ec160 | 74 | } |