2 # Copyright (C) 2007, The Perl Foundation.
8 use Test::More tests => 16;
10 use lib qw( lib t/configure/testlib );
11 use_ok('config::init::defaults');
12 use_ok('config::auto::format');
13 use Parrot::BuildUtil;
14 use Parrot::Configure;
15 use Parrot::Configure::Options qw( process_options );
16 use Parrot::Configure::Test qw( test_step_thru_runstep);
18 my $args = process_options( {
23 my $conf = Parrot::Configure->new();
25 test_step_thru_runstep($conf, q{init::defaults}, $args);
27 my ($task, $step_name, $step, $ret);
28 my $pkg = q{auto::format};
30 $conf->add_steps($pkg);
31 $conf->options->set(%{$args});
33 $task = $conf->steps->[-1];
34 $step_name = $task->step;
36 $step = $step_name->new();
37 ok(defined $step, "$step_name constructor returned defined value");
38 isa_ok($step, $step_name);
39 ok($step->description(), "$step_name has description");
42 $conf->data->set( iv => 'int' );
43 auto::format::_set_intvalfmt($conf);
44 is($conf->data->get( 'intvalfmt' ), '%d',
45 "intvalfmt set as expected");
47 $conf->data->set( iv => undef );
51 $conf->data->set( iv => 'long' );
52 auto::format::_set_intvalfmt($conf);
53 is($conf->data->get( 'intvalfmt' ), '%ld',
54 "intvalfmt set as expected");
56 $conf->data->set( iv => undef );
60 $conf->data->set( iv => 'long int' );
61 auto::format::_set_intvalfmt($conf);
62 is($conf->data->get( 'intvalfmt' ), '%ld',
63 "intvalfmt set as expected");
65 $conf->data->set( iv => undef );
69 $conf->data->set( iv => 'long long' );
70 auto::format::_set_intvalfmt($conf);
71 is($conf->data->get( 'intvalfmt' ), '%lld',
72 "intvalfmt set as expected");
74 $conf->data->set( iv => undef );
78 $conf->data->set( iv => 'long long int' );
79 auto::format::_set_intvalfmt($conf);
80 is($conf->data->get( 'intvalfmt' ), '%lld',
81 "intvalfmt set as expected");
83 $conf->data->set( iv => undef );
88 $conf->data->set( iv => $type );
89 eval { auto::format::_set_intvalfmt($conf); };
91 qr/Can't find a printf-style format specifier for type '$type'/, #'
92 "Got expected error message");
95 pass("Completed all tests in $0");
97 ################### DOCUMENTATION ###################
101 auto_format-01.t - test config::auto::format
105 % prove t/steps/auto_format-01.t
109 The files in this directory test functionality used by F<Configure.pl>.
111 The tests in this file test subroutines exported by config::auto::format.
119 config::auto::format, F<Configure.pl>.
125 # cperl-indent-level: 4
128 # vim: expandtab shiftwidth=4: