refactored out fast method modifier as Class::Method::Modifiers::Fast and used Class...
[gitmo/Mouse.git] / t / 010-required.t
CommitLineData
c3398f5b 1#!/usr/bin/env perl
2use strict;
3use warnings;
4use Test::More tests => 3;
eab81545 5use Test::Exception;
c3398f5b 6
7do {
8 package Class;
9 use Mouse;
10
11 has foo => (
12 required => 1,
13 );
14
15 has bar => (
16 required => 1,
17 default => 50,
18 );
19
20 has baz => (
21 required => 1,
22 default => sub { 10 },
23 );
24
25 has quux => (
26 is => "rw",
27 required => 1,
28 lazy => 1,
29 default => sub { "yay" },
30 );
31};
32
398327c3 33throws_ok { Class->new } qr/Attribute \(foo\) is required/, "required attribute is required";
c3398f5b 34lives_ok { Class->new(foo => 5) } "foo is the only required but unfulfilled attribute";
35lives_ok { Class->new(foo => 1, bar => 1, baz => 1, quux => 1) } "all attributes specified";
36