Move CPANPLUS from ext/ to cpan/
[p5sagit/p5-mst-13.2.git] / cpan / CPANPLUS / t / 06_CPANPLUS-Internals-Constants.t
1 ### make sure we can find our conf.pl file
2 BEGIN { 
3     use FindBin; 
4     require "$FindBin::Bin/inc/conf.pl";
5 }
6
7 use strict;
8 use Test::More 'no_plan';
9 use Cwd;
10 use Config;
11 use File::Basename;
12
13 use CPANPLUS::Internals::Constants;
14 use CPANPLUS::Module::Fake;
15 use CPANPLUS::Module::Author::Fake;
16 use CPANPLUS::Configure;
17 use CPANPLUS::Backend;
18
19 my $conf = gimme_conf();
20
21 my $cb = CPANPLUS::Backend->new( $conf );
22
23 my $f_auth = CPANPLUS::Module::Author::Fake->new( _id => $cb->_id );
24 ok( $f_auth,                        "Fake auth object created" );
25 ok( IS_AUTHOBJ->( $f_auth ),        "   IS_AUTHOBJ recognizes it" );
26 ok( IS_FAKE_AUTHOBJ->( $f_auth ),   "   IS_FAKE_AUTHOBJ recognizes it" );
27
28 my $f_mod = CPANPLUS::Module::Fake->new(
29                 module  => TEST_CONF_INST_MODULE ,
30                 path    => 'some/where',
31                 package => 'Foo-Bar-1.2.tgz',
32                 _id     => $cb->_id,
33             );
34 ok( $f_mod,                     "Fake mod object created" );
35 ok( IS_MODOBJ->( $f_mod ),      "   IS_MODOBJ recognizes it" );
36 ok( IS_FAKE_MODOBJ->( $f_mod ), "   IS_FAKE_MODOJB recognizes it" );
37
38 ok( IS_CONFOBJ->( conf => $conf ),  "IS_CONFOBJ recognizes conf object" );
39
40 ok( FILE_EXISTS->( file => basename($0) ),      "FILE_EXISTS finds file" );
41 ok( FILE_READABLE->( file => basename($0) ),    "FILE_READABLE finds file" );
42 ok( DIR_EXISTS->( dir => cwd() ),               "DIR_EXISTS finds dir" );
43             
44
45 {   no strict 'refs';
46
47     my $tmpl = {
48         MAKEFILE_PL => 'Makefile.PL',
49         BUILD_PL    => 'Build.PL',
50         BLIB        => 'blib',
51         MAKEFILE    => do {
52             ### On vms, it's a different name. See constants
53             ### file for details
54             (ON_VMS and $Config::Config{make} =~ /MM[S|K]/i)
55                 ? 'DESCRIP.MMS'
56                 : 'Makefile'
57         },
58     };
59     
60     while ( my($sub,$res) = each %$tmpl ) {
61         is( &{$sub}->(), $res, "$sub returns proper result without args" );
62         
63         my $long = File::Spec->catfile( cwd(), $res );
64         is( &{$sub}->( cwd() ), $long, "$sub returns proper result with args" );
65     }       
66 }                               
67       
68 # Local variables:
69 # c-indentation-style: bsd
70 # c-basic-offset: 4
71 # indent-tabs-mode: nil
72 # End:
73 # vim: expandtab shiftwidth=4: