This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Add test preambles
[perl5.git] / lib / base / t / warnings.t
1 #!/usr/bin/perl -w
2
3 BEGIN {
4    if( $ENV{PERL_CORE} ) {
5         chdir 't' if -d 't';
6         @INC = qw(../lib);
7     }
8 }
9
10 use strict;
11
12 use Test::More tests => 1;
13
14 my $warnings;
15 BEGIN {
16     $SIG{__WARN__} = sub { $warnings = join '', @_ };
17 }
18
19 {
20     package Foo;
21     use fields qw(thing);
22 }
23
24 {
25     package Bar;
26     use fields qw(stuff);
27     use base qw(Foo);
28 }
29
30 ::like $warnings,
31        '/^Bar is inheriting from Foo but already has its own fields!/',
32        'Inheriting from a base with protected fields warns';