Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 39 lines (28 sloc) 1.014 kb
dd2b31b [t] move var/is_readonly.t to spec
moritz authored
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 plan 9;
8
9 {
10 my $a is readonly := 42;
11 is $a, 42, "basic declaration of a 'is readonly' variable works";
12
13 dies_ok { $a = 23 }, "a var declared with 'is readonly' is readonly (1)";
14 is $a, 42, "a var declared with 'is readonly' is readonly (2)";
15 }
16
17 {
18 my $a is readonly;
19 ok !$a, "declaration of an 'is readonly' var without supplying a container to bind to works";
20 try { $a := 42 };
21 is $a, 42, "binding the variable now works";
22
23 dies_ok { $a := 17 }, "but binding it again does not work", :todo<feature>;
24 }
25
26 {
27 my $a is readonly;
28 ok !(try { exists $a }), "exists() returns false on an uninitialized var declared with 'is readonly'";
29
30 $a := 42;
31 ok (try { exists $a }), "exists() returns true now", :todo<feature>;
32 }
33
34 {
35 my $a = 3;
36
37 ok (try { exists $a }), "exists() on a plain normal initialized variable returns true", :todo<feature>;
38 }
Something went wrong with that request. Please try again.