File: declarations.t

package info (click to toggle)
libclass-makemethods-perl 1.01-7
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 1,944 kB
  • sloc: perl: 10,495; makefile: 2
file content (80 lines) | stat: -rw-r--r-- 1,615 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/usr/bin/perl

use Test;
BEGIN { plan tests => 12 }

########################################################################

package MyObject;

use Class::MakeMethods::Standard::Hash (
  'new' => 'new',
);

########################################################################
### WAYS OF SPECIFYING A SUBCLASS 
########################################################################

use Class::MakeMethods::Standard::Hash (
  scalar => 'a'
);

use Class::MakeMethods (
  -MakerClass => 'Standard::Hash',
  scalar => 'b',
);

use Class::MakeMethods (
  -MakerClass => '::Class::MakeMethods::Standard::Hash',
  scalar => 'c',
);

use Class::MakeMethods (
  'Standard::Hash:scalar' => 'd',
);

use Class::MakeMethods (
  '::Class::MakeMethods::Standard::Hash:scalar' => 'e',
);

########################################################################
### FORMS OF SIMPLE DECLARATION SYNTAX
########################################################################

use Class::MakeMethods::Standard::Hash (
  scalar => 'f'
);

use Class::MakeMethods::Standard::Hash (
  scalar => [ 'g' ]
);

use Class::MakeMethods::Standard::Hash (
  scalar => 'h i'
);

use Class::MakeMethods::Standard::Hash (
  scalar => [ 'j', 'k' ]
);

########################################################################

package main;

ok( 1 );

my $i;
my $o = MyObject->new( map { $_ => ++ $i  } qw ( a b c d e f g h i j k ) );

ok( $o->a(), 1 );
ok( $o->b(), 2 );
ok( $o->c(), 3 );
ok( $o->d(), 4 );
ok( $o->e(), 5 );

ok( $o->f(), 6 );
ok( $o->g(), 7 );
ok( $o->h(), 8 );
ok( $o->i(), 9 );
ok( $o->j(), 10 );
ok( $o->k(), 11 );