File: comments.t

package info (click to toggle)
libfunction-parameters-perl 2.001003-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster
  • size: 948 kB
  • sloc: perl: 6,478; makefile: 3
file content (90 lines) | stat: -rw-r--r-- 1,857 bytes parent folder | download | duplicates (2)
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!perl
use strict;
use warnings FATAL => 'all';

use Test::More
    eval { require Moose }
    ? (tests    => 5)
    : (skip_all => "Moose required for testing types")
;
use Test::Fatal;

use Function::Parameters {
    fun    => { defaults => 'function', reify_type => 'moose' },
    method => { defaults => 'method',   reify_type => 'moose' },
};


is exception
{
    eval q{
        fun foo (
            Int :$foo,              # this is foo
            Int :$bar               # this is bar
        )
        {
        }

        1;
    } or die;
}, undef,
'survives comments within the signature itself';

is exception
{
    eval q{
        fun bar ( Int :$foo, Int :$bar )       # this is a signature
        {
        }

        1;
    } or die;
}, undef,
'survives comments between signature and open brace';

#SKIP:
#{
#    eval { require MooseX::Declare } or skip "MooseX::Declare required for this test", 1;
#
    is exception
    {
        eval q{
#            use MooseX::Declare;
#            use Method::Signatures::Modifiers;

            package Foo
            {
                method bar ( Int :$foo, Int :$bar )     # this is a signature
                {
                }
            }

            1;
        } or die;
    }, undef,
    'survives comments between signature and open brace';
#}


#TODO: {
#    local $TODO = "closing paren in comment: rt.cpan.org 81364";

    is exception
    {
#        # When this fails, it produces 'Variable "$bar" is not imported'
#        # This is expected to fail, don't bother the user.
#        no warnings;
        eval q{
            fun special_comment (
                $foo, # )
                $bar
            )
            { 42 }
            1;
        } or die;
    }, undef,
    'closing paren in comment';
    is eval q[special_comment("this", "that")], 42;
#}

#done_testing();