From 6ab7e1eabb1164e8f4e4e31f3ef6c987918ae5d3 Mon Sep 17 00:00:00 2001 From: doy Date: Wed, 8 Apr 2009 01:25:35 -0500 Subject: a few more tests --- t/003-attrs.t | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 t/003-attrs.t (limited to 't/003-attrs.t') diff --git a/t/003-attrs.t b/t/003-attrs.t new file mode 100644 index 0000000..9e222d0 --- /dev/null +++ b/t/003-attrs.t @@ -0,0 +1,36 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use Test::More tests => 4; + +package Foo; + +sub new { + my $class = shift; + bless { @_ }, $class; +} + +sub foo { + my $self = shift; + return $self->{foo} unless @_; + $self->{foo} = shift; +} + +package Foo::Moose; +use Moose; +use MooseX::NonMoose; +extends_nonmoose 'Foo'; + +has bar => ( + is => 'rw', +); + +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'; -- cgit v1.2.3-54-g00ecf