File: package_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 (63 lines) | stat: -rw-r--r-- 1,206 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
#!/usr/bin/perl

package X;

use Class::MakeMethods::Template::PackageVar (
  'scalar' => [ qw / a b / ],
  'scalar' => { 'name' => 'c', 'variable' => 'Foozle' }
);

sub new { bless {}, shift; }

package Y;

@ISA = 'X';

package main;
use Test;
BEGIN { plan tests => 31 }

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

ok( 1 ); #1
ok( ! defined $o->a ); #2
ok( $o->a(123) ); #3
ok( $o->a == 123 ); #4
ok( $o2->a == 123 ); #5
ok( ! defined $o2->a(undef) ); #6
ok( ! defined $o->a ); #7

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

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

$foo = 'that';

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

ok( ! defined X->c ); #23
ok( X->c(123) ); #24
ok( X->c == 123 ); #25
ok( $X::Foozle = 123 ); #26
ok( ! defined $Y::Foozle ); #27
ok( $o2->c == 123 ); #28
ok( $X::Foozle = 1234 ); #29
ok( $o->c() == 1234 ); #30
ok( ! defined $Y::Foozle ); #31

exit 0;