Skip to content

Commit 08725fd

Browse files
committed
Merge pull request #78 from LLFourn/is_required_fix
is required used as default checks
2 parents 747632a + 13badac commit 08725fd

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

S12-class/attributes-required.t

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use v6;
22

33
use Test;
44

5-
plan 3;
5+
plan 5;
66

77
class fish {
88
has $.x is required;
@@ -17,3 +17,12 @@ class lemur {
1717

1818
lives-ok { lemur.new() }, "Non-required attributes aren't";
1919

20+
class sloth {
21+
has Int:D $.x is required;
22+
has Int:D $.y = self.x;
23+
}
24+
25+
throws-like { sloth.new() }, X::Attribute::Required,
26+
"required attributes are checked before defaults run";
27+
28+
is sloth.new(:x(3)).y,3,"required attribute in default";

0 commit comments

Comments
 (0)