o Test that elections with a single vote return the expected result.
[rubyvote] / lib / rubyvote / condorcet.rb
index 68b3c708d25fa324dd2d361b210fc10fd0184a08..340be9273f05fe7915a74902b4c049f8985834c8 100644 (file)
@@ -76,8 +76,6 @@ class CondorcetVote < ElectionVote
 
           # make sure we have a comparable object
           @votes[loser][winner] = 0 unless @votes[loser].has_key?( winner )
-
-          @candidates << loser unless @candidates.include?( loser )
         end
       end
     end
@@ -135,6 +133,7 @@ class CondorcetResult < ElectionResult
     votes = @election.votes unless votes
 
     defeats = Array.new
+    candidates = [candidates] unless candidates.class == Array
     candidates.each do |candidate|
       candidates.each do |challenger|
         next if candidate == challenger
@@ -206,6 +205,7 @@ class CloneproofSSDResult < CondorcetResult
       # see the array with the standard defeats
       transitive_defeats = self.defeats(candidates, votes)
 
+      candidates = [candidates] unless candidates.class == Array
       candidates.each do |cand1|
         candidates.each do |cand2|
           candidates.each do |cand3|

Benjamin Mako Hill || Want to submit a patch?