File: strictures.t

package info (click to toggle)
libmoo-perl 2.004004-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 844 kB
  • sloc: perl: 2,449; makefile: 6
file content (36 lines) | stat: -rw-r--r-- 827 bytes parent folder | download | duplicates (3)
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
BEGIN { delete $ENV{MOO_FATAL_WARNINGS} }
use strict;
use warnings;
use Test::More;

$INC{'strictures.pm'} = __FILE__;
my $strictures = 0;
my $version;
sub strictures::VERSION {
  $version = $_[1];
  2;;
}
sub strictures::import {
  $strictures++;
  strict->import;
  warnings->import(FATAL => 'all');
}

local $SIG{__WARN__} = sub {};
eval q{
  use Moo::_strictures;
  0 + "string";
};
is $strictures, 0, 'strictures not imported without MOO_FATAL_WARNINGS';
is $@, '', 'warnings not fatal without MOO_FATAL_WARNINGS';

$ENV{MOO_FATAL_WARNINGS} = 1;
eval q{
  use Moo::_strictures;
  0 + "string";
};
is $strictures, 1, 'strictures imported with MOO_FATAL_WARNINGS';
is $version, 2, 'strictures version 2 requested with MOO_FATAL_WARNINGS';
like $@, qr/isn't numeric/, 'warnings fatal with MOO_FATAL_WARNINGS';

done_testing;