File: isa-triggering-overload.t

package info (click to toggle)
libuniversal-can-perl 1.20140328-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 152 kB
  • sloc: perl: 326; makefile: 2
file content (31 lines) | stat: -rw-r--r-- 702 bytes parent folder | download | duplicates (4)
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
#! perl

{
    package Test::Overloaded::String;

    use vars qw( $called_string_overload );

    use strict;
    use warnings;

    use overload '""' => sub { $called_string_overload++ };

    sub new { bless {}, shift }

    sub foo { }
}

package main;

use strict;
use warnings;

use Test::More tests => 3;
use UNIVERSAL::can;

ok( eval { Test::Overloaded::String->new->can('foo') },
    "->can should return true for an existing method" );
ok( !eval { Test::Overloaded::String->new->can('bar') },
    "->can should return false for a non-existent method" );
ok( !$Test::Overloaded::String::called_string_overload,
    "it should not trigger the string overload on the invocant in either case" );