Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 57 lines (43 sloc) 1.442 kb
dd2b31bf » moritz
2008-09-03 [t] move var/is_readonly.t to spec
1 use v6;
2 use Test;
3
4 # L<S06/"Parameter traits"/"=item is readonly">
5 # should be moved with other subroutine tests?
6
7
8 {
9 my $a is readonly := 42;
10 is $a, 42, "basic declaration of a 'is readonly' variable works";
11
12 dies_ok { $a = 23 }, "a var declared with 'is readonly' is readonly (1)";
13 is $a, 42, "a var declared with 'is readonly' is readonly (2)";
14 }
15
16 {
17 my $a is readonly;
18 ok !$a, "declaration of an 'is readonly' var without supplying a container to bind to works";
19 try { $a := 42 };
20 is $a, 42, "binding the variable now works";
21
f25f151e » kyle
2009-06-19 [t/spec] Change more Pugs todo flags to fudge commands
22 #?pugs todo 'feature'
efe2b307 » coke
2011-10-08 rakudo fudging
23 #?rakudo todo 'todo'
f25f151e » kyle
2009-06-19 [t/spec] Change more Pugs todo flags to fudge commands
24 dies_ok { $a := 17 }, "but binding it again does not work";
dd2b31bf » moritz
2008-09-03 [t] move var/is_readonly.t to spec
25 }
26
efe2b307 » coke
2011-10-08 rakudo fudging
27 #?rakudo skip 'segfault'
dd2b31bf » moritz
2008-09-03 [t] move var/is_readonly.t to spec
28 {
29 my $a is readonly;
7aab93d8 » lwall
2008-10-10 [t] excise exists and delete functions
30 ok !(try { VAR($a).defined }), ".VAR returns undefined on an uninitialized var declared with 'is readonly'";
dd2b31bf » moritz
2008-09-03 [t] move var/is_readonly.t to spec
31
32 $a := 42;
f25f151e » kyle
2009-06-19 [t/spec] Change more Pugs todo flags to fudge commands
33 #?pugs todo 'feature'
34 ok (try { VAR($a).defined }), ".VAR returns defined now";
dd2b31bf » moritz
2008-09-03 [t] move var/is_readonly.t to spec
35 }
36
37 {
38 my $a = 3;
39
f25f151e » kyle
2009-06-19 [t/spec] Change more Pugs todo flags to fudge commands
40 #?pugs todo 'feature'
41 ok (try { VAR($a).defined }), ".VAR on a plain normal initialized variable returns true";
dd2b31bf » moritz
2008-09-03 [t] move var/is_readonly.t to spec
42 }
7f29bc53 » kyle
2009-08-08 [t/spec] Add vim: lines everywhere.
43
53c1decb » kyle
2009-10-27 [t/spec] Test for RT #65900
44 # RT #65900
45 {
46 my ($rt65900 is readonly) = 5;
47 is $rt65900, 5, 'my ($x is readonly) can take assignment';
efe2b307 » coke
2011-10-08 rakudo fudging
48 #?rakudo 2 todo 'todo'
53c1decb » kyle
2009-10-27 [t/spec] Test for RT #65900
49 dies_ok { $rt65900 = 'ro' }, 'dies on assignment to readonly variable';
50
51 dies_ok { (my $rt65900 is readonly) = 5 },
52 'dies on assignment to (my $x is readonly)';
53 }
54
e76dd4c7 » moritz
2010-12-31 s/done_testing/done/ as per recent S24 changes
55 done;
53c1decb » kyle
2009-10-27 [t/spec] Test for RT #65900
56
7f29bc53 » kyle
2009-08-08 [t/spec] Add vim: lines everywhere.
57 # vim: ft=perl6
Something went wrong with that request. Please try again.