[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
FYI: remove Automake::DisjConditions::permutations
From: |
Alexandre Duret-Lutz |
Subject: |
FYI: remove Automake::DisjConditions::permutations |
Date: |
Sun, 02 Feb 2003 11:09:13 +0100 |
User-agent: |
Gnus/5.090008 (Oort Gnus v0.08) Emacs/21.2 (i386-pc-linux-gnu) |
Hurrah!
2003-02-02 Alexandre Duret-Lutz <address@hidden>
* lib/Automake/DisjConditions.pm (_permutations_worker)
(permutations): Remove, so that people aren't tempted to use it.
* lib/Automake/tests/DisjConditions.pl (tests_permutations): Remove.
Index: lib/Automake/DisjConditions.pm
===================================================================
RCS file: /cvs/automake/automake/lib/Automake/DisjConditions.pm,v
retrieving revision 1.1
diff -u -r1.1 DisjConditions.pm
--- lib/Automake/DisjConditions.pm 19 Jan 2003 23:01:03 -0000 1.1
+++ lib/Automake/DisjConditions.pm 2 Feb 2003 10:07:31 -0000
@@ -61,10 +61,6 @@
# "(COND1 and !COND2) or (!COND3)"
my $str = $set->human;
- # Build a new DisjConditions from the permuation of all
- # Conditions appearing in $set.
- my $perm = $set->permutations;
-
# Invert a DisjConditions, i.e., create a new DisjConditions
# that complements $set.
my $inv = $set->invert;
@@ -292,86 +288,6 @@
return $res;
}
-
-sub _permutations_worker (@)
-{
- my @conds = @_;
- return () unless @conds;
-
- my $cond = shift @conds;
-
- # Ignore "TRUE" conditions, since they add nothing to permutations.
- return &_permutations_worker (@conds) if $cond eq "TRUE";
-
- (my $neg = $cond) =~ s/TRUE$/FALSE/;
-
- # Recurse.
- my @ret = ();
- foreach my $c (&_permutations_worker (@conds))
- {
- push (@ret, $c->merge_conds ($cond));
- push (@ret, $c->merge_conds ($neg));
- }
- if (! @ret)
- {
- push (@ret, new Automake::Condition $cond);
- push (@ret, new Automake::Condition $neg);
- }
-
- return @ret;
-}
-
-=item C<$perm = $set-E<gt>permutations>
-
-Return a permutations of the conditions involved in a C<DisjConditions>.
-
-For instance consider this initial C<DisjConditions>.
-
- my $set = new Automake::DisjConditions
- (new Automake::Condition ("COND1_TRUE", "COND2_TRUE"),
- new Automake::Condition ("COND3_FALSE", "COND2_TRUE"));
-
-Calling C<$set-E<gt>permutations> will return the following DisjConditions.
-
- new Automake::DisjConditions
- (new Automake::Condition ("COND1_TRUE", "COND2_TRUE", "COND3_TRUE"),
- new Automake::Condition ("COND1_FALSE","COND2_TRUE", "COND3_TRUE"),
- new Automake::Condition ("COND1_TRUE", "COND2_FALSE","COND3_TRUE"),
- new Automake::Condition ("COND1_FALSE","COND2_FALSE","COND3_TRUE"),
- new Automake::Condition ("COND1_TRUE", "COND2_TRUE", "COND3_FALSE"),
- new Automake::Condition ("COND1_FALSE","COND2_TRUE", "COND3_FALSE"),
- new Automake::Condition ("COND1_TRUE", "COND2_FALSE","COND3_FALSE"),
- new Automake::Condition ("COND1_FALSE","COND2_FALSE","COND3_FALSE"));
-
-=cut
-
-sub permutations ($ )
-{
- my ($self) = @_;
-
- return $self->{'permutations'} if defined $self->{'permutations'};
-
- my %atomic_conds = ();
-
- for my $conditional ($self->conds)
- {
- for my $cond ($conditional->conds)
- {
- $cond =~ s/FALSE$/TRUE/;
- $atomic_conds{$cond} = 1;
- }
- }
-
- my @res = _permutations_worker (keys %atomic_conds);
- # An empty permutation is TRUE, because we ignore TRUE conditions
- # in the recursions.
- @res = (TRUE) unless @res;
- my $res = new Automake::DisjConditions @res;
-
- $self->{'permutations'} = $res;
-
- return $res;
-}
=item C<$prod = $set1->multiply ($set2)>
Index: lib/Automake/tests/DisjConditions.pl
===================================================================
RCS file: /cvs/automake/automake/lib/Automake/tests/DisjConditions.pl,v
retrieving revision 1.1
diff -u -r1.1 DisjConditions.pl
--- lib/Automake/tests/DisjConditions.pl 19 Jan 2003 23:01:03 -0000
1.1
+++ lib/Automake/tests/DisjConditions.pl 2 Feb 2003 10:07:31 -0000
@@ -44,61 +44,6 @@
return new Automake::DisjConditions @set;
}
-sub test_permutations ()
-{
- my @tests = ([[["FALSE"]],
- [["TRUE"]]],
-
- [[["TRUE"]],
- [["TRUE"]]],
-
- [[["COND1_TRUE", "COND2_TRUE"],
- ["COND3_FALSE", "COND2_TRUE"]],
- [["COND1_FALSE","COND2_FALSE","COND3_FALSE"],
- ["COND1_TRUE", "COND2_FALSE","COND3_FALSE"],
- ["COND1_FALSE","COND2_TRUE", "COND3_FALSE"],
- ["COND1_TRUE", "COND2_TRUE", "COND3_FALSE"],
- ["COND1_FALSE","COND2_FALSE","COND3_TRUE"],
- ["COND1_TRUE", "COND2_FALSE","COND3_TRUE"],
- ["COND1_FALSE","COND2_TRUE", "COND3_TRUE"],
- ["COND1_TRUE", "COND2_TRUE", "COND3_TRUE"]]],
-
- [[["COND1_TRUE", "COND2_TRUE"],
- ["TRUE"]],
- [["COND1_TRUE", "COND2_TRUE"],
- ["COND1_FALSE", "COND2_TRUE"],
- ["COND1_FALSE", "COND2_FALSE"],
- ["COND1_TRUE", "COND2_FALSE"]]],
-
- [[["COND1_TRUE", "COND2_TRUE"],
- ["FALSE"]],
- [["COND1_TRUE", "COND2_TRUE"],
- ["COND1_FALSE", "COND2_TRUE"],
- ["COND1_FALSE", "COND2_FALSE"],
- ["COND1_TRUE", "COND2_FALSE"]]],
-
- [[["COND1_TRUE"],
- ["COND2_FALSE"]],
- [["COND1_TRUE", "COND2_TRUE"],
- ["COND1_FALSE", "COND2_TRUE"],
- ["COND1_FALSE", "COND2_FALSE"],
- ["COND1_TRUE", "COND2_FALSE"]]]
- );
-
- for my $t (@tests)
- {
- my $set = build_set @{$t->[0]};
- my $res = build_set @{$t->[1]};
- my $per = $set->permutations;
- if ($per != $res)
- {
- print " (P) " . $per->string . ' != ' . $res->string . "\n";
- return 1;
- }
- }
- return 0;
-}
-
sub test_invert ()
{
my @tests = ([[["FALSE"]],
@@ -302,7 +247,7 @@
# Also exercize invert() while we are at it.
- # FIXME: Don't run invert() with too much conditions, this is too slow.
+ # FIXME: Can't run invert() with too much conditions, this is too slow.
next if $#{$t->[0][0]} > 8;
my $inv1 = $set->invert->simplify;
@@ -381,7 +326,6 @@
}
exit (test_basics
- || test_permutations
|| test_invert
|| test_simplify
|| test_sub_conditions);
--
Alexandre Duret-Lutz
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- FYI: remove Automake::DisjConditions::permutations,
Alexandre Duret-Lutz <=