tagged release 0.6.4
[parrot.git] / t / steps / auto_format-01.t
blobf9eb583605468adfe0cd701da420f17306829010
1 #! perl
2 # Copyright (C) 2007, The Perl Foundation.
3 # $Id$
4 # auto_format-01.t
6 use strict;
7 use warnings;
8 use Test::More tests => 16;
9 use Carp;
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( {
19     argv            => [],
20     mode            => q{configure},
21 } );
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");
46     # reset for next test
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");
55     # reset for next test
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");
64     # reset for next test
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");
73     # reset for next test
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");
82     # reset for next test
83     $conf->data->set( iv => undef );
87     my $type = 'foobar';
88     $conf->data->set( iv => $type );
89     eval { auto::format::_set_intvalfmt($conf); };
90     like($@,
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 ###################
99 =head1 NAME
101 auto_format-01.t - test config::auto::format
103 =head1 SYNOPSIS
105     % prove t/steps/auto_format-01.t
107 =head1 DESCRIPTION
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.
113 =head1 AUTHOR
115 James E Keenan
117 =head1 SEE ALSO
119 config::auto::format, F<Configure.pl>.
121 =cut
123 # Local Variables:
124 #   mode: cperl
125 #   cperl-indent-level: 4
126 #   fill-column: 100
127 # End:
128 # vim: expandtab shiftwidth=4: