import some (modified) tests from MSS
[p5sagit/Function-Parameters.git] / t / foreign / Method-Signatures-Simple / 02-use.t
CommitLineData
d93106d7 1#!perl
2use strict;
3use warnings FATAL => 'all';
4
5use Test::More tests => 7;
6BEGIN { 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
26my $o = My::Obj->make(first => 1);
27is $o->first, 1;
28is $o->second, 2;
29is $o->nth(10), 11;
30
31$o->first = 10;
32
33is $o->first, 10;
34is $o->second, 11;
35is $o->nth(10), 20;
36