763006c69a9f96ccba25a6991379f549c4c5d269
[gitmo/Moose.git] / t / 019_method_keyword.t
1 #!/usr/bin/perl
2
3 use strict;
4 use warnings;
5
6 use Test::More no_plan => 1;
7
8 BEGIN {
9     use_ok('Moose');
10 }
11
12 {
13     package Foo;
14     use Moose;
15     
16     sub greetings {
17         "Hello, $_[1]";
18     }
19     
20     method 'greet_world_from' => sub {
21         my $from = shift;
22         self->greetings("World") . " from $from";
23     };    
24     
25     method 'greet_world_from_me' => sub {
26         self->greet_world_from("Stevan");
27     };  
28     
29     no Moose;  
30 }
31
32 my $foo = Foo->new;
33 isa_ok($foo, 'Foo');
34
35 is($foo->greetings('World'), 'Hello, World', '... got the right value from greetings');
36 is($foo->greet_world_from('Stevan'), 'Hello, World from Stevan', '... got the right value from greet_world_from');
37 is($foo->greet_world_from_me, 'Hello, World from Stevan', '... got the right value from greet_world');