File: 02_assert_disabled.t

package info (click to toggle)
libsyntax-keyword-assert-perl 0.16-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 196 kB
  • sloc: perl: 98; pascal: 69; makefile: 3
file content (33 lines) | stat: -rw-r--r-- 571 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
use Test2::V0;

BEGIN {
    $ENV{PERL_ASSERT_ENABLED} = !!0
}

use Syntax::Keyword::Assert;

subtest 'Test `assert` keyword when $ENV{PERL_ASSERT_ENABLED} is falsy' => sub {
    ok lives {
        assert( 0 );
    };

    ok lives {
        assert( 1 );
    };

    my $hello = sub {
        my ($message) = @_;
        assert( defined $message );
        return "Hello, $message!";
    };

    ok lives {
        $hello->('world');
    };

    like warning {
        $hello->(undef);
    }, qr/\AUse of uninitialized value \$message in concatenation/;
};

done_testing;