File: getset.t

package info (click to toggle)
libclass-makemethods-perl 1.01-7
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid
  • size: 1,944 kB
  • sloc: perl: 10,495; makefile: 2
file content (67 lines) | stat: -rw-r--r-- 1,244 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

BEGIN {
  eval q{ local $SIG{__DIE__}; require Test::More; 1 };
  if ( $@ ) {
    plan( tests => 1 );
    print "Skipping test on this platform (test requires Test::More).\n";
    ok( 1 );
    exit 0;
  }
}

use Class::MakeMethods::Emulator::mcoder ('-take_namespace');

# Test taken from mcoder 0.05:

package One;

# BEGIN {$mcoder::debug=1}

use mcoder new => qw(new),
    [qw(set get)] => [qw(runner walker)],
    [qw(calculated delete undef set)] => qw(weight),
    [qw(bool_set bool_unset get)] => qw(is_good);


sub _calculate_weight {
    return 70;
}

package testing;

use Test::More tests => 12;

my $o;
ok($o=One->new(walker=>'lucas grihander'), 'constructor');

is($o->weight, 70, "weight");

is($o->set_weight(50), 50, "set_weight");

# use Data::Dumper;
# print STDERR Dumper $o;

is($o->weight, 50, "weight");

$o->undef_weight;

is($o->weight, 70, "undefined weight");

$o->delete_weight;

is($o->weight, 70, "deleted weight");

is($o->set_runner('pecador'), 'pecador', 'set');

is($o->walker, 'lucas grihander', 'get after ctor');

is($o->runner, 'pecador', 'cobarde, pecador, aigg!');

$o->set_is_good;
ok($o->is_good, 'good');

$o->unset_is_good;
ok(!$o->is_good, 'bad');

$o->set_is_good(4);
is($o->is_good, 4, 'good 4');