Skip to content

Instantly share code, notes, and snippets.

@logie17
Last active December 11, 2015 07:38
Show Gist options
  • Save logie17/4567292 to your computer and use it in GitHub Desktop.
Save logie17/4567292 to your computer and use it in GitHub Desktop.
#! /usr/bin/perl
package Foo;
use Moose;
use Test::More;
has foo => ( is => 'rw');
has bar => ( is => 'ro', writer => 'bar' );
has baz => ( is => 'ro', writer => 'set_baz');
my $obj = Foo->new;
$obj->foo;
$obj->foo('test');
is $obj->foo, ('test');
$obj->bar('test');
is $obj->bar, undef;
$obj->set_baz('test');
is $obj->baz, 'test';
$obj->set_baz('foo');
$obj->set_baz;
is $obj->baz, undef;
done_testing;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment