Skip to content

Commit

Permalink
Test self-referential (in top-level) hash asignment
Browse files Browse the repository at this point in the history
  • Loading branch information
zoffixznet committed Feb 28, 2017
1 parent c7bf3a0 commit 3cd5126
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion S09-typed-arrays/hashes.t
@@ -1,7 +1,7 @@
use v6;
use Test;

plan 43;
plan 44;

# L<S09/Typed arrays>

Expand Down Expand Up @@ -90,4 +90,37 @@ plan 43;
'.invert on typed Hash';
}

# RT#130870
subtest 'self-referential top-level hash assignment' => {
plan 4;

subtest '= self, other' => {
plan 2;
my %h1 = :1a; my %h2 = :2b;
is-deeply (%h1 = %h1, %h2), %(:1a, :2b), 'result of assignment';
is-deeply %h1, %(:1a, :2b), 'value in original hash';
}

subtest '= self, self' => {
plan 2;
my %h1 = :1a;
is-deeply (%h1 = %h1, %h1), %(:1a), 'result of assignment';
is-deeply %h1, %(:1a), 'value in original hash';
}

subtest '= self, other - clashing keys' => {
plan 2;
my %h1 = :1a, :2b; my %h2 = :4b, :3c;
is-deeply (%h1 = %h1, %h2), %(:1a, :4b, :3c), 'result of assignment';
is-deeply %h1, %(:1a, :4b, :3c), 'value in original hash';
}

subtest '= other, self - clashing keys' => {
plan 2;
my %h1 = :1a, :2b; my %h2 = :4b, :3c;
is-deeply (%h1 = %h2, %h1), %(:1a, :2b, :3c), 'result of assignment';
is-deeply %h1, %(:1a, :2b, :3c), 'value in original hash';
}
}

# vim: ft=perl6

0 comments on commit 3cd5126

Please sign in to comment.