2 # Copyright (C) 2007-2009, Parrot Foundation.
9 my @conf_args = ( true => 1, false => 0, value => 'xx' );
13 # perl-syntax true or false
18 ["IF(true | false)", 1],
19 ["IF(true & false)", 0],
20 ["IF(true or true)", 1],
21 ["IF(true or false)", 1],
22 ["IF(false or true)", 1],
23 ["IF(false or false)", 0],
24 ["IF(true and true)", 1],
25 ["IF(true and false)", 0],
26 ["IF(false and true)", 0],
27 ["IF(false and false)", 0],
28 ["UNLESS(true|false)", 0],
29 ["UNLESS(true&false)", 1],
41 ["IF(true and (!false and value))", 1],
42 ["IF(true and (!false) and value)", 1],
43 ["IF(true and !false and value)", 1, 'no parens'],
44 ["IF(true and not false and value)", 1, 'no parens'],
45 ["IF(true&!false&value)", 1],
46 ["IF(false or (!false and value))", 1, 'not parser problem'],
47 ["UNLESS(!(true&!false&value))", 1, 'no ws, but nested parens'],
48 ["IF(true&(!false&false))", 0, 'not precedence'],
49 ["IF(true&(!false&value))", 1],
50 ["IF(not true and value)", 0, 'not precedence over and'],
51 ["IF(not false and value)", 1],
52 ["IF((not false) and value)", 1],
53 ["IF(not (false and value))", 1],
54 ["IF(not (false or value))", 0],
55 ["IF(true and not false)", 1],
57 ["IF(someplatform)", 1],
58 ["IF(not someplatform)", 0],
59 ["UNLESS(someplatform)", 0],
60 ["UNLESS(not someplatform)", 1],
63 ["IF(value==xxy)", 0],
64 ["UNLESS(value==xx)", 0],
65 ["UNLESS(value==xxy)", 1],
66 ["IF(true & (value==xx & (!false)))",1],
68 #["IF(value == xx)", 0], # invalid op error
69 #["IF(value = xx)", 0], # invalid op error
70 ["IF(value=xx)", 0], # also invalid, no warning. checks for key value=xx
74 use Test::More tests => (7 + @cond_tests);
78 use_ok('config::gen::makefiles');
80 use Parrot::Configure::Options qw( process_options );
81 use Parrot::Configure::Step::Test;
82 use Parrot::Configure::Test qw(
83 test_step_constructor_and_description
86 ########## regular ##########
88 my ($args, $step_list_ref) = process_options(
95 my $conf = Parrot::Configure::Step::Test->new;
96 $conf->include_config_results( $args );
97 my $pkg = 'gen::makefiles';
99 $conf->add_steps($pkg);
100 $conf->options->set( %{$args} );
102 my $step = test_step_constructor_and_description($conf);
103 my $missing_SOURCE = 0;
104 my %makefiles = %{ $step->{makefiles} };
106 foreach my $k ( keys %makefiles ) {
107 $missing_SOURCE++ unless (-f $makefiles{$k}{SOURCE});
110 is($missing_SOURCE, 0, "No Makefile source file missing");
123 $s .= ("_".++$index) if $s =~ /^(ELSE|ELSIF)/;
125 return $s."=".($c->[1]?"true":"false");
128 # test #IF(keys):line
129 $conf->data->set( @conf_args, ('osname' => 'someplatform' ) );
131 open my $IN, ">", "Makefile_$$.in";
132 print $IN "# There should only be =true results in .out\n";
133 for my $c (@cond_tests) {
134 my $result = result($c);
135 print $IN "#$c->[0]:$result\n";
140 $conf->genfile("Makefile_$$.in", "Makefile_$$.out",
141 (makefile => 1, conditioned_lines => 1));
143 open my $OUT, "<", "Makefile_$$.out";
154 for my $c (@cond_tests) {
155 my $result = result($c);
156 if ($c->[2] and $c->[2] =~ /^TODO(.*)$/) {
158 ok(($c->[1] ? $f =~ /^$result$/m : $f !~ /^$result$/m), "$result");
161 ok(($c->[1] ? $f =~ /^$result$/m : $f !~ /^$result$/m), "$result".($c->[2]?" $c->[2]":''));
165 # TT #279: reporting the makefile line number
166 # step gen::makefiles died during execution:
167 # invalid op "IF" in "#IF(bla)" at "(bla)" at Configure.pl line 72
168 open $IN, ">", "Makefile_$$.in";
169 print $IN "# Test reporting sourcefile line numbers. TT #279\n";
170 print $IN "#IF(IF(bla)):test\n";
173 $conf->genfile("Makefile_$$.in", "Makefile_$$.out",
174 (makefile => 1, conditioned_lines => 1));
178 ok($error eq "invalid op \"bla\" in \"IF(bla)\" at \"(bla)\" at Makefile_$$.in line 2\n",
179 "report correct error line");
181 pass("Completed all tests in $0");
184 unlink "Makefile_$$.in", "Makefile_$$.out", "Makefile_$$.out.tmp";
187 ################### DOCUMENTATION ###################
191 gen/makefiles-01.t - test gen::makefiles
195 % prove t/steps/gen/makefiles-01.t
199 The files in this directory test functionality used by F<Configure.pl>.
201 The tests in this file test gen::makefiles.
210 config::gen::makefiles, F<Configure.pl>.
216 # cperl-indent-level: 4
219 # vim: expandtab shiftwidth=4: