Skip to content

Instantly share code, notes, and snippets.

@kfly8
Created April 2, 2014 02:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kfly8/9927234 to your computer and use it in GitHub Desktop.
Save kfly8/9927234 to your computer and use it in GitHub Desktop.
#!/usr/bin/env perl
use 5.10.0;
use strict;
use warnings;
use Test::More;
sub hoge {
my %ret;
for my $row (@_) {
$ret{$row->[0]}{$row->[1]} = $row->[2];
}
%ret;
}
is_deeply +{
hoge(
[qw/1 1 hello/],
[qw/1 2 world/],
[qw/2 2 good/],
[qw/2 3 bad/],
)
}, +{
1 => +{
1 => 'hello',
2 => 'world',
},
2 => +{
2 => 'good',
3 => 'bad',
},
};
done_testing;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment