Add a benchmark for strict constructors
[gitmo/Mouse.git] / t / 001_mouse / 068-strict-constructor.t
CommitLineData
29cb82b7 1#!perl
2use strict;
3use warnings;
4
5use Test::More;
6use Test::Exception;
7
8{
9 package MyClass;
10 use Mouse;
11
12 has foo => (
13 is => 'rw',
14 );
15
16 has bar => (
17 is => 'rw',
18 init_arg => undef,
19 );
20
21 __PACKAGE__->meta->make_immutable(strict_constructor => 1);
22}
23
24lives_ok {
25 MyClass->new(foo => 1);
26};
27
28throws_ok {
29 MyClass->new(foo => 1, hoge => 42);
30} qr/\b hoge \b/xms;
31
32throws_ok {
33 MyClass->new(foo => 1, bar => 42);
34} qr/\b bar \b/xms, "init_arg => undef";
35
36
37throws_ok {
38 MyClass->new(aaa => 1, bbb => 2, ccc => 3);
39} qr/\b aaa \b/xms;
40
41throws_ok {
42 MyClass->new(aaa => 1, bbb => 2, ccc => 3);
43} qr/\b bbb \b/xms;
44
45throws_ok {
46 MyClass->new(aaa => 1, bbb => 2, ccc => 3);
47} qr/\b ccc \b/xms;
48
49done_testing;