Skip to content

Commit

Permalink
Add tests for pairup. (#174)
Browse files Browse the repository at this point in the history
* Add test for pairup keys and values.

* Add test for pairup list size.

* Use clearer test descriptions.

* Test for exceptions.
  • Loading branch information
hchienjo authored and zoffixznet committed Oct 20, 2016
1 parent 6c31fe3 commit 37c8fd4
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions S32-basics/pairup.t
Expand Up @@ -2,10 +2,17 @@ use v6;

use Test;

plan 1;
plan 5;

{
is-deeply Any.pairup(), (), 'pairup on an undefined invocant returns an empty list'
is-deeply Any.pairup(), (), 'pairup on an undefined invocant returns an empty list';
my @nums = 1..6;
my %h = @nums.pairup;
is(@nums.pairup.elems, 3, 'pairup returns correct list size');
is-deeply(%h.keys.sort, ('1', '3', '5'), 'hash constructed from pairup has correct keys');
is-deeply(%h.values.sort, (2, 4, 6), 'hash constructed from pairup has correct values');
@nums.push(7);
dies-ok(sub{@nums.pairup}, 'pairup on odd numbered list size throws exception');
}

# vim: ft=perl6

0 comments on commit 37c8fd4

Please sign in to comment.