summaryrefslogtreecommitdiff
path: root/cpan/Test-Simple/t/test_use_ok.t
blob: 0b4b9a7d3579611f0546a71b4e69eb85c6014e07 (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
use strict;
use Test::More;
use ok;
use ok 'strict';
use ok 'Test::More';
use ok 'ok';

my $class = 'Test::Builder';
BEGIN {
    ok(!$class, '$class is declared, but not yet set');


    my $success = eval 'use ok $class';
    my $error = $@;

    ok(!$success, "Threw an exception");
    like(
        $error,
        qr/^'use ok' called with an empty argument, did you try to use a package name from an uninitialized variable\?/,
        "Threw expected exception"
    );



    $success = eval 'use ok $class, "xxx"';
    $error = $@;

    ok(!$success, "Threw an exception");
    like(
        $error,
        qr/^'use ok' called with an empty argument, did you try to use a package name from an uninitialized variable\?/,
        "Threw expected exception when arguments are added"
    );
}

my $class2;
BEGIN {$class2 = 'Test::Builder'};
use ok $class2;

done_testing;