File: 05multi.t

package info (click to toggle)
libattribute-storage-perl 0.12-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 172 kB
  • sloc: perl: 499; makefile: 3
file content (32 lines) | stat: -rw-r--r-- 679 bytes parent folder | download
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
#!/usr/bin/perl

use v5.14;
use warnings;

use Test2::V0;

use Attribute::Storage qw( get_subattr );

sub One :ATTR(CODE)
{
   my $package = shift;
   1;
}

sub Many :ATTR(CODE,MULTI)
{
   my $package = shift;
   my ( $oldvalue ) = @_;
   return ++$oldvalue;
}

# We have to put  my $dummy = ...  or else the Perl compiler gets confused.
# Reported to perl-p5p@
eval "my \$dummy = sub :One :One { 'XXX' }";
like( $@, qr/^Already have the One attribute /, 'Applying :One multiple times dies' );

my $coderef = eval "my \$dummy = sub :Many :Many :Many { 'XXX' }";
ok( !$@, 'Applying :Many succeeds' );
is( get_subattr( $coderef, "Many" ), 3, 'Value of Many is 3' );

done_testing;