~ubuntu-branches/ubuntu/saucy/padre/saucy-proposed

« back to all changes in this revision

Viewing changes to t/perl/functionlist.t

  • Committer: Package Import Robot
  • Author(s): Dominique Dumont, gregor herrmann, Dominique Dumont
  • Date: 2012-01-04 12:04:20 UTC
  • mfrom: (1.3.3)
  • Revision ID: package-import@ubuntu.com-20120104120420-i5oybqwf91m1d3il
Tags: 0.92.ds1-1
[ gregor herrmann ]
* Remove debian/source/local-options; abort-on-upstream-changes
  and unapply-patches are default in dpkg-source since 1.16.1.
* Swap order of alternative (build) dependencies after the perl
  5.14 transition.

[ Dominique Dumont ]
* Imported Upstream version 0.92.ds1
* removed fix-spelling patch (applied upstream)
* lintian-override: use wildcard to avoid listing a gazillion files
* updated size of some 'not-real-man-page' entries
* rules: remove dekstop cruft (replaced by a file provided in debian
  directory)
* control: removed Breaks statement. Add /me to uploaders. Updated
  dependencies
* rules: make sure that non-DFSG file (i.e. the cute butterfly, sigh)
  is not distributed

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#!/usr/bin/perl
 
2
 
 
3
# Tests the logic for extracting the list of functions in a program
 
4
 
 
5
use strict;
 
6
use warnings;
 
7
use Test::More;
 
8
 
 
9
BEGIN {
 
10
        unless ( $ENV{DISPLAY} or $^O eq 'MSWin32' ) {
 
11
                plan skip_all => 'Needs DISPLAY';
 
12
                exit 0;
 
13
        }
 
14
        plan( tests => 9 );
 
15
}
 
16
 
 
17
use t::lib::Padre;
 
18
use Padre::Document::Perl::FunctionList ();
 
19
 
 
20
# Sample code we will be parsing
 
21
my $code = <<'END_PERL';
 
22
package Foo;
 
23
sub _bar { }
 
24
sub foo1 {}
 
25
sub foo3 { }
 
26
sub foo2{}
 
27
sub  foo4 {
 
28
}
 
29
sub foo5 :tag {
 
30
}
 
31
*backwards = sub { };
 
32
*_backwards = \&backwards;
 
33
END_PERL
 
34
 
 
35
 
 
36
 
 
37
 
 
38
 
 
39
######################################################################
 
40
# Basic Parsing
 
41
 
 
42
SCOPE: {
 
43
 
 
44
        # Create the function list parser
 
45
        my $task = new_ok(
 
46
                'Padre::Document::Perl::FunctionList',
 
47
                [   text => $code,
 
48
                ]
 
49
        );
 
50
 
 
51
        # Executing the parsing job
 
52
        ok( $task->run, '->run ok' );
 
53
 
 
54
        # Check the result of the parsing
 
55
        is_deeply(
 
56
                $task->{list},
 
57
                [   qw{
 
58
                                _bar
 
59
                                foo1
 
60
                                foo3
 
61
                                foo2
 
62
                                foo4
 
63
                                foo5
 
64
                                backwards
 
65
                                _backwards
 
66
                                }
 
67
                ],
 
68
                'Found expected functions',
 
69
        );
 
70
}
 
71
 
 
72
 
 
73
 
 
74
 
 
75
 
 
76
######################################################################
 
77
# Alphabetical Ordering
 
78
 
 
79
SCOPE: {
 
80
 
 
81
        # Create the function list parser
 
82
        my $task = new_ok(
 
83
                'Padre::Document::Perl::FunctionList',
 
84
                [   text  => $code,
 
85
                        order => 'alphabetical',
 
86
                ]
 
87
        );
 
88
 
 
89
        # Executing the parsing job
 
90
        ok( $task->run, '->run ok' );
 
91
 
 
92
        # Check the result of the parsing
 
93
        is_deeply(
 
94
                $task->{list},
 
95
                [   qw{
 
96
                                backwards
 
97
                                _backwards
 
98
                                _bar
 
99
                                foo1
 
100
                                foo2
 
101
                                foo3
 
102
                                foo4
 
103
                                foo5
 
104
                                }
 
105
                ],
 
106
                'Found expected functions',
 
107
        );
 
108
}
 
109
 
 
110
 
 
111
 
 
112
 
 
113
 
 
114
######################################################################
 
115
# Alphabetical Ordering (Private Last)
 
116
 
 
117
SCOPE: {
 
118
 
 
119
        # Create the function list parser
 
120
        my $task = new_ok(
 
121
                'Padre::Document::Perl::FunctionList',
 
122
                [   text  => $code,
 
123
                        order => 'alphabetical_private_last',
 
124
                ]
 
125
        );
 
126
 
 
127
        # Executing the parsing job
 
128
        ok( $task->run, '->run ok' );
 
129
 
 
130
        # Check the result of the parsing
 
131
        is_deeply(
 
132
                $task->{list},
 
133
                [   qw{
 
134
                                backwards
 
135
                                foo1
 
136
                                foo2
 
137
                                foo3
 
138
                                foo4
 
139
                                foo5
 
140
                                _backwards
 
141
                                _bar
 
142
                                }
 
143
                ],
 
144
                'Found expected functions',
 
145
        );
 
146
}