File: 01-require.t

package info (click to toggle)
libclass-loader-perl 2.03-4
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, sid, trixie
  • size: 88 kB
  • sloc: perl: 185; makefile: 2
file content (70 lines) | stat: -rwxr-xr-x 1,625 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/perl -st
##
## Class::Loader Test Suite
##
## Copyright (c) 2001, Vipul Ved Prakash.  All rights reserved.
## This code is free software; you can redistribute it and/or modify
## it under the same terms as Perl itself.
##
## $Id: 01-require.t,v 1.2 2001/04/28 03:21:47 vipul Exp $

use lib '../lib', 'lib';
package Class::Loader::Test01;
use Class::Loader;
use vars qw(@ISA);
@ISA = (Class::Loader);

sub new { 

    my $self = { Method => 'new' };
    return bless $self, shift;

}

sub test { 

    my $self = shift;
    $self->{Handler} = $self->_load ( Module => "Class::LoaderTest" );

}

sub test2 { 

    my ($self, $param) = @_;
    if ($param) { 
        $self->_load ( 'Handler2', Module => "Class::LoaderTest", 
                                       Constructor => "foo",
                                       Args => ["$param"],
                       );
    } else { 
        $self->_load ( 'Handler2', Module => "Class::LoaderTest", Constructor => "foo" );
    }

}


package main;

use Data::Dumper;
use Test;
BEGIN { plan tests => 5 };

print "construction by module name...\n";
my $test = new Class::Loader::Test01;
$test->test();
ok(1) if ref $test->{Handler} eq "Class::LoaderTest";

print "construction by module name and constructor name...\n";
$test = new Class::Loader::Test01;
$test->test2;
ok(ref $test->{Handler2}, "Class::LoaderTest");
ok($test->{Handler2}{Method}, "foo");

print "construction by module, constructor and arguments...\n";
$test = new Class::Loader::Test01;
$test->test2 ("few");
ok(ref $test->{Handler2}, "Class::LoaderTest");
ok($test->{Handler2}{Method}, "few");