Skip to content

Instantly share code, notes, and snippets.

@notbenh
Created May 19, 2015 01:16
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 notbenh/42cd79ea09f384f249aa to your computer and use it in GitHub Desktop.
Save notbenh/42cd79ea09f384f249aa to your computer and use it in GitHub Desktop.
How to group possible bundles when given only part_ids
#!/usr/bin/env perl
use strict;
use warnings;
use Test::More;
my $bundle = {
A => [qw{box widget1}],
B => [qw{box widget1 widget2}],
C => [qw{box widget1 widget3}],
D => [qw{box widget1 widget2 widget3}]
};
sub group_ids{
my $return = {};
# ???
return $return;
}
is_deeply group_ids(@{ $bundle->{A} }),
{ A=>[[qw{box widget1}]] },
q{A only};
is_deeply group_ids(@{ $bundle->{A}},
@{ $bundle->{D}},
@{ $bundle->{D}},
qw{ widget1 widget1},
),
{ A => [[qw{box widget1}]],
D => [ [qw{box widget1 widget2 widget3}],
[qw{box widget1 widget2 widget3}],
],
other => [['widget1'],['widget1']]
},
q{A,D,D, and two widget1s};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment