File: insideout_array.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-- 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
53
54
55
56
57
58
59
#!/usr/bin/perl

use Test;
BEGIN { plan tests => 15 }

package X;

use Class::MakeMethods::Template::Flyweight (
  new => 'new',
  array => [ qw / a b / ]
);

package main;

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

ok( 1 ); #1
ok( ! scalar @{$o->a} ); #2
ok( $o->push_a(123, 456) ); #3
ok( $o->unshift_a('baz') ); #4
ok( $o->pop_a == 456 ); #5
ok( $o->shift_a eq 'baz' ); #6
ok( ! scalar @{$o2->a} ); #7
ok( $o2->push_a(123, 456) ); #8

ok( $o->b(123, 'foo', qw / a b c /, 'bar') ); #9
ok do { #10
  my @l = $o->b;
  $l[0] == 123 and
  $l[1] eq 'foo' and
  $l[2] eq 'a' and
  $l[3] eq 'b' and
  $l[4] eq 'c' and
  $l[5] eq 'bar'
};

ok do { #11
  $o->splice_b(1, 2, 'baz');
  my @l = $o->b;
  $l[0] == 123 and
  $l[1] eq 'baz' and
  $l[2] eq 'b' and
  $l[3] eq 'c' and
  $l[4] eq 'bar'
};

ok( ref $o->b_ref eq 'ARRAY' ); #12
ok( ! scalar @{$o->clear_b} ); #13
ok( ! scalar @{$o->b} ); #14

ok do { #15
  my @l = $o2->a;
  $l[0] == 123 and
  $l[1] == 456
};

exit 0;