From: Shawn M Moore Date: Tue, 17 Jun 2008 04:16:57 +0000 (+0000) Subject: Begin adding tests for Squirrel::Role X-Git-Tag: 0.19~292 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=9fc566e38c5a8786a58aace9ee7304339234ea4b;p=gitmo%2FMouse.git Begin adding tests for Squirrel::Role --- diff --git a/t/202-squirrel-role.t b/t/202-squirrel-role.t new file mode 100644 index 0000000..618b950 --- /dev/null +++ b/t/202-squirrel-role.t @@ -0,0 +1,61 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use Test::More; +use Scalar::Util 'blessed'; + +do { + package Foo::Role; + use Squirrel::Role; + + has foo => ( + isa => "Int", + is => "rw", + ); + + no Squirrel::Role; +}; + +# note that 'Foo' is defined before this, to prevent Moose being loaded from +# affecting its definition + +BEGIN { + plan skip_all => "Moose required for this test" unless eval { require Moose }; + plan tests => 12; +} + +do { + package Bar::Role; + use Squirrel::Role; + + has foo => ( + isa => "Int", + is => "rw", + ); + + no Squirrel::Role; +}; + +ok(!Foo::Role->can('has'), "Mouse::Role::has was unimported"); +ok(!Bar::Role->can('has'), "Moose::Role::has was unimported"); + +eval " + package Foo::Role; + use Squirrel::Role; + + has bar => (is => 'rw'); + + package Bar::Role; + use Squirrel::Role; + + has bar => (is => 'rw'); +"; + +isa_ok(blessed(Foo::Role->meta), 'Mouse::Meta::Role'); +isa_ok(blessed(Foo::Role->meta), 'Mouse::Meta::Role', 'Squirrel::Role is consistent if Moose was loaded between imports'); + +isa_ok(blessed(Bar::Role->meta), 'Moose::Meta::Role'); +isa_ok(blessed(Bar::Role->meta), 'Moose::Meta::Role'); +