Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 49 lines (38 sloc) 1.151 kB
f4697e2 [spec] moved var/is_rw.t to spec/
moritz authored
1 use v6;
2
3 use Test;
4
a493f00 @moritz test that "is rw" requires a variable for writing (RT #74820)
moritz authored
5 plan 7;
0a51f84 [spec] S06-traits/is-rw.t: added smartlink, fudged for rakudo
moritz authored
6 # L<S06/"Parameter traits"/"=item is rw">
7
f4697e2 [spec] moved var/is_rw.t to spec/
moritz authored
8
9 {
10 sub foo($a is rw) {
11 $a = 42;
12 return 19;
13 }
14
15 my $bar = 23;
16 is $bar, 23, "basic sanity";
17 is foo($bar), 19, "calling a sub with an is rw param";
18 is $bar, 42, "sub changed our variable";
a493f00 @moritz test that "is rw" requires a variable for writing (RT #74820)
moritz authored
19 # RT #74830
709e414 @lizmat s/dies_ok/dies-ok/g
lizmat authored
20 dies-ok { EVAL('foo(28)') }, 'is rw requires a variable';
f4697e2 [spec] moved var/is_rw.t to spec/
moritz authored
21 }
22
23 {
24 my $anon = -> $a is rw { $a++ };
25 my $bar = 10;
26 $anon.($bar);
27 is($bar, 11, "anon sub changed variable");
28 }
29
30 # See thread "is rw basically a null-op on objects/references?" on p6l
31 # L<"http://www.nntp.perl.org/group/perl.perl6.language/20671">
32 {
33 my %hash = (a => 23);
34 # First check .value = ... works (as this is a dependency for the next test)
35 try { %hash.pairs[0].value = 42 };
3d4f970 @usev6 Use unique ticket numer for RT #124640
usev6 authored
36 #?rakudo todo 'RT #124640'
f4697e2 [spec] moved var/is_rw.t to spec/
moritz authored
37 is %hash<a>, 42, "pairs are mutable";
38
ea0874c [is-rw.t] s/\xa0/\x20/g
lwall authored
39 for %hash.pairs -> $pair { # Note: No "is rw"!
40 try { $pair.value += 100 }; # Modifies %hash
41 }
3d4f970 @usev6 Use unique ticket numer for RT #124640
usev6 authored
42 #?rakudo todo 'Depends on preceding test working RT #124640'
f4697e2 [spec] moved var/is_rw.t to spec/
moritz authored
43 is %hash<a>, 142, "'is rw' not necessary on objects/references";
44 }
45
46 # for ... -> ... is rw {...} already tested for in t/statements/for.t.
7f29bc5 [t/spec] Add vim: lines everywhere.
kyle authored
47
48 # vim: ft=perl6
Something went wrong with that request. Please try again.