File: 20disabled.t

package info (click to toggle)
libcarp-assert-perl 0.20-2
  • links: PTS, VCS
  • area: main
  • in suites: lenny, squeeze, wheezy
  • size: 84 kB
  • ctags: 16
  • sloc: perl: 291; makefile: 35
file content (44 lines) | stat: -rw-r--r-- 769 bytes parent folder | download | duplicates (5)
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
#!/usr/bin/perl -w

# Test with assert off.


use strict;
use Test::More tests => 25;


use Carp::Assert qw(:NDEBUG);


my $tests = <<'END_OF_TESTS';
eval { assert(1==0) if DEBUG; };
is $@, '';


eval { assert(1==0); };
is $@, '';


eval { should('this', 'moofer') if DEBUG };
is $@, '';


eval { shouldnt('this', 'this') };
is $@, '';
END_OF_TESTS


my @disable_code = (
    "use Carp::Assert qw(:NDEBUG);",
    "no Carp::Assert;",
    'BEGIN { $ENV{NDEBUG} = 1; }  use Carp::Assert;',
    'BEGIN { $ENV{PERL_NDEBUG} = 1; }  use Carp::Assert;',
    'BEGIN { $ENV{NDEBUG} = 0;  $ENV{PERL_NDEBUG} = 1; } use Carp::Assert;'
);

for my $code (@disable_code) {
    local %ENV = %ENV;
    delete @ENV{qw(PERL_NDEBUG NDEBUG)};
    eval $code . "\n" . $tests;
    is $@, '';
}