File: 09_insideout.t

package info (click to toggle)
libparams-util-perl 1.102-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,044 kB
  • sloc: perl: 5,398; makefile: 3
file content (52 lines) | stat: -rw-r--r-- 903 bytes parent folder | download | duplicates (3)
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#!/usr/bin/perl

# Test for a custom isa method that returns the same way that
# Object::InsideOut does.

use strict;

BEGIN
{
    $|  = 1;
    $^W = 1;
    $ENV{PERL_PARAMS_UTIL_PP} ||= 1;
}

use Test::More tests => 2;
use Scalar::Util ();
use Params::Util ();

#####################################################################
# Create an object and test it

SCOPE:
{
    my $object = Foo->new;
    ok(Scalar::Util::blessed($object), 'Foo');
    my $instance = Params::Util::_INSTANCE($object, 'Foo');
    is($instance, undef, '_INSTANCE correctly returns undef');
}

#####################################################################
# Create a package to simulate Object::InsideOut

CLASS:
{

    package Foo;

    sub new
    {
        my $foo  = 1234;
        my $self = \$foo;
        bless $self, $_[0];
        return $self;
    }

    sub isa
    {
        return ('');
    }

    1;
}