use different mechanism for disabling some warnings
[p5sagit/strictures.git] / t / strictures.t
CommitLineData
967e00d7 1BEGIN { $ENV{PERL_STRICTURES_EXTRA} = 0 }
5ab06a4d 2
eae006ee 3use Test::More qw(no_plan);
4
967e00d7 5our ($hints, $warning_bits);
eae006ee 6
967e00d7 7sub capture_hints {
8 # ignore lexicalized hints
9 $hints = $^H & ~ 0x20000;
10 $warning_bits = defined ${^WARNING_BITS} ? (unpack "H*", ${^WARNING_BITS}) : undef;
11}
eae006ee 12
967e00d7 13sub test_hints {
14 my $name = shift;
15 my $want_hints = $hints;
16 my $want_bits = $warning_bits;
17 capture_hints;
18 is($hints, $want_hints, "Hints ok for $name");
19 is($warning_bits, $want_bits, "Warnings ok for $name");
eae006ee 20}
21
22{
23 use strict;
24 use warnings FATAL => 'all';
967e00d7 25 BEGIN { capture_hints }
eae006ee 26}
27
967e00d7 28{
29 use strictures 1;
30 BEGIN { test_hints "version 1" }
eae006ee 31}
32
23c0b85d 33{
34 use strict;
35 BEGIN {
36 warnings->import('all');
37 warnings->import(FATAL => @strictures::WARNING_CATEGORIES);
d50343b9 38 warnings->unimport(FATAL => @strictures::V2_NONFATAL);
39 warnings->import(@strictures::V2_NONFATAL);
23c0b85d 40 warnings->unimport(@strictures::V2_DISABLE);
41 }
42 BEGIN { capture_hints }
43}
44
45{
46 use strictures 2;
47 BEGIN { test_hints "version 2" }
48}
49
91b5f6b6 50my $v;
51eval { $v = strictures->VERSION; 1 } or diag $@;
52is $v, $strictures::VERSION, '->VERSION returns version correctly';
53
23c0b85d 54ok(!eval q{use strictures 3; 1; }, "Can't use strictures 3 (this is version 2)");