Skip to content
Browse files

[t] move var/is_readonly.t to spec

git-svn-id: http://svn.pugscode.org/pugs@22125 c213334d-75ef-0310-aa23-eaa082d1ae64
  • Loading branch information...
1 parent aede1fa commit dd2b31bf44d166d85c3c8973319a7976bccc9d27 moritz committed Sep 3, 2008
Showing with 38 additions and 0 deletions.
  1. +38 −0 S06-traits/is-readonly.t
View
38 S06-traits/is-readonly.t
@@ -0,0 +1,38 @@
+use v6;
+use Test;
+
+# L<S06/"Parameter traits"/"=item is readonly">
+# should be moved with other subroutine tests?
+
+plan 9;
+
+{
+ my $a is readonly := 42;
+ is $a, 42, "basic declaration of a 'is readonly' variable works";
+
+ dies_ok { $a = 23 }, "a var declared with 'is readonly' is readonly (1)";
+ is $a, 42, "a var declared with 'is readonly' is readonly (2)";
+}
+
+{
+ my $a is readonly;
+ ok !$a, "declaration of an 'is readonly' var without supplying a container to bind to works";
+ try { $a := 42 };
+ is $a, 42, "binding the variable now works";
+
+ dies_ok { $a := 17 }, "but binding it again does not work", :todo<feature>;
+}
+
+{
+ my $a is readonly;
+ ok !(try { exists $a }), "exists() returns false on an uninitialized var declared with 'is readonly'";
+
+ $a := 42;
+ ok (try { exists $a }), "exists() returns true now", :todo<feature>;
+}
+
+{
+ my $a = 3;
+
+ ok (try { exists $a }), "exists() on a plain normal initialized variable returns true", :todo<feature>;
+}

0 comments on commit dd2b31b

Please sign in to comment.
Something went wrong with that request. Please try again.