summaryrefslogtreecommitdiff
path: root/cpan/Test-Simple/t/Modern/NotTB15.t
blob: dda51ae8a26e3d6cefb105f00ba66fea4a296f5b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/perl
use strict;
use warnings;

use Test::More 'modern';

# This is just a list of method Test::Builder current does not have that Test::Builder 1.5 does.
my @TB15_METHODS = qw{
    _file_and_line _join_message _make_default _my_exit _reset_todo_state
    _result_to_hash _results _todo_state formatter history in_subtest in_test
    no_change_exit_code post_event post_result set_formatter set_plan test_end
    test_exit_code test_start test_state
};

for my $method (qw/foo bar baz/) {
    my $success = !eval { Test::Builder->$method; 1 }; my $line = __LINE__;
    my $error = $@;
    ok($success, "Threw an exception ($method)");
    is(
        $error,
        qq{Can't locate object method "$method" via package "Test::Builder" at } . __FILE__ . " line $line\n",
        "Did not auto-create random sub ($method)"
    );
}

my $file = __FILE__;
for my $method (@TB15_METHODS) {
    my $success = !eval { Test::Builder->$method; 1 }; my $line = __LINE__;
    my $error = $@;

    ok($success, "Threw an exception ($method)");

    is($error, <<"    EOT", "Got expected error ($method)");
Can't locate object method "$method" via package "Test::Builder" at $file line $line

    *************************************************************************
    '$method' is a Test::Builder 1.5 method. Test::Builder 1.5 is a dead branch.
    You need to update your code so that it no longer treats Test::Builders
    over a specific version number as anything special.

    See: http://blogs.perl.org/users/chad_exodist_granum/2014/03/testmore---new-maintainer-also-stop-version-checking.html
    *************************************************************************
    EOT
}

done_testing;