File: override.t

package info (click to toggle)
libtest-class-perl 0.52-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 540 kB
  • sloc: perl: 1,706; makefile: 2
file content (27 lines) | stat: -rw-r--r-- 500 bytes parent folder | download
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
use strict;
use warnings;
use Test::More tests => 1;

my $warning;

BEGIN {

    $SIG{ __WARN__ } = sub { $warning = "@_" };

    {
        package Base::Test;
        use base qw( Test::Class );
    }
    
    {
        package Broken::Test;
        use base qw( Base::Test );

        sub new : Test {
            "oops - we've overridden a public method with a test method";
        }
    }
}

like $warning, qr/overriding public method/,
    'cannot override a public method with a test method';