source: branches/UKMO/r6232_tracer_advection/NEMOGCM/EXTERNAL/fcm/t/Fcm/Util/ClassLoader.t @ 9295

Last change on this file since 9295 was 9295, checked in by jcastill, 3 years ago

Remove svn keywords

File size: 1.2 KB
Line 
1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
6################################################################################
7# A class for testing the loader
8{
9    package MyTestClass;
10
11    sub new {
12        my ($class) = @_;
13        return bless(\do{my $annon_scalar}, $class);
14    }
15}
16
17use Test::More qw{no_plan};
18
19main();
20
21sub main {
22    use_ok('Fcm::Util::ClassLoader');
23    test_normal();
24    test_bad();
25}
26
27################################################################################
28# Tests loading classes that should load OK
29sub test_normal {
30    my $prefix = 'normal';
31    my @CLASSES = (
32        'Fcm::CLI::Config',
33        'Fcm::Exception',
34        'Fcm::CLI::Config', # repeat
35        'MyTestClass',
36    );
37    for my $class (@CLASSES) {
38        ok(Fcm::Util::ClassLoader::load($class), "$prefix: load $class");
39    }
40}
41
42################################################################################
43# Tests loading classes that should fail
44sub test_bad {
45    my $prefix = 'bad';
46    my @CLASSES = ('Foo', 'Bar', 'Baz', 'No::Such::Class', 'Foo');
47    for my $class (@CLASSES) {
48        eval {
49            Fcm::Util::ClassLoader::load($class);
50        };
51        isa_ok($@, 'Fcm::Exception', "$prefix: load $class");
52    }
53}
54
55__END__
Note: See TracBrowser for help on using the repository browser.