2 # Copyright (C) 2007, Parrot Foundation.
8 use Test::More tests => 27;
10 use lib qw( lib t/configure/testlib );
11 use_ok('config::auto::perldoc');
12 use Parrot::BuildUtil;
13 use Parrot::Configure::Options qw( process_options );
14 use Parrot::Configure::Step::Test;
15 use Parrot::Configure::Test qw(
16 test_step_constructor_and_description
19 ########## regular ##########
21 my ($args, $step_list_ref) = process_options( {
26 my $conf = Parrot::Configure::Step::Test->new;
27 $conf->include_config_results( $args );
29 my $pkg = q{auto::perldoc};
31 $conf->add_steps($pkg);
33 my $serialized = $conf->pcfreeze();
35 $conf->options->set(%{$args});
36 my $step = test_step_constructor_and_description($conf);
37 ok($step->runstep($conf), "runstep() completed successfully");
38 ok(defined($step->result), "Result was defined");
39 my $has = $conf->data->get('has_perldoc');
40 ok( ( ($has == 1) or ($has == 0) ),
41 "Got an acceptable value for 'has_perldoc'");
42 my $new = $conf->data->get('new_perldoc');
43 ok( ( ($new == 1) or ($new == 0) ),
44 "Got an acceptable value for 'new_perldoc'");
46 $conf->replenish($serialized);
48 ########## _initial_content_check() ##########
51 my $rv = $step->_initial_content_check($conf, $content);
52 ok(! defined $rv, "Got expected return value when content was undefined");
54 q{no}, "Got expected result when content was undefined");
56 ########## _handle_version() ##########
60 ok(auto::perldoc::_handle_version($conf, $version, 'not_a_path'),
61 "_handle_version() returned true value");
62 is($conf->data->get('has_perldoc'), 0,
63 "Got expected value for 'has_perldoc'");
64 is($conf->data->get('new_perldoc'), 0,
65 "Got expected value for 'new_perldoc'");
66 is($conf->data->get('perldoc'), 'echo',
67 "... and expected 'perldoc' path");
70 ok(auto::perldoc::_handle_version($conf, $version, 'path_to_pd'),
71 "_handle_version() returned true value");
72 is($conf->data->get('has_perldoc'), 1,
73 "Got expected value for 'has_perldoc'");
74 is($conf->data->get('new_perldoc'), 0,
75 "Got expected value for 'new_perldoc'");
76 is($conf->data->get('perldoc'), 'path_to_pd',
77 "... and expected 'perldoc' path");
80 ok(auto::perldoc::_handle_version($conf, $version, 'another_path_to_pd'),
81 "_handle_version() returned true value");
82 is($conf->data->get('has_perldoc'), 1,
83 "Got expected value for 'has_perldoc'");
84 is($conf->data->get('new_perldoc'), 1,
85 "Got expected value for 'new_perldoc'");
86 is($conf->data->get('perldoc'), 'another_path_to_pd',
87 "... and expected 'perldoc' path");
89 ########## _handle_old_perldoc() ##########
91 $version = $step->_handle_old_perldoc();
92 is($version, 1, "Got expected version setting for old perldoc");
93 is($step->result(), q{yes, old version},
94 "Got expected result when old perldoc");
96 ########## _handle_no_perldoc() ##########
98 $version = $step->_handle_no_perldoc();
99 is($version, 0, "Got expected version setting for no perldoc");
100 is($step->result(), q{failed}, "Got expected result when no perldoc");
102 pass("Completed all tests in $0");
104 ################### DOCUMENTATION ###################
108 auto/perldoc-01.t - test auto::perldoc
112 % prove t/steps/auto/perldoc-01.t
116 The files in this directory test functionality used by F<Configure.pl>.
118 The tests in this file test auto::perldoc.
126 config::auto::perldoc, F<Configure.pl>.
132 # cperl-indent-level: 4
135 # vim: expandtab shiftwidth=4: