File: static_get_set.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 (52 lines) | stat: -rw-r--r-- 961 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
#!/usr/local/bin/perl

package X;

use Class::MakeMethods::Emulator::MethodMaker
  get_set => [ qw / -static a b / ],
  static_get_set => 'c';

sub new { bless {}, shift; }

package main;
BEGIN { unshift @INC, ( $0 =~ /\A(.*?)[\w\.]+\z/ )[0] }
use Test;

my $o = new X;
my $o2 = new X;

# 1--7
TEST { 1 };
TEST { ! defined $o->a };
TEST { $o->a(123) };
TEST { $o->a == 123 };
TEST { $o2->a == 123 };
TEST { ! defined $o2->clear_a };
TEST { ! defined $o->a };

# 8--13
TEST { ! defined $o->b };
TEST { $o->b('hello world') };
TEST { $o->b eq 'hello world' };
TEST { $o2->b eq 'hello world' };
TEST { ! defined $o2->clear_b };
TEST { ! defined $o->b };

my $foo = 'this';
# 14--15
TEST { ! defined $o->c };
TEST { $o->c(\$foo) };

$foo = 'that';

# 16--22
TEST { $o->c eq \$foo };
TEST { $o2->c eq \$foo };
TEST { ${$o->c} eq ${$o2->c}};
TEST { ${$o->c} eq 'that'};
TEST { ${$o->c} eq 'that'};
TEST { ! defined $o2->clear_c };
TEST { ! defined $o->c };

exit 0;