Commit | Line | Data |
967e00d7 |
1 | BEGIN { $ENV{PERL_STRICTURES_EXTRA} = 0 } |
5ab06a4d |
2 | |
967e00d7 |
3 | sub capture_hints { |
b4f4fcfc |
4 | my $code = shift; |
5 | my ($hints, $warning_bits); |
6 | $code .= q{ |
7 | ; |
8 | BEGIN { |
9 | # ignore lexicalized hints |
10 | $hints = $^H & ~ 0x20000; |
11 | $warning_bits = defined ${^WARNING_BITS} ? (unpack "H*", ${^WARNING_BITS}) : undef; |
12 | }; |
13 | 1; |
14 | }; |
15 | eval $code or die $@; |
16 | return ($hints, $warning_bits); |
967e00d7 |
17 | } |
eae006ee |
18 | |
b4f4fcfc |
19 | use strict; |
20 | use warnings; |
21 | use Test::More qw(no_plan); |
22 | |
23 | sub compare_hints { |
24 | my ($code_want, $code_got, $name) = @_; |
25 | my ($want_hints, $want_warnings) = capture_hints $code_want; |
26 | my ($hints, $warnings) = capture_hints $code_got; |
27 | is($hints, $want_hints, "Hints correct for $name"); |
28 | is($warnings, $want_warnings, "Warnings correct for $name"); |
eae006ee |
29 | } |
30 | |
b4f4fcfc |
31 | compare_hints q{ |
eae006ee |
32 | use strict; |
33 | use warnings FATAL => 'all'; |
b4f4fcfc |
34 | }, |
35 | q{ |
967e00d7 |
36 | use strictures 1; |
b4f4fcfc |
37 | }, |
38 | 'version 1'; |
eae006ee |
39 | |
b4f4fcfc |
40 | compare_hints q{ |
23c0b85d |
41 | use strict; |
b4f4fcfc |
42 | use warnings 'all'; |
43 | use warnings FATAL => @strictures::WARNING_CATEGORIES; |
44 | no warnings FATAL => @strictures::V2_NONFATAL; |
45 | use warnings @strictures::V2_NONFATAL; |
46 | no warnings @strictures::V2_DISABLE; |
47 | }, |
48 | q{ |
23c0b85d |
49 | use strictures 2; |
b4f4fcfc |
50 | }, |
51 | 'version 2'; |
23c0b85d |
52 | |
91b5f6b6 |
53 | my $v; |
54 | eval { $v = strictures->VERSION; 1 } or diag $@; |
55 | is $v, $strictures::VERSION, '->VERSION returns version correctly'; |
56 | |
cd782762 |
57 | my $next = int $v + 1; |
58 | eval qq{ use strictures $next; }; |
18069754 |
59 | |
cd782762 |
60 | like $@, qr/strictures version $next required/, |
61 | "Can't use strictures $next (this is version $v)"; |