From: Shawn M Moore Date: Fri, 13 Jun 2008 01:34:18 +0000 (+0000) Subject: Add t/029-new.t for testing the constructor X-Git-Tag: 0.04~16 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=39d3892835648e27207ffb598b1d55799007c376;p=gitmo%2FMouse.git Add t/029-new.t for testing the constructor --- diff --git a/t/029-new.t b/t/029-new.t new file mode 100644 index 0000000..9ad1721 --- /dev/null +++ b/t/029-new.t @@ -0,0 +1,30 @@ +#!/usr/bin/env perl +use strict; +use warnings; +use Test::More tests => 4; +use Test::Exception; + +do { + package Class; + use Mouse; + + has 'x'; + + has y => ( + is => 'ro', + ); + + has z => ( + is => 'rw', + ); +}; + +my $object = Class->new({x => 1, y => 2, z => 3}); +is($object->{x}, 1); +is($object->y, 2); +is($object->z, 3); + +throws_ok { + Class->new('non-hashref scalar'); +} qr/Single parameters to new\(\) must be a HASH ref/; +