1use strict;
2use warnings;
3use Test::More;
4
5
6my $want = 0;
7my $got  = 0;
8
9cmp_ok($got, 'eq', $want, "Passes on correct comparison");
10
11my ($res, @ok, @diag, @warn);
12{
13    no warnings 'redefine';
14    local *Test::Builder::ok = sub {
15        my ($tb, $ok, $name) = @_;
16        push @ok => $ok;
17        return $ok;
18    };
19    local *Test::Builder::diag = sub {
20        my ($tb, @d) = @_;
21        push @diag => @d;
22    };
23    local $SIG{__WARN__} = sub {
24        push @warn => @_;
25    };
26    $res = cmp_ok($got, '#eq', $want, "You shall not pass!");
27}
28
29ok(!$res, "Did not pass");
30
31is(@ok, 1, "1 result");
32ok(!$ok[0], "result is false");
33
34# We only care that it mentions a syntax error.
35like(join("\n" => @diag), qr/syntax error at \(eval in cmp_ok\)/, "Syntax error");
36
37# We are not going to inspect the warning because it is not super predictable,
38# and changes with eval specifics.
39ok(@warn, "We got warnings");
40
41done_testing;
42