Throw an error if there's no parameter name provided
[gitmo/MooseX-Role-Parameterized.git] / t / 009-override-super.t
CommitLineData
20725a2d 1#!/usr/bin/env perl
2use strict;
3use warnings;
4use Test::More tests => 2;
5
6my @calls;
7
8do {
9 package MyRole::LogMethod;
10 use MooseX::Role::Parameterized;
11
12 parameter method => (
13 is => 'rw',
14 isa => 'Str',
15 required => 1,
16 );
17
18 role {
19 my $p = shift;
20
21 override $p->method => sub {
22 push @calls, "calling " . $p->method;
23 super;
24 push @calls, "called " . $p->method;
25 };
26 };
27};
28
29do {
30 package MyClass;
31 use Moose;
32 with 'MyRole::LogMethod' => {
33 method => 'new',
34 };
35};
36
37is_deeply([splice @calls], [], "no calls yet");
38MyClass->new;
39is_deeply([splice @calls], ["calling new", "called new"], "instrumented new");
40