Permalink
Browse files

Checking in changes prior to tagging of version 0.02.

Changelog diff is:

diff --git a/Changes b/Changes
index fc79d08..6fd3bdb 100644
--- a/Changes
+++ b/Changes
@@ -1,4 +1,9 @@
 Revision history for Perl extension Hash::Compact

-0.01    Thu Jun 23 23:36:55 2011
+0.02    2011-10-19
+
+        [TESTING ISSUE]
+        - added tests whether compact hashes will be correctly expanded
+
+0.01    2011-06-23
         - original version
  • Loading branch information...
1 parent a316a63 commit 1b76da28a8d5a136c38923ee85af5d7511634298 @kentaro committed Oct 18, 2011
Showing with 34 additions and 5 deletions.
  1. +6 −1 Changes
  2. +7 −4 lib/Hash/Compact.pm
  3. +21 −0 t/basic.t
View
@@ -1,4 +1,9 @@
Revision history for Perl extension Hash::Compact
-0.01 Thu Jun 23 23:36:55 2011
+0.02 2011-10-19
+
+ [TESTING ISSUE]
+ - added tests whether compact hashes will be correctly expanded
+
+0.01 2011-06-23
- original version
View
@@ -5,7 +5,7 @@ use warnings;
use Carp qw(croak);
use Scalar::Util qw(blessed);
-our $VERSION = '0.01';
+our $VERSION = '0.02';
sub new {
my $class = shift;
@@ -47,16 +47,18 @@ sub param {
}
}
else {
- my $key = shift;
+ my $key = shift;
my $option = $self->options->{$key} || {};
- $value = $self->{$option->{alias_for} || $key} || $option->{default};
+
+ $value = $self->{$option->{alias_for} || $key} || $option->{default};
}
$value;
}
sub to_hash {
my $self = shift;
+
+{
map {
my $value = $self->{$_};
@@ -67,7 +69,8 @@ sub to_hash {
$_ => $value;
}
}
- grep { $_ ne '__OPTIONS__' } keys %$self }
+ grep { $_ ne '__OPTIONS__' } keys %$self
+ }
}
1;
View
@@ -92,6 +92,27 @@ subtest 'hash with options' => sub {
done_testing;
};
+subtest 'compact hash with options' => sub {
+ my $hash = Hash::Compact->new({
+ f => 'foo',
+ }, {
+ foo => {
+ alias_for => 'f',
+ },
+ bar => {
+ alias_for => 'b',
+ default => 'bar',
+ },
+ },
+ );
+
+ is $hash->param('foo'), 'foo';
+ is $hash->param('bar'), 'bar';
+ is_deeply $hash->to_hash, +{
+ f => 'foo',
+ };
+};
+
subtest 'pass some refs' => sub {
my $hash = Hash::Compact->new;
$hash->param(array => [qw(foo bar)]);

0 comments on commit 1b76da2

Please sign in to comment.