summaryrefslogtreecommitdiff
path: root/lib/base/t/warnings.t
blob: 631cc37b7f825bfa5ea38a18d06102c8c29ac57e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/perl -w

BEGIN {
   if( $ENV{PERL_CORE} ) {
        chdir 't' if -d 't';
        @INC = qw(../lib);
    }
}

use strict;

use Test::More tests => 1;

my $warnings;
BEGIN {
    $SIG{__WARN__} = sub { $warnings = join '', @_ };
}

{
    package Foo;
    use fields qw(thing);
}

{
    package Bar;
    use fields qw(stuff);
    use base qw(Foo);
}

::like $warnings,
       '/^Bar is inheriting from Foo but already has its own fields!/',
       'Inheriting from a base with protected fields warns';