Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
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...
commit 1b76da28a8d5a136c38923ee85af5d7511634298 1 parent a316a63
@kentaro authored
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
7 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
View
11 lib/Hash/Compact.pm
@@ -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,9 +47,10 @@ 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;
@@ -57,6 +58,7 @@ sub param {
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
21 t/basic.t
@@ -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)]);
Please sign in to comment.
Something went wrong with that request. Please try again.