Changeset 214 for trunk/t


Ignore:
Timestamp:
04/17/09 15:32:47 (15 years ago)
Author:
nanardon
Message:
  • more results function, support empty ballots in voices count
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/t/10Vote_DB.t

    r213 r214  
    6060            a => { sbal => [ 'ch1' ] }, 
    6161            b => { sbal => [ 'ch1', 'ch10' ] }, 
    62             d => { sbal => [ 'ch1', 'ch2' ] }, 
     62            d => { sbal => [ 'ch1', 'ch2', 'ch4' ] }, 
    6363            f => {}, 
    6464        }, 
    65         test_count => 9, 
     65        test_count => 10, 
    6666        tests => sub { 
    6767            my ($r) = @_; 
     
    6969            is($r->absolute_majority, 2, "Can get absolute_majority"); 
    7070            is($r->ballot_count, 4, "can get ballot count"); 
    71             is($r->ballot_count_nonull, 3, "can get ballot count"); 
     71            is($r->not_empty_ballot_count, 3, "can get ballot count"); 
     72            is($r->empty_ballot_count, 1, "can get empty ballot count"); 
    7273            is($r->voting_count, 6, "can get voting count"); 
    7374            is($r->signing_count, 4, "can get signing count"); 
    74             my $res = $r->results_nonull; 
     75            my $res = $r->results; 
    7576            is($res->[0]->{value}, 'ch1', "winner is ch1"); 
    7677            is($res->[0]->{count}, 3, "winner has 3 voices"); 
    77             is(@$res, 3, "count of winners"); 
    78             is($res->[2]->{count}, 0, "last has 0 voices"); 
     78            is(@$res, 4, "count of winners"); 
     79            is($res->[3]->{count}, 0, "last has 0 voices"); 
     80        } 
     81    }, 
     82    { 
     83        poll => { 
     84            label => 'empty ballot count', 
     85            empty_ballot_has_voice => 1, 
     86        }, 
     87        choices => [ qw(ch1 ch2 ch3) ], 
     88        voting => [ qw(a b c d e f) ], 
     89        ballot => { 
     90            a => { sbal => [ 'ch1' ] }, 
     91            b => { sbal => [ 'ch1', 'ch2' ] }, 
     92            d => { sbal => [ 'ch1', 'ch2' ] }, 
     93            e => {}, 
     94            f => {}, 
     95        }, 
     96        test_count => 10, 
     97        tests => sub { 
     98            my ($r) = @_; 
     99            is($r->absolute_majority, 3, "Can get absolute_majority"); 
     100            is($r->ballot_count, 5, "can get ballot count"); 
     101            is($r->not_empty_ballot_count, 3, "can get ballot count"); 
     102            is($r->empty_ballot_count, 2, "can get empty ballot count"); 
     103            is($r->voting_count, 6, "can get voting count"); 
     104            is($r->signing_count, 5, "can get signing count"); 
     105            my $res = $r->results; 
     106            is($res->[0]->{value}, 'ch1', "winner is ch1"); 
     107            is($res->[0]->{count}, 3, "winner has 3 voices"); 
     108            is(@$res, 4, "count of winners"); 
     109            is($res->[3]->{count}, 0, "last has 0 voices"); 
    79110        } 
    80111    }, 
Note: See TracChangeset for help on using the changeset viewer.