~ubuntu-branches/ubuntu/trusty/libperl5i-perl/trusty-proposed

« back to all changes in this revision

Viewing changes to t/flip.t

  • Committer: Bazaar Package Importer
  • Author(s): Ivan Kohler
  • Date: 2010-05-08 17:42:00 UTC
  • Revision ID: james.westby@ubuntu.com-20100508174200-7ogg0zrimh9gvcuw
Tags: upstream-2.1.1
ImportĀ upstreamĀ versionĀ 2.1.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/env perl
 
2
 
 
3
use perl5i::latest;
 
4
 
 
5
use lib 't/lib';
 
6
use Test::More;
 
7
use Test::perl5i;
 
8
 
 
9
my %hash = ( 1 => 'foo', 2 => 'bar', 3 => 'bar' );
 
10
my $f;
 
11
 
 
12
is_deeply( $f = %hash->flip, { foo => 1, bar => 3 } );
 
13
 
 
14
my %f = %hash->flip;
 
15
 
 
16
is_deeply( \%f, { foo => 1, bar => 3 }, "Returns hash in list context" );
 
17
 
 
18
my %nested = ( 1 => { foo => 'bar' }, 2 => 'bar' );
 
19
 
 
20
dies_ok  { %nested->flip } 'Dies if values are not valid hash keys';
 
21
 
 
22
done_testing;