Skip to content
This repository
Fetching contributors…

Cannot retrieve contributors at this time

file 22 lines (13 sloc) 0.443 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
#!/usr/bin/env perl

use perl5i::latest;

use lib 't/lib';
use Test::More;
use Test::perl5i;

my %hash = ( 1 => 'foo', 2 => 'bar', 3 => 'bar' );
my $f;

is_deeply( $f = %hash->flip, { foo => 1, bar => 3 } );

my %f = %hash->flip;

is_deeply( \%f, { foo => 1, bar => 3 }, "Returns hash in list context" );

my %nested = ( 1 => { foo => 'bar' }, 2 => 'bar' );

dies_ok { %nested->flip } 'Dies if values are not valid hash keys';

done_testing;
Something went wrong with that request. Please try again.