fix codetest failure - ASSERT_ARGS does not have a ; after and
[parrot.git] / t / steps / auto / readline-01.t
blob66d64a5e982b4acd86df907686b118b304128cd1
1 #! perl
2 # Copyright (C) 2007, Parrot Foundation.
3 # $Id$
4 # auto/readline-01.t
6 use strict;
7 use warnings;
8 use Test::More tests => 15;
9 use Carp;
10 use Cwd;
11 use File::Spec;
12 use File::Temp qw( tempdir );
13 use lib qw( lib );
14 use_ok('config::auto::readline');
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 ########## _select_lib() ##########
24 my ($args, $step_list_ref) = process_options(
25     {
26         argv => [ '--without-readline' ],
27         mode => q{configure},
28     }
31 my $conf = Parrot::Configure::Step::Test->new;
32 $conf->include_config_results( $args );
33 my $serialized = $conf->pcfreeze();
35 my $pkg = q{auto::readline};
37 $conf->add_steps($pkg);
38 $conf->options->set( %{$args} );
39 my $step = test_step_constructor_and_description($conf);
41 my $ret = $step->runstep($conf);
42 ok( $ret, "runstep() returned true value" );
43 is($step->result(), q{not requested},
44     "Got expected result for 'without-readline'");
45 is($conf->data->get('HAS_READLINE'), 0,
46     "Got expected value for HAS_READLINE");
48 $conf->replenish($serialized);
50 ($args, $step_list_ref) = process_options(
51     {
52         argv => [ ],
53         mode => q{configure},
54     }
57 $conf->add_steps($pkg);
58 $conf->options->set( %{$args} );
59 $step = test_step_constructor_and_description($conf);
61 # Mock values for OS and C-compiler
62 my ($osname, $cc);
63 $osname = 'mswin32';
64 $cc = 'gcc';
65 is($step->_select_lib( {
66     conf            => $conf,
67     osname          => $osname,
68     cc              => $cc,
69     win32_nongcc    => 'readline.lib',
70     default         => '-lreadline',
71 } ),
72    '-lreadline',
73    "_select_lib() returned expected value");
75 $osname = 'mswin32';
76 $cc = 'cc';
77 is($step->_select_lib( {
78     conf            => $conf,
79     osname          => $osname,
80     cc              => $cc,
81     win32_nongcc    => 'readline.lib',
82     default         => '-lreadline',
83 } ),
84    'readline.lib',
85    "_select_lib() returned expected value");
87 $osname = 'foobar';
88 $cc = undef;
89 is($step->_select_lib( {
90     conf            => $conf,
91     osname          => $osname,
92     cc              => $cc,
93     win32_nongcc    => 'readline.lib',
94     default         => '-lreadline',
95 } ),
96    '-lreadline',
97    "_select_lib() returned true value");
99 $osname = 'foobar';
100 $cc = undef;
101 eval {
102     $step->_select_lib( [
103         conf            => $conf,
104         osname          => $osname,
105         cc              => $cc,
106         win32_nongcc    => 'readline.lib',
107         default         => '-lreadline',
108     ] );
110 like($@, qr/_select_lib\(\) takes hashref/,
111     "Bad argument to _select_lib correctly detected");
113 pass("Completed all tests in $0");
115 ################### DOCUMENTATION ###################
117 =head1 NAME
119 auto/readline-01.t - test auto::readline
121 =head1 SYNOPSIS
123     % prove t/steps/auto/readline-01.t
125 =head1 DESCRIPTION
127 The files in this directory test functionality used by F<Configure.pl>.
129 The tests in this file test auto::readline.
131 =head1 AUTHOR
133 James E Keenan
135 =head1 SEE ALSO
137 config::auto::readline, F<Configure.pl>.
139 =cut
141 # Local Variables:
142 #   mode: cperl
143 #   cperl-indent-level: 4
144 #   fill-column: 100
145 # End:
146 # vim: expandtab shiftwidth=4: