2 # Copyright (C) 2007, Parrot Foundation.
8 use Test::More tests => 26;
12 use File::Temp qw( tempdir );
13 use lib qw( lib t/configure/testlib );
14 use_ok('config::auto::gmp');
15 use Parrot::Configure::Options qw( process_options );
16 use Parrot::Configure::Step::Test;
17 use Parrot::Configure::Test qw(
18 test_step_constructor_and_description
20 use IO::CaptureOutput qw( capture );
22 =for hints_for_testing The documentation for this package is skimpy;
23 please try to improve it, e.g., by providing a link to an introduction
24 to the GNU MP library.
28 ########### --without-gmp ###########
30 my ($args, $step_list_ref) = process_options( {
31 argv => [ q{--without-gmp} ],
35 my $conf = Parrot::Configure::Step::Test->new;
36 $conf->include_config_results( $args );
38 my $pkg = q{auto::gmp};
40 $conf->add_steps($pkg);
42 my $serialized = $conf->pcfreeze();
44 $conf->options->set( %{$args} );
45 my $step = test_step_constructor_and_description($conf);
46 my $ret = $step->runstep($conf);
47 ok( $ret, "runstep() returned true value" );
48 is($conf->data->get('has_gmp'), 0,
49 "Got expected value for 'has_gmp'");
50 is($step->result(), q{no}, "Expected result was set");
52 $conf->replenish($serialized);
54 ########### _select_lib() ###########
56 ($args, $step_list_ref) = process_options( {
60 $conf->options->set( %{$args} );
61 $step = test_step_constructor_and_description($conf);
62 # Mock values for OS and C-compiler
63 my ($osname, $cc, $initial_value);
66 $initial_value = $conf->data->get( 'libs' );
67 is($step->_select_lib( {
71 win32_nongcc => 'gmp.lib',
75 "_select_lib() returned expected value");
79 is($step->_select_lib( {
83 win32_nongcc => 'gmp.lib',
87 "_select_lib() returned expected value");
91 is($step->_select_lib( {
95 win32_nongcc => 'gmp.lib',
99 "_select_lib() returned expected value");
101 my ($flagsbefore, $flagsafter);
104 ########### _evaluate_cc_run() ###########
106 ($args, $step_list_ref) = process_options( {
108 mode => q{configure},
110 $conf->options->set( %{$args} );
111 $step = test_step_constructor_and_description($conf);
113 my ($test, $has_gmp);
115 $test = $step->{cc_run_expected};
117 $conf->options->set(verbose => undef);
118 $has_gmp = $step->_evaluate_cc_run($conf, $test, $has_gmp);
119 is($step->result, 'yes', "Got expected result");
120 is($conf->data->get('gmp'), 'define', "Expected value set for 'gmp'");
121 is($conf->data->get('HAS_GMP'), 1, "Expected value set for 'HAS_GMP'");
122 # prepare for next test
123 $conf->data->set('gmp' => undef);
124 $conf->data->set('HAS_GMP' => undef);
125 $step->set_result(undef);
129 $conf->options->set(verbose => undef);
130 $has_gmp = $step->_evaluate_cc_run($conf, $test, $has_gmp);
131 ok(! defined($step->result), "Result undefined as expected");
132 is($has_gmp, 0, "gmp status unchanged");
136 $test = $step->{cc_run_expected};
138 $conf->options->set(verbose => 1);
141 $step->_evaluate_cc_run($conf, $test, $has_gmp); },
144 is($step->result, 'yes', "Got expected result");
145 is($conf->data->get('gmp'), 'define', "Expected value set for 'gmp'");
146 is($conf->data->get('HAS_GMP'), 1, "Expected value set for 'HAS_GMP'");
147 like($stdout, qr/\(yes\)/, "Got expected verbose output");
148 # prepare for next test
149 $conf->data->set('gmp' => undef);
150 $conf->data->set('HAS_GMP' => undef);
151 $step->set_result(undef);
154 pass("Completed all tests in $0");
156 ################### DOCUMENTATION ###################
160 auto/gmp-01.t - test auto::gmp
164 % prove t/steps/auto/gmp-01.t
168 The files in this directory test functionality used by F<Configure.pl>.
170 The tests in this file test auto::gmp.
178 config::auto::gmp, F<Configure.pl>.
184 # cperl-indent-level: 4
187 # vim: expandtab shiftwidth=4: