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

« back to all changes in this revision

Viewing changes to t/csharp/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 C# 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::CSharp::FunctionList ();
 
19
 
 
20
# Sample code we will be parsing
 
21
my $code = <<'END_CS';
 
22
/**
 
23
public static void Bogus(a, b)
 
24
{
 
25
}
 
26
*/
 
27
//public static void Bogus(a, b) { }
 
28
 
 
29
public static void Main(string[] args)
 
30
{
 
31
}
 
32
 
 
33
///
 
34
protected override void Init()
 
35
// ticket #1351
 
36
 
 
37
public abstract void MyAbstractMethod();
 
38
 
 
39
public byte[] ToByteArray();
 
40
 
 
41
public static T StaticGenericMethod<T>(arguments);
 
42
 
 
43
public sealed List<int>[] GenericArrayReturnType();
 
44
 
 
45
public virtual string[,] TwoDimArrayReturnType();
 
46
 
 
47
public abstract List<int> GetList();
 
48
 
 
49
private int Subtract(int a, int b)
 
50
{
 
51
        return a - b;
 
52
}
 
53
 
 
54
private int Add(int a, int b)
 
55
{
 
56
        return a + b;
 
57
}
 
58
 
 
59
[Test()] public void TestMethod() { }
 
60
END_CS
 
61
 
 
62
######################################################################
 
63
# Basic Parsing
 
64
 
 
65
SCOPE: {
 
66
 
 
67
        # Create the function list parser
 
68
        my $task = new_ok(
 
69
                'Padre::Document::CSharp::FunctionList',
 
70
                [ text => $code ]
 
71
        );
 
72
 
 
73
        # Executing the parsing job
 
74
        ok( $task->run, '->run ok' );
 
75
 
 
76
        # Check the result of the parsing
 
77
        is_deeply(
 
78
                $task->{list},
 
79
                [   qw{
 
80
                                Main
 
81
                                MyAbstractMethod
 
82
                                ToByteArray
 
83
                                StaticGenericMethod
 
84
                                GenericArrayReturnType
 
85
                                TwoDimArrayReturnType
 
86
                                GetList
 
87
                                Subtract
 
88
                                Add
 
89
                                TestMethod
 
90
                                }
 
91
                ],
 
92
                'Found expected functions',
 
93
        );
 
94
}
 
95
 
 
96
 
 
97
 
 
98
 
 
99
 
 
100
######################################################################
 
101
# Alphabetical Ordering
 
102
 
 
103
SCOPE: {
 
104
 
 
105
        # Create the function list parser
 
106
        my $task = new_ok(
 
107
                'Padre::Document::CSharp::FunctionList',
 
108
                [   text  => $code,
 
109
                        order => 'alphabetical',
 
110
                ]
 
111
        );
 
112
 
 
113
        # Executing the parsing job
 
114
        ok( $task->run, '->run ok' );
 
115
 
 
116
        # Check the result of the parsing
 
117
        is_deeply(
 
118
                $task->{list},
 
119
                [   qw{
 
120
                                Add
 
121
                                GenericArrayReturnType
 
122
                                GetList
 
123
                                Main
 
124
                                MyAbstractMethod
 
125
                                StaticGenericMethod
 
126
                                Subtract
 
127
                                TestMethod
 
128
                                ToByteArray
 
129
                                TwoDimArrayReturnType
 
130
                                }
 
131
                ],
 
132
                'Found expected functions (alphabetical)',
 
133
        );
 
134
}
 
135
 
 
136
 
 
137
 
 
138
 
 
139
 
 
140
######################################################################
 
141
# Alphabetical Ordering (Private Last)
 
142
 
 
143
SCOPE: {
 
144
 
 
145
        # Create the function list parser
 
146
        my $task = new_ok(
 
147
                'Padre::Document::CSharp::FunctionList',
 
148
                [   text  => $code,
 
149
                        order => 'alphabetical_private_last',
 
150
                ]
 
151
        );
 
152
 
 
153
        # Executing the parsing job
 
154
        ok( $task->run, '->run ok' );
 
155
 
 
156
        # Check the result of the parsing
 
157
        is_deeply(
 
158
                $task->{list},
 
159
                [   qw{
 
160
                                Add
 
161
                                GenericArrayReturnType
 
162
                                GetList
 
163
                                Main
 
164
                                MyAbstractMethod
 
165
                                StaticGenericMethod
 
166
                                Subtract
 
167
                                TestMethod
 
168
                                ToByteArray
 
169
                                TwoDimArrayReturnType
 
170
                                }
 
171
                ],
 
172
                'Found expected functions (alphabetical_private_last)',
 
173
        );
 
174
}