summaryrefslogtreecommitdiffstats
path: root/gnu/usr.bin/perl/dist/Attribute-Handlers/t/data_convert.t
blob: 4357c5396427a31808a221914a2704815a087149 (plain) (blame)
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
#!/usr/bin/perl -w

# Test attribute data conversion using examples from the docs

use Test::More tests => 8;

package LoudDecl;
use Attribute::Handlers;

sub Loud :ATTR {
    my ($package, $symbol, $referent, $attr, $data, $phase) = @_;

    ::is_deeply( $data, $referent->(), *{$symbol}{NAME} );
}


sub test1 :Loud(till=>ears=>are=>bleeding) {
    [qw(till ears are bleeding)]
}

sub test2 :Loud(['till','ears','are','bleeding']) {
    [[qw(till ears are bleeding)]]
}

sub test3 :Loud(qw/till ears are bleeding/) {
    [qw(till ears are bleeding)]
}

sub test4 :Loud(qw/my, ears, are, bleeding/) {
    [('my,', 'ears,', 'are,', 'bleeding')]
}

sub test5 :Loud(till,ears,are,bleeding) {
    [qw(till ears are bleeding)]
}

sub test6 :Loud(my,ears,are,bleeding) {
    'my,ears,are,bleeding';
}

sub test7 :Loud(qw/my ears are bleeding) {
    'qw/my ears are bleeding'; #'
}

sub test8 :Loud("turn it up to 11, man!") {
    ['turn it up to 11, man!'];
}