summary |
shortlog |
log |
commit | commitdiff |
tree
raw |
patch |
inline | side by side (from parent 1:
cf5965f)
if vote.length - 1 == index
losers = []
else
if vote.length - 1 == index
losers = []
else
- losers = vote.last( vote.flatten.length - index )
+ losers = vote.flatten.last( vote.flatten.length - index - 1)
end
losers.each do |place|
place = [place] unless place.class == Array
place.each do |loser|
end
losers.each do |place|
place = [place] unless place.class == Array
place.each do |loser|
- next if winner == loser
@votes[winner] = Hash.new unless @votes.has_key?(winner)
@votes[loser] = Hash.new unless @votes.has_key?(loser)
@votes[winner] = Hash.new unless @votes.has_key?(winner)
@votes[loser] = Hash.new unless @votes.has_key?(loser)
- top_result = resultFactory( self )
- until @candidates.empty?
- aResult = resultFactory( self )
- top_result.full_results << aResult
- filter_out(aResult)
- end
- top_result
def resultFactory(init)
CloneproofSSDResult.new(init)
end
def resultFactory(init)
CloneproofSSDResult.new(init)
end
+
+ def result
+ top_result = resultFactory( self )
+ until @candidates.empty?
+ aResult = resultFactory( self )
+ top_result.full_results << aResult
+ filter_out(aResult)
+ end
+ top_result
+ end
+
end
def filter_out(winner)
end
def filter_out(winner)
- if winner.winners[0].class == Array
- to_filter = winner.winners[0]
- else
- to_filter = [winner.winners[0]]
- end
- @candidates.delete_if {|x| to_filter.include?(x)}
+ @candidates.delete_if {|x| winner.winners.include?(x)}
assert_equal [[78]], result.get_full_results
end
assert_equal [[78]], result.get_full_results
end
+ def test_ssd_sparse
+ vote_array = Array.new
+ vote_array << ['B', 'D']
+ vote_array << ['A', 'C']
+ vote_array << ['E', 'C']
+ result = CloneproofSSDVote.new(vote_array).result
+ assert_equal 5, result.get_full_results.flatten.size
+ end
+