This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Promote v5.36 usage and feature bundles doc
[perl5.git] / lib / strict.t
1 #!./perl
2
3 chdir 't' if -d 't';
4 @INC = ( '.', '../lib' );
5
6 our $local_tests = 7;
7 require "../t/lib/common.pl";
8
9 eval qq(use strict 'garbage');
10 like($@, qr/^Unknown 'strict' tag\(s\) 'garbage'/);
11
12 eval qq(no strict 'garbage');
13 like($@, qr/^Unknown 'strict' tag\(s\) 'garbage'/);
14
15 eval qq(use strict qw(foo bar));
16 like($@, qr/^Unknown 'strict' tag\(s\) 'foo bar'/);
17
18 eval qq(no strict qw(foo bar));
19 like($@, qr/^Unknown 'strict' tag\(s\) 'foo bar'/);
20
21 {
22     my $warnings = "";
23     local $SIG{__WARN__} = sub { $warnings .= $_[0] };
24     eval 'use v5.12; use v5.10; ${"c"}';
25     is($@, '', 'use v5.10 disables implicit strict refs');
26     like($warnings,
27         qr/^Downgrading a use VERSION declaration to below v5.11 is deprecated, and will become fatal in Perl 5.40 at /,
28         'use v5.10 after use v5.12 provokes deprecation warning');
29 }
30
31 eval 'use strict; use v5.10; ${"c"}';
32 like($@,
33     qr/^Can't use string \("c"\) as a SCALAR ref while "strict refs" in use/,
34     "use v5.10 doesn't disable explicit strict ref");