Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add tests for is copy in use with arrays and hashes.

git-svn-id: http://svn.pugscode.org/pugs@25314 c213334d-75ef-0310-aa23-eaa082d1ae64
  • Loading branch information...
commit 0de48a03bce835aea9726bb49fe5e4d967c77c88 1 parent 49d08c1
jnthn authored
Showing with 25 additions and 1 deletion.
  1. +25 −1 S06-traits/is-copy.t
View
26 S06-traits/is-copy.t
@@ -4,7 +4,7 @@ use Test;
# L<S06/"Parameter traits"/"=item is copy">
# should be moved with other subroutine tests?
-plan 10;
+plan 16;
{
sub foo($a is copy) {
@@ -36,3 +36,27 @@ plan 10;
is(copy_tester($baz, $quux), 25, 'calling with two arguments');
is($baz, 10, 'variable was not affected');
}
+
+# is copy with arrays
+{
+ sub array_test(@testc is copy) {
+ is(@testc[0], 1, 'array copied correctly by is copy');
+ @testc[0] = 123;
+ is(@testc[0], 123, 'can modify array copied by is copy...');
+ };
+ my @test = (1, 2, 3);
+ array_test(@test);
+ is(@test[0], 1, '...and original is unmodified.');
+}
+
+# is copy with hashes
+{
+ sub hash_test(%h is copy) {
+ is(%h<x>, 1, 'hash copied correctly by is copy');
+ %h<x> = 123;
+ is(%h<x>, 123, 'can modify hash copied by is copy...');
+ };
+ my %test = (x => 1);
+ hash_test(%test);
+ is(%test<x>, 1, '...and original is unmodified.');
+}
Please sign in to comment.
Something went wrong with that request. Please try again.