File: 22-overload-can-bug.t

package info (click to toggle)
libparams-validate-perl 0.91-2
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 524 kB
  • ctags: 729
  • sloc: perl: 2,596; makefile: 52
file content (38 lines) | stat: -rw-r--r-- 573 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
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/perl -w

use strict;

use Params::Validate qw(validate);
use Test::More tests => 2;

{
    package Overloaded;

    use overload 'bool' => sub { 0 };

    sub new { bless {} }

    sub foo { 1 }
}

my $ovl = Overloaded->new;

{
    eval
    {
        my @p = ( object => $ovl );
        validate( @p, { object => { isa => 'Overloaded' } } );
    };

    is( $@, q{}, 'overloaded object->isa' );
}

{
    eval
    {
        my @p = ( object => $ovl );
        validate( @p, { object => { can => 'foo' } } );
    };

    is( $@, q{}, 'overloaded object->foo' );
}