Remove unused Module::Build tests
[p5sagit/p5-mst-13.2.git] / lib / Module / Build / t / notes.t
1 #!/usr/bin/perl -w
2
3 use strict;
4 use lib $ENV{PERL_CORE} ? '../lib/Module/Build/t/lib' : 't/lib';
5 use MBTest tests => 11;
6
7 use Cwd ();
8 my $cwd = Cwd::cwd;
9 my $tmp = File::Spec->catdir( $cwd, 't', '_tmp' );
10
11 use DistGen;
12 my $dist = DistGen->new( dir => $tmp );
13 $dist->regen;
14
15 chdir( $dist->dirname ) or die "Can't chdir to '@{[$dist->dirname]}': $!";
16
17
18 use Module::Build;
19
20 ###################################
21 $dist->change_file( 'Build.PL', <<"---" );
22 use Module::Build;
23 my \$build = Module::Build->new(
24   module_name => @{[$dist->name]},
25   license     => 'perl'
26 );
27 \$build->create_build_script;
28 \$build->notes(foo => 'bar');
29 ---
30
31 $dist->regen;
32
33 my $mb = Module::Build->new_from_context;
34
35 is $mb->notes('foo'), 'bar';
36
37 # Try setting & checking a new value
38 $mb->notes(argh => 'new');
39 is $mb->notes('argh'), 'new';
40
41 # Change existing value
42 $mb->notes(foo => 'foo');
43 is $mb->notes('foo'), 'foo';
44
45 # Change back so we can run this test again successfully
46 $mb->notes(foo => 'bar');
47 is $mb->notes('foo'), 'bar';
48
49 # Check undef vs. 0 vs ''
50 foreach my $val (undef, 0, '') {
51   $mb->notes(null => $val);
52   is $mb->notes('null'), $val;
53 }
54
55
56 ###################################
57 # Make sure notes set before create_build_script() get preserved
58 $mb = Module::Build->new(module_name => $dist->name);
59 ok $mb;
60 $mb->notes(foo => 'bar');
61 is $mb->notes('foo'), 'bar';
62
63 $mb->create_build_script;
64
65 $mb = Module::Build->resume;
66 ok $mb;
67 is $mb->notes('foo'), 'bar';
68
69
70 # cleanup
71 chdir( $cwd ) or die "Can''t chdir to '$cwd': $!";
72 $dist->remove;
73
74 use File::Path;
75 rmtree( $tmp );