From 8bf5e6931a1bd96df0cdb1ceb94bbb3e578a8126 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Wed, 4 Sep 2013 19:38:21 -0400 Subject: packaging --- t/immutable.t | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 t/immutable.t (limited to 't/immutable.t') diff --git a/t/immutable.t b/t/immutable.t new file mode 100644 index 0000000..275b387 --- /dev/null +++ b/t/immutable.t @@ -0,0 +1,45 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use Test::More; + +package Foo; + +sub new { + my $class = shift; + bless { @_ }, $class; +} + +sub foo { + my $self = shift; + return $self->{foo} unless @_; + $self->{foo} = shift; +} + +sub baz { 'Foo' } +sub quux { ref(shift) } + +package Foo::Moose; +use Moose; +use MooseX::NonMoose; +extends 'Foo'; + +has bar => ( + is => 'rw', +); + +__PACKAGE__->meta->make_immutable; + +package main; + +my $foo_moose = Foo::Moose->new(foo => 'FOO', bar => 'BAR'); +is($foo_moose->foo, 'FOO', 'foo set in constructor'); +is($foo_moose->bar, 'BAR', 'bar set in constructor'); +$foo_moose->foo('BAZ'); +$foo_moose->bar('QUUX'); +is($foo_moose->foo, 'BAZ', 'foo set by accessor'); +is($foo_moose->bar, 'QUUX', 'bar set by accessor'); +is($foo_moose->baz, 'Foo', 'baz method'); +is($foo_moose->quux, 'Foo::Moose', 'quux method'); + +done_testing; -- cgit v1.2.3-54-g00ecf