tagged release 0.6.4
[parrot.git] / t / steps / auto_format-02.t
blob6bb62d3466a6c9af58dab35d6323914275db8df8
1 #! perl
2 # Copyright (C) 2007, The Perl Foundation.
3 # $Id$
4 # auto_format-02.t
6 use strict;
7 use warnings;
8 use Test::More tests =>  14;
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);
42     $conf->data->set( nv => 'double' );
43     auto::format::_set_floatvalfmt_nvsize($conf);
44     is($conf->data->get( 'floatvalfmt' ), '%f',
45         "floatvalfmt set as expected");
46     is($conf->data->get( 'nvsize' ), $conf->data->get( 'doublesize' ),
47         "nvsize set as expected");
48     $conf->data->set(
49         nv          => undef,
50         floatvalfmt => undef,
51         nvsize      => undef,
52     );
56     $conf->data->set( nv => 'long double' );
57     auto::format::_set_floatvalfmt_nvsize($conf);
58     is($conf->data->get( 'floatvalfmt' ), '%Lf',
59         "floatvalfmt set as expected");
60     is($conf->data->get( 'nvsize' ), $conf->data->get( 'hugefloatvalsize' ),
61         "nvsize set as expected");
62     $conf->data->set(
63         nv          => undef,
64         floatvalfmt => undef,
65         nvsize      => undef,
66     );
70     my $type = 'foobar';
71     $conf->data->set( nv => 'foobar' );
72     eval { auto::format::_set_floatvalfmt_nvsize($conf); };
73     like($@,
74         qr/Can't find a printf-style format specifier for type '$type'/, #'
75         "Got expected error message");
79 pass("Completed all tests in $0");
81 ################### DOCUMENTATION ###################
83 =head1 NAME
85 auto_format-02.t - test config::auto::format
87 =head1 SYNOPSIS
89     % prove t/steps/auto_format-02.t
91 =head1 DESCRIPTION
93 The files in this directory test functionality used by F<Configure.pl>.
95 The tests in this file test subroutines exported by config::auto::format.
97 =head1 AUTHOR
99 James E Keenan
101 =head1 SEE ALSO
103 config::auto::format, F<Configure.pl>.
105 =cut
107 # Local Variables:
108 #   mode: cperl
109 #   cperl-indent-level: 4
110 #   fill-column: 100
111 # End:
112 # vim: expandtab shiftwidth=4: