import some (modified) tests from MSS
[p5sagit/Function-Parameters.git] / t / foreign / Method-Signatures-Simple / 02-use.t
1 #!perl
2 use strict;
3 use warnings FATAL => 'all';
4
5 use Test::More tests => 7;
6 BEGIN { use_ok 'Function::Parameters' }
7
8 {
9     package My::Obj;
10     use Function::Parameters qw(:strict);
11
12     method make($class: %opts) {
13         bless {%opts}, $class;
14     }
15     method first : lvalue {
16         $self->{first};
17     }
18     method second {
19         $self->first + 1;
20     }
21     method nth($inc) {
22         $self->first + $inc;
23     }
24 }
25
26 my $o = My::Obj->make(first => 1);
27 is $o->first, 1;
28 is $o->second, 2;
29 is $o->nth(10), 11;
30
31 $o->first = 10;
32
33 is $o->first, 10;
34 is $o->second, 11;
35 is $o->nth(10), 20;
36