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