summaryrefslogtreecommitdiffstats
path: root/t/52-hashref-constructor.t
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2010-11-08 21:48:25 -0600
committerJesse Luehrs <doy@tozt.net>2010-11-08 21:48:25 -0600
commit36fb7f594d2e8249ca656725922e3118e6458153 (patch)
treea5a799fcaedc50407d5c9d96f0a89f3991f91aa3 /t/52-hashref-constructor.t
parent8d0ba7da07e943fb6c641202b335fc8a2f7ae73b (diff)
downloadmoosex-nonmoose-36fb7f594d2e8249ca656725922e3118e6458153.tar.gz
moosex-nonmoose-36fb7f594d2e8249ca656725922e3118e6458153.zip
rename one more test file
Diffstat (limited to 't/52-hashref-constructor.t')
-rw-r--r--t/52-hashref-constructor.t67
1 files changed, 67 insertions, 0 deletions
diff --git a/t/52-hashref-constructor.t b/t/52-hashref-constructor.t
new file mode 100644
index 0000000..74fd530
--- /dev/null
+++ b/t/52-hashref-constructor.t
@@ -0,0 +1,67 @@
+#!/usr/bin/env perl
+use strict;
+use warnings;
+use Test::More;
+use Test::Exception;
+
+{
+ package Foo;
+
+ sub new {
+ my $class = shift;
+ bless { ref($_[0]) ? %{$_[0]} : @_ }, $class;
+ }
+
+ sub foo {
+ my $self = shift;
+ $self->{foo};
+ }
+}
+
+{
+ package Bar;
+ use Moose;
+ use MooseX::NonMoose;
+
+ extends 'Foo';
+
+ has _bar => (
+ init_arg => 'bar',
+ reader => 'bar',
+ );
+
+ __PACKAGE__->meta->make_immutable;
+}
+
+{
+ package Baz;
+ use Moose;
+
+ extends 'Bar';
+
+ has _baz => (
+ init_arg => 'baz',
+ reader => 'baz',
+ );
+}
+
+{
+ my $baz;
+ lives_ok { $baz = Baz->new( foo => 1, bar => 2, baz => 3 ) }
+ "constructor lives";
+ is($baz->foo, 1, "foo set");
+ is($baz->bar, 2, "bar set");
+ is($baz->baz, 3, "baz set");
+
+}
+
+{
+ my $baz;
+ lives_ok { $baz = Baz->new({foo => 1, bar => 2, baz => 3}) }
+ "constructor lives (hashref)";
+ is($baz->foo, 1, "foo set (hashref)");
+ is($baz->bar, 2, "bar set (hashref)");
+ is($baz->baz, 3, "baz set (hashref)");
+}
+
+done_testing;