Changelogging
[gitmo/Mouse.git] / t / 202-squirrel-role.t
CommitLineData
9fc566e3 1#!/usr/bin/perl
2
3use strict;
4use warnings;
5
6use Test::More;
6c169c50 7use Scalar::Util 'blessed';
9fc566e3 8
1a7f1147 9BEGIN {
10 $SIG{__WARN__} = sub { warn $_[0] if $_[0] !~ /Squirrel is deprecated/ };
11}
12
9fc566e3 13do {
14 package Foo::Role;
15 use Squirrel::Role;
16
17 has foo => (
18 isa => "Int",
19 is => "rw",
20 );
21
22 no Squirrel::Role;
23};
24
25# note that 'Foo' is defined before this, to prevent Moose being loaded from
26# affecting its definition
27
28BEGIN {
9cc87fff 29 plan skip_all => "Moose 0.68 required for this test" unless eval { require Moose::Role && Moose::Role->VERSION('0.68') };
7bbf018c 30 plan tests => 6;
9fc566e3 31}
32
33do {
34 package Bar::Role;
35 use Squirrel::Role;
36
37 has foo => (
38 isa => "Int",
39 is => "rw",
40 );
41
42 no Squirrel::Role;
43};
44
45ok(!Foo::Role->can('has'), "Mouse::Role::has was unimported");
ddd4992c 46SKIP: {
47 skip "ancient moose", 1 if $Moose::VERSION <= 0.50;
48 ok(!Bar::Role->can('has'), "Moose::Role::has was unimported");
49}
9fc566e3 50
51eval "
52 package Foo::Role;
53 use Squirrel::Role;
54
55 has bar => (is => 'rw');
56
57 package Bar::Role;
58 use Squirrel::Role;
59
60 has bar => (is => 'rw');
61";
62
d1288432 63isa_ok(Foo::Role->meta, 'Mouse::Meta::Role');
64isa_ok(Foo::Role->meta, 'Mouse::Meta::Role');
9fc566e3 65
d1288432 66isa_ok(Bar::Role->meta, 'Moose::Meta::Role');
67isa_ok(Bar::Role->meta, 'Moose::Meta::Role');
9fc566e3 68