File: hash_number_interfaces.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 (44 lines) | stat: -rw-r--r-- 1,097 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
#!/usr/bin/perl

use Test;
BEGIN { plan tests => 12 }

package X;

use Class::MakeMethods::Template::Hash (
  new => 'new',
  number => [
    '-interface' =>{ 'get_*' => 'get', 'set_*' => 'set_return' } => qw/ d e /,
    -interface => 'eiffel'        => 'g',
    '--java'          => 'h',
    '--with_clear'    => 'i',
    '-interface' => 'noclear'       => 'f',
  ]
);

package main;

my $o = new X;

ok( 1 ); #1

ok( ! $o->can ('d') ); #2			# 12
ok( ! $o->can ('clear_e') ); #3			# 13
ok( ! defined $o->get_d ); #4			# 14
ok( ! defined $o->set_d ('foo') ); #5		# 15
ok( $o->get_d eq 'foo' ); #6			# 16
ok( ! defined $o->set_d (undef) ); #7		# 17
ok( ! defined $o->get_d ); #8			# 18

ok sub { $o->can ('f') and ! $o->can ('clear_f') and
	 ! $o->can ('set_f') and ! $o->can ('get_f') };

ok sub { $o->can ('g') and ! $o->can ('clear_g') and
	 $o->can ('set_g') and ! $o->can ('get_g') };
ok sub { ! $o->can ('h') and ! $o->can ('clear_h') and
	 $o->can ('seth') and $o->can ('geth') };
ok sub { $o->can ('i') and $o->can ('clear_i') and
	 ! $o->can ('set_i') and ! $o->can ('get_i') };

exit 0;