~ubuntu-branches/ubuntu/utopic/spamassassin/utopic-proposed

« back to all changes in this revision

Viewing changes to t/rule_names.t

  • Committer: Bazaar Package Importer
  • Author(s): Noah Meyerhans
  • Date: 2010-01-26 22:53:12 UTC
  • mfrom: (1.1.13 upstream) (5.1.7 sid)
  • Revision ID: james.westby@ubuntu.com-20100126225312-wkftb10idc1kz2aq
Tags: 3.3.0-1
* New upstream version.
* Switch to dpkg-source 3.0 (quilt) format

Show diffs side-by-side

added added

removed removed

Lines of Context:
18
18
use strict;
19
19
use SATest; sa_t_init("rule_names");
20
20
use Test;
21
 
 
22
21
use Mail::SpamAssassin;
23
 
use Digest::SHA1;
 
22
 
 
23
BEGIN {
 
24
  eval { require Digest::SHA; import Digest::SHA qw(sha1); 1 }
 
25
  or do { require Digest::SHA1; import Digest::SHA1 qw(sha1) }
 
26
}
 
27
 
24
28
use vars qw(%patterns %anti_patterns);
25
29
 
26
30
# initialize SpamAssassin
122
126
# Fisher-Yates shuffle
123
127
sub fy_shuffle {
124
128
  for (my $i = $#_; $i > 0; $i--) {
125
 
    @_[$_,$i] = @_[$i,$_] for rand $i+1;
 
129
    @_[$_,$i] = @_[$i,$_] for int rand($i+1);
126
130
  }
127
131
  return @_;
128
132
}
132
136
  my $i = shift;
133
137
  return map { $_->[0] }
134
138
         sort { $a->[1] cmp $b->[1] }
135
 
         map { [$_, Digest::SHA1::sha1($_ . $i)] }
 
139
         map { [$_, sha1($_ . $i)] }
136
140
         @_;
137
141
}