Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
add tests for antipairs
- Loading branch information
Showing
1 changed file
with
25 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| use v6; | ||
| use Test; | ||
|
|
||
| # L<S32::Containers/Hash/antipairs> | ||
|
|
||
| plan 5; | ||
|
|
||
| { | ||
| my %h = a => 'b', c => 'd'; | ||
| isa-ok %h.antipairs, Seq, 'Hash.antipairs returns a Seq'; | ||
| #?niecza todo 'Cannot use value like Pair as a number' | ||
| is-deeply %h.antipairs.sort.list, (b => 'a', d => 'c'), 'simple Hash.antipairs works'; | ||
| is-deeply %h, { a => 'b', c => 'd' }, 'original remains unchanged'; | ||
| } | ||
|
|
||
| { | ||
| # with lists | ||
| my %h = a => <b c>, d => 'e'; | ||
| #?niecza todo 'Cannot use value like Pair as a number' | ||
| is-deeply %h.antipairs.sort.list, (<b c> => 'a', e => 'd'), | ||
| 'Hash.antipairs does not flatten list values'; | ||
| is-deeply %h, {a => <b c>, d => 'e'}, 'original remains unchanged'; | ||
| } | ||
|
|
||
| # vim: ft=perl6 |