Skip to content

@notbenh /annon_hash_eq_list.t
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
annon { $label => ...} with out assignment is seen as a list?
#!/usr/bin/env perl
use strict;
use warnings;
use Test::Most qw{no_plan};
my $data = [{ label => {key => 'value'}}];
eq_or_diff
[ map{ my $hash = $_;
my $x =
{ map { my $label = $_;
$label => $hash->{$label}
} keys %$hash
}
} @$data
],
[ map{ my $hash = $_;
#my $x =
{ map { my $label = $_;
$label => $hash->{$label}
} keys %$hash
}
} @$data
],
q| annon { $label => ...} with out assignment is seen as a list? |;
__END__
not ok 1 - annon { $label => ...} with out assignment is seen as a list?
# Failed test ' annon { $label => ...} with out assignment is seen as a list? '
# at data_eq.t line 17.
# +----+----------------------+----+--------------------+
# | Elt|Got | Elt|Expected |
# +----+----------------------+----+--------------------+
# | 0|[ | 0|[ |
# | | * 1| 'label', *
# | 1| { | 2| { |
# * 2| label => { * 3| key => 'value' *
# * 3| key => 'value' * | |
# * 4| } * | |
# | 5| } | 4| } |
# | 6|] | 5|] |
# +----+----------------------+----+--------------------+
1..1
# Looks like you failed 1 test of 1.
@schwern

I think it's interpreting the braces as a bare block.

@schwern

You can stick "scalar" or + in front of the { to force Perl to interpret it as a hash ref.

@notbenh
Owner

Ahhhh. Bare block that makes sence.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.