Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[t/spec] Tests for hypers on arrays containing hashes.

git-svn-id: http://svn.pugscode.org/pugs@31094 c213334d-75ef-0310-aa23-eaa082d1ae64
  • Loading branch information...
commit 41b685333d868209d5d41adb9db663bb338130fb 1 parent ec20f69
colomon authored
Showing with 93 additions and 0 deletions.
  1. +93 −0 S03-metaops/hyper.t
View
93 S03-metaops/hyper.t
@@ -518,6 +518,99 @@ my @e;
is %r<c>, 8, 'hash - correct result from <<**>>';
}
+{
+ my @a = (1, { a => 2, b => 3 }, 4);
+ my @b = <a b c>;
+ my @c = ('z', { a => 'y', b => 'x' }, 'w');
+ my @d = 'a'..'f';
+
+ my @r = @a <<~>> @b;
+ is +@r, 3, 'hash in array - result array is the correct length';
+ is @r[0], "1a", 'hash in array - correct result from <<~>>';
+ is @r[1]<a>, "2b", 'hash in array - correct result from <<~>>';
+ is @r[1]<b>, "3b", 'hash in array - correct result from <<~>>';
+ is @r[2], "4c", 'hash in array - correct result from <<~>>';
+
+ @r = @a >>~<< @c;
+ is +@r, 3, 'hash in array - result array is the correct length';
+ is @r[0], "1z", 'hash in array - correct result from >>~<<';
+ is @r[1]<a>, "2y", 'hash in array - correct result from >>~<<';
+ is @r[1]<b>, "3x", 'hash in array - correct result from >>~<<';
+ is @r[2], "4w", 'hash in array - correct result from >>~<<';
+
+ @r = @a >>~>> @d;
+ is +@r, 3, 'hash in array - result array is the correct length';
+ is @r[0], "1a", 'hash in array - correct result from >>~>>';
+ is @r[1]<a>, "2b", 'hash in array - correct result from >>~>>';
+ is @r[1]<b>, "3b", 'hash in array - correct result from >>~>>';
+ is @r[2], "4c", 'hash in array - correct result from >>~>>';
+
+ @r = @d <<R~<< @a;
+ is +@r, 3, 'hash in array - result array is the correct length';
+ is @r[0], "1a", 'hash in array - correct result from <<R~<<';
+ is @r[1]<a>, "2b", 'hash in array - correct result from <<R~<<';
+ is @r[1]<b>, "3b", 'hash in array - correct result from <<R~<<';
+ is @r[2], "4c", 'hash in array - correct result from <<R~<<';
+
+ @r = @a <<~>> @d;
+ is +@r, 6, 'hash in array - result array is the correct length';
+ is @r[0], "1a", 'hash in array - correct result from <<~>>';
+ is @r[1]<a>, "2b", 'hash in array - correct result from <<~>>';
+ is @r[1]<b>, "3b", 'hash in array - correct result from <<~>>';
+ is @r[2], "4c", 'hash in array - correct result from <<~>>';
+ is @r[3], "1d", 'hash in array - correct result from <<~>>';
+ is @r[4]<a>, "2e", 'hash in array - correct result from <<~>>';
+ is @r[4]<b>, "3e", 'hash in array - correct result from <<~>>';
+ is @r[5], "4f", 'hash in array - correct result from <<~>>';
+}
+
+{
+ my @a = (1, { a => 2, b => 3 }, 4);
+ my @b = <a b c>;
+ my @c = ('z', { a => 'y', b => 'x' }, 'w');
+ my @d = 'a'..'f';
+
+ my @r = @a «~» @b;
+ is +@r, 3, 'hash in array - result array is the correct length';
+ is @r[0], "1a", 'hash in array - correct result from «~»';
+ is @r[1]<a>, "2b", 'hash in array - correct result from «~»';
+ is @r[1]<b>, "3b", 'hash in array - correct result from «~»';
+ is @r[2], "4c", 'hash in array - correct result from «~»';
+
+ @r = @a »~« @c;
+ is +@r, 3, 'hash in array - result array is the correct length';
+ is @r[0], "1z", 'hash in array - correct result from »~«';
+ is @r[1]<a>, "2y", 'hash in array - correct result from »~«';
+ is @r[1]<b>, "3x", 'hash in array - correct result from »~«';
+ is @r[2], "4w", 'hash in array - correct result from »~«';
+
+ @r = @a »~» @d;
+ is +@r, 3, 'hash in array - result array is the correct length';
+ is @r[0], "1a", 'hash in array - correct result from »~»';
+ is @r[1]<a>, "2b", 'hash in array - correct result from »~»';
+ is @r[1]<b>, "3b", 'hash in array - correct result from »~»';
+ is @r[2], "4c", 'hash in array - correct result from »~»';
+
+ @r = @d «R~« @a;
+ is +@r, 3, 'hash in array - result array is the correct length';
+ is @r[0], "1a", 'hash in array - correct result from «R~«';
+ is @r[1]<a>, "2b", 'hash in array - correct result from «R~«';
+ is @r[1]<b>, "3b", 'hash in array - correct result from «R~«';
+ is @r[2], "4c", 'hash in array - correct result from «R~«';
+
+ @r = @a «~» @d;
+ is +@r, 6, 'hash in array - result array is the correct length';
+ is @r[0], "1a", 'hash in array - correct result from «~»';
+ is @r[1]<a>, "2b", 'hash in array - correct result from «~»';
+ is @r[1]<b>, "3b", 'hash in array - correct result from «~»';
+ is @r[2], "4c", 'hash in array - correct result from «~»';
+ is @r[3], "1d", 'hash in array - correct result from «~»';
+ is @r[4]<a>, "2e", 'hash in array - correct result from «~»';
+ is @r[4]<b>, "3e", 'hash in array - correct result from «~»';
+ is @r[5], "4f", 'hash in array - correct result from «~»';
+}
+
+
# test non-UTF-8 input
#?pugs skip 'eval(Buf)'
#?rakudo skip 'eval(Buf)'
Please sign in to comment.
Something went wrong with that request. Please try again.