This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
new perldelta
[perl5.git] / lib / strict.t
... / ...
CommitLineData
1#!./perl
2
3chdir 't' if -d 't';
4@INC = ( '.', '../lib' );
5
6our $local_tests = 7;
7require "../t/lib/common.pl";
8
9eval qq(use strict 'garbage');
10like($@, qr/^Unknown 'strict' tag\(s\) 'garbage'/);
11
12eval qq(no strict 'garbage');
13like($@, qr/^Unknown 'strict' tag\(s\) 'garbage'/);
14
15eval qq(use strict qw(foo bar));
16like($@, qr/^Unknown 'strict' tag\(s\) 'foo bar'/);
17
18eval qq(no strict qw(foo bar));
19like($@, 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
31eval 'use strict; use v5.10; ${"c"}';
32like($@,
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");