Permalink
Browse files

[t/spec] Tests for prefix and postfix array hypers with nested hashes.

git-svn-id: http://svn.pugscode.org/pugs@31102 c213334d-75ef-0310-aa23-eaa082d1ae64
  • Loading branch information...
1 parent f0ac25a commit 60d1184626ff731db65202d290b2652ad63fd7b4 colomon committed Jun 4, 2010
Showing with 57 additions and 0 deletions.
  1. +57 −0 S03-metaops/hyper.t
View
@@ -610,6 +610,63 @@ my @e;
is @r[5], "4f", 'hash in array - correct result from «~»';
}
+{
+ my @a = (1, { a => 2, b => 3 }, 4);
+ my @r = -<<@a;
+ is +@r, 3, 'hash in array - result array is the correct length';
+ is @r[0], -1, 'hash in array - correct result from -<<';
+ is @r[1]<a>, -2, 'hash in array - correct result from -<<';
+ is @r[1]<b>, -3, 'hash in array - correct result from -<<';
+ is @r[2], -4, 'hash in array - correct result from -<<';
+
+ @r = ++<<@a;
+ is +@r, 3, 'hash in array - result array is the correct length';
+ is @r[0], 2, 'hash in array - correct result from ++<<';
+ is @r[1]<a>, 3, 'hash in array - correct result from ++<<';
+ is @r[1]<b>, 4, 'hash in array - correct result from ++<<';
+ is @r[2], 5, 'hash in array - correct result from ++<<';
+
+ @r = @a>>--;
+ is +@r, 3, 'hash in array - result array is the correct length';
+ is @r[0], 2, 'hash in array - correct result from ++<<';
+ is @r[1]<a>, 3, 'hash in array - correct result from ++<<';
+ is @r[1]<b>, 4, 'hash in array - correct result from ++<<';
+ is @r[2], 5, 'hash in array - correct result from ++<<';
+ is +@a, 3, 'hash in array - result array is the correct length';
+ is @a[0], 1, 'hash in array - correct result from ++<<';
+ is @a[1]<a>, 2, 'hash in array - correct result from ++<<';
+ is @a[1]<b>, 3, 'hash in array - correct result from ++<<';
+ is @a[2], 4, 'hash in array - correct result from ++<<';
+}
+
+{
+ my @a = (1, { a => 2, b => 3 }, 4);
+ my @r = -«@a;
+ is +@r, 3, 'hash in array - result array is the correct length';
+ is @r[0], -1, 'hash in array - correct result from -«';
+ is @r[1]<a>, -2, 'hash in array - correct result from -«';
+ is @r[1]<b>, -3, 'hash in array - correct result from -«';
+ is @r[2], -4, 'hash in array - correct result from -«';
+
+ @r = ++«@a;
+ is +@r, 3, 'hash in array - result array is the correct length';
+ is @r[0], 2, 'hash in array - correct result from ++«';
+ is @r[1]<a>, 3, 'hash in array - correct result from ++«';
+ is @r[1]<b>, 4, 'hash in array - correct result from ++«';
+ is @r[2], 5, 'hash in array - correct result from ++«';
+
+ @r = @a»--;
+ is +@r, 3, 'hash in array - result array is the correct length';
+ is @r[0], 2, 'hash in array - correct result from ++«';
+ is @r[1]<a>, 3, 'hash in array - correct result from ++«';
+ is @r[1]<b>, 4, 'hash in array - correct result from ++«';
+ is @r[2], 5, 'hash in array - correct result from ++«';
+ is +@a, 3, 'hash in array - result array is the correct length';
+ is @a[0], 1, 'hash in array - correct result from ++«';
+ is @a[1]<a>, 2, 'hash in array - correct result from ++«';
+ is @a[1]<b>, 3, 'hash in array - correct result from ++«';
+ is @a[2], 4, 'hash in array - correct result from ++«';
+}
# test non-UTF-8 input
#?pugs skip 'eval(Buf)'

0 comments on commit 60d1184

Please sign in to comment.