File: global_scalar.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 (59 lines) | stat: -rw-r--r-- 1,062 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
#!/usr/local/bin/perl

use Test;
BEGIN { plan tests => 22 }

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

package X;

use Class::MakeMethods::Basic::Global
  scalar => [ qw / a b / ],
  scalar => 'c';

sub new { bless {}, shift; }

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

package main;

ok( 1 );

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

# 2--7
ok( ! defined $o->a );
ok( $o->a(123) );
ok( $o->a == 123 );
ok( $o2->a == 123 );
ok( ! defined $o2->a(undef) );
ok( ! defined $o->a );

# 8--13
ok( ! defined $o->b );
ok( $o->b('hello world') );
ok( $o->b eq 'hello world' );
ok( $o2->b eq 'hello world' );
ok( ! defined $o2->b(undef) );
ok( ! defined $o->b );

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

$foo = 'that';

# 16--22
ok( $o->c eq \$foo );
ok( $o2->c eq \$foo );
ok( ${$o->c} eq ${$o2->c});
ok( ${$o->c} eq 'that');
ok( ${$o->c} eq 'that');
ok( ! defined $o2->c(undef) );
ok( ! defined $o->c );

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

1;