|
| 1 | +Execute (just the header if no input): |
| 2 | + let g:rows = [] |
| 3 | + let g:expected = ['Team | MP | W | D | L | P'] |
| 4 | + AssertEqual g:expected, Tally(g:rows) |
| 5 | + |
| 6 | +Execute (a win is three points, a loss is zero points): |
| 7 | + let g:rows = ['Allegoric Alaskans;Blithering Badgers;win'] |
| 8 | + let g:expected = ['Team | MP | W | D | L | P', 'Allegoric Alaskans | 1 | 1 | 0 | 0 | 3', 'Blithering Badgers | 1 | 0 | 0 | 1 | 0'] |
| 9 | + AssertEqual g:expected, Tally(g:rows) |
| 10 | + |
| 11 | +Execute (a win can also be expressed as a loss): |
| 12 | + let g:rows = ['Blithering Badgers;Allegoric Alaskans;loss'] |
| 13 | + let g:expected = ['Team | MP | W | D | L | P', 'Allegoric Alaskans | 1 | 1 | 0 | 0 | 3', 'Blithering Badgers | 1 | 0 | 0 | 1 | 0'] |
| 14 | + AssertEqual g:expected, Tally(g:rows) |
| 15 | + |
| 16 | +Execute (a different team can win): |
| 17 | + let g:rows = ['Blithering Badgers;Allegoric Alaskans;win'] |
| 18 | + let g:expected = ['Team | MP | W | D | L | P', 'Blithering Badgers | 1 | 1 | 0 | 0 | 3', 'Allegoric Alaskans | 1 | 0 | 0 | 1 | 0'] |
| 19 | + AssertEqual g:expected, Tally(g:rows) |
| 20 | + |
| 21 | +Execute (a draw is one point each): |
| 22 | + let g:rows = ['Allegoric Alaskans;Blithering Badgers;draw'] |
| 23 | + let g:expected = ['Team | MP | W | D | L | P', 'Allegoric Alaskans | 1 | 0 | 1 | 0 | 1', 'Blithering Badgers | 1 | 0 | 1 | 0 | 1'] |
| 24 | + AssertEqual g:expected, Tally(g:rows) |
| 25 | + |
| 26 | +Execute (There can be more than one match): |
| 27 | + let g:rows = ['Allegoric Alaskans;Blithering Badgers;win', 'Allegoric Alaskans;Blithering Badgers;win'] |
| 28 | + let g:expected = ['Team | MP | W | D | L | P', 'Allegoric Alaskans | 2 | 2 | 0 | 0 | 6', 'Blithering Badgers | 2 | 0 | 0 | 2 | 0'] |
| 29 | + AssertEqual g:expected, Tally(g:rows) |
| 30 | + |
| 31 | +Execute (There can be more than one winner): |
| 32 | + let g:rows = ['Allegoric Alaskans;Blithering Badgers;loss', 'Allegoric Alaskans;Blithering Badgers;win'] |
| 33 | + let g:expected = ['Team | MP | W | D | L | P', 'Allegoric Alaskans | 2 | 1 | 0 | 1 | 3', 'Blithering Badgers | 2 | 1 | 0 | 1 | 3'] |
| 34 | + AssertEqual g:expected, Tally(g:rows) |
| 35 | + |
| 36 | +Execute (There can be more than two teams): |
| 37 | + let g:rows = ['Allegoric Alaskans;Blithering Badgers;win', 'Blithering Badgers;Courageous Californians;win', 'Courageous Californians;Allegoric Alaskans;loss'] |
| 38 | + let g:expected = ['Team | MP | W | D | L | P', 'Allegoric Alaskans | 2 | 2 | 0 | 0 | 6', 'Blithering Badgers | 2 | 1 | 0 | 1 | 3', 'Courageous Californians | 2 | 0 | 0 | 2 | 0'] |
| 39 | + AssertEqual g:expected, Tally(g:rows) |
| 40 | + |
| 41 | +Execute (typical input): |
| 42 | + let g:rows = ['Allegoric Alaskans;Blithering Badgers;win', 'Devastating Donkeys;Courageous Californians;draw', 'Devastating Donkeys;Allegoric Alaskans;win', 'Courageous Californians;Blithering Badgers;loss', 'Blithering Badgers;Devastating Donkeys;loss', 'Allegoric Alaskans;Courageous Californians;win'] |
| 43 | + let g:expected = ['Team | MP | W | D | L | P', 'Devastating Donkeys | 3 | 2 | 1 | 0 | 7', 'Allegoric Alaskans | 3 | 2 | 0 | 1 | 6', 'Blithering Badgers | 3 | 1 | 0 | 2 | 3', 'Courageous Californians | 3 | 0 | 1 | 2 | 1'] |
| 44 | + AssertEqual g:expected, Tally(g:rows) |
| 45 | + |
| 46 | +Execute (incomplete competition (not all pairs have played)): |
| 47 | + let g:rows = ['Allegoric Alaskans;Blithering Badgers;loss', 'Devastating Donkeys;Allegoric Alaskans;loss', 'Courageous Californians;Blithering Badgers;draw', 'Allegoric Alaskans;Courageous Californians;win'] |
| 48 | + let g:expected = ['Team | MP | W | D | L | P', 'Allegoric Alaskans | 3 | 2 | 0 | 1 | 6', 'Blithering Badgers | 2 | 1 | 1 | 0 | 4', 'Courageous Californians | 2 | 0 | 1 | 1 | 1', 'Devastating Donkeys | 1 | 0 | 0 | 1 | 0'] |
| 49 | + AssertEqual g:expected, Tally(g:rows) |
| 50 | + |
| 51 | +Execute (ties broken alphabetically): |
| 52 | + let g:rows = ['Courageous Californians;Devastating Donkeys;win', 'Allegoric Alaskans;Blithering Badgers;win', 'Devastating Donkeys;Allegoric Alaskans;loss', 'Courageous Californians;Blithering Badgers;win', 'Blithering Badgers;Devastating Donkeys;draw', 'Allegoric Alaskans;Courageous Californians;draw'] |
| 53 | + let g:expected = ['Team | MP | W | D | L | P', 'Allegoric Alaskans | 3 | 2 | 1 | 0 | 7', 'Courageous Californians | 3 | 2 | 1 | 0 | 7', 'Blithering Badgers | 3 | 0 | 1 | 2 | 1', 'Devastating Donkeys | 3 | 0 | 1 | 2 | 1'] |
| 54 | + AssertEqual g:expected, Tally(g:rows) |
| 55 | + |
| 56 | +Execute (ensure points sorted numerically): |
| 57 | + let g:rows = ['Devastating Donkeys;Blithering Badgers;win', 'Devastating Donkeys;Blithering Badgers;win', 'Devastating Donkeys;Blithering Badgers;win', 'Devastating Donkeys;Blithering Badgers;win', 'Blithering Badgers;Devastating Donkeys;win'] |
| 58 | + let g:expected = ['Team | MP | W | D | L | P', 'Devastating Donkeys | 5 | 4 | 0 | 1 | 12', 'Blithering Badgers | 5 | 1 | 0 | 4 | 3'] |
| 59 | + AssertEqual g:expected, Tally(g:rows) |
0 commit comments