File: Util.t

package info (click to toggle)
libtest-simple-perl 1.302075-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 1,844 kB
  • ctags: 628
  • sloc: perl: 10,369; makefile: 2
file content (42 lines) | stat: -rw-r--r-- 848 bytes parent folder | download
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
use strict;
use warnings;

use Test2::Tools::Tiny;
use Test2::Util qw/
    try

    get_tid USE_THREADS

    pkg_to_file

    CAN_FORK
    CAN_THREAD
    CAN_REALLY_FORK

    IS_WIN32
/;

{
    for my $try (\&try, Test2::Util->can('_manual_try'), Test2::Util->can('_local_try')) {
        my ($ok, $err) = $try->(sub { die "xxx" });
        ok(!$ok, "cought exception");
        like($err, qr/xxx/, "expected exception");

        ($ok, $err) = $try->(sub { 0 });
        ok($ok,   "Success");
        ok(!$err, "no error");
    }
}

is(pkg_to_file('A::Package::Name'), 'A/Package/Name.pm', "Converted package to file");

# Make sure running them does not die
# We cannot really do much to test these.
CAN_THREAD();
CAN_FORK();
CAN_REALLY_FORK();
IS_WIN32();

is(IS_WIN32(), ($^O eq 'MSWin32') ? 1 : 0, "IS_WIN32 is correct ($^O)");

done_testing;