Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[t/spec] Tests for attributes with the & sigil.

git-svn-id: http://svn.pugscode.org/pugs@26895 c213334d-75ef-0310-aa23-eaa082d1ae64
  • Loading branch information...
commit e9a791ffc169f6b758a53d59c1744514c573d5ac 1 parent 692c417
jnthn authored
Showing with 14 additions and 1 deletion.
  1. +14 −1 S12-attributes/instance.t
View
15 S12-attributes/instance.t
@@ -2,7 +2,7 @@ use v6;
use Test;
-plan 122;
+plan 126;
=begin pod
@@ -486,4 +486,17 @@ is eval('Foo7.new.attr'), 42, "default attribute value (1)";
is AttrInitTest.new(c => 9).c, 9, 'Can initialize one attribute based on another (3)';
}
+# attributes with & sigil
+{
+ class CodeAttr1 { has &!m = sub { "ok" }; method f { &!m() } }
+ is CodeAttr1.new.f, "ok", '&!m = sub { ... } works and an be called';
+
+ class CodeAttr2 { has &.a = { "woot" }; method foo { &!a() } }
+ is CodeAttr2.new.foo, "woot", '&.a = { ... } works and also declares &!a';
+ is CodeAttr2.new.a().(), "woot", '&.a has accessor returning closure';
+
+ class CodeAttr3 { has &!m = method { "OH HAI" }; method f { self.&!m() } }
+ is CodeAttr3.new.f, 'OH HAI', '&!m = method { ... } and self.&!m() work';
+}
+
# vim: ft=perl6
Please sign in to comment.
Something went wrong with that request. Please try again.