@@ -67,147 +67,39 @@ private ScintillaControl GetBaseScintillaControl()
67
67
68
68
public class GetBodyStart : ASGeneratorTests
69
69
{
70
- [ Test ]
71
- public void SimpleCase ( )
72
- {
73
- var sci = GetBaseScintillaControl ( ) ;
74
- sci . Text = "function test():void{\r \n \t \t \t \r \n }" ;
75
- sci . ConfigurationLanguage = "haxe" ;
76
- sci . Colourise ( 0 , - 1 ) ;
77
- int funcBodyStart = ASGenerator . GetBodyStart ( 0 , 1 , sci ) ;
78
-
79
- Assert . AreEqual ( 26 , funcBodyStart ) ;
80
- }
81
-
82
- [ Test ]
83
- public void EndOnSecondLine ( )
84
- {
85
- var sci = GetBaseScintillaControl ( ) ;
86
- // TODO: Should we reindent second line?
87
- sci . Text = "function test():void{\r \n \t \t \t }" ;
88
- sci . ConfigurationLanguage = "haxe" ;
89
- sci . Colourise ( 0 , - 1 ) ;
90
- int funcBodyStart = ASGenerator . GetBodyStart ( 0 , 1 , sci ) ;
91
-
92
- Assert . AreEqual ( 26 , funcBodyStart ) ;
93
- Assert . AreEqual ( "function test():void{\r \n \t \t \t \r \n }" , sci . Text ) ;
94
- }
95
-
96
- [ Test ]
97
- public void EndOnSecondLineNoExtraIndent ( )
98
- {
99
- var sci = GetBaseScintillaControl ( ) ;
100
- sci . Text = "function test():void{\r \n }" ;
101
- sci . ConfigurationLanguage = "haxe" ;
102
- sci . Colourise ( 0 , - 1 ) ;
103
- int funcBodyStart = ASGenerator . GetBodyStart ( 0 , 1 , sci ) ;
104
-
105
- Assert . AreEqual ( 24 , funcBodyStart ) ;
106
- Assert . AreEqual ( "function test():void{\r \n \t \r \n }" , sci . Text ) ;
107
- }
108
-
109
- [ Test ]
110
- public void CharOnSecondLine ( )
111
- {
112
- var sci = GetBaseScintillaControl ( ) ;
113
- // TODO: Should we reindent second line?
114
- sci . Text = "function test():void{\r \n \t \t \t //comment}" ;
115
- sci . ConfigurationLanguage = "haxe" ;
116
- sci . Colourise ( 0 , - 1 ) ;
117
- int funcBodyStart = ASGenerator . GetBodyStart ( 0 , 1 , sci ) ;
118
-
119
- Assert . AreEqual ( 26 , funcBodyStart ) ;
120
- Assert . AreEqual ( "function test():void{\r \n \t \t \t //comment}" , sci . Text ) ;
121
- }
122
-
123
- [ Test ]
124
- public void EndOnSameDeclarationLine ( )
70
+ public IEnumerable < TestCaseData > GetBodyStartTestCases
125
71
{
126
- var sci = GetBaseScintillaControl ( ) ;
127
- sci . Text = "function test():void{}" ;
128
- sci . ConfigurationLanguage = "haxe" ;
129
- sci . Colourise ( 0 , - 1 ) ;
130
- int funcBodyStart = ASGenerator . GetBodyStart ( 0 , 0 , sci ) ;
131
-
132
- Assert . AreEqual ( 24 , funcBodyStart ) ;
133
- Assert . AreEqual ( "function test():void{\r \n \t \r \n }" , sci . Text ) ;
134
- }
135
-
136
- [ Test ]
137
- public void EndOnSameLine ( )
138
- {
139
- var sci = GetBaseScintillaControl ( ) ;
140
- sci . Text = "function test():void\r \n \r \n {}\r \n " ;
141
- sci . ConfigurationLanguage = "as3" ;
142
- sci . Colourise ( 0 , - 1 ) ;
143
- int funcBodyStart = ASGenerator . GetBodyStart ( 0 , 2 , sci ) ;
144
-
145
- Assert . AreEqual ( 28 , funcBodyStart ) ;
146
- Assert . AreEqual ( "function test():void\r \n \r \n {\r \n \t \r \n }\r \n " , sci . Text ) ;
147
- }
148
-
149
- [ Test ]
150
- public void TextOnStartLine ( )
151
- {
152
- var sci = GetBaseScintillaControl ( ) ;
153
- sci . Text = "function test():void {trace(1);}" ;
154
- sci . ConfigurationLanguage = "as3" ;
155
- sci . Colourise ( 0 , - 1 ) ;
156
- int funcBodyStart = ASGenerator . GetBodyStart ( 0 , 2 , sci ) ;
157
-
158
- Assert . AreEqual ( 25 , funcBodyStart ) ;
159
- Assert . AreEqual ( "function test():void {\r \n \t trace(1);}" , sci . Text ) ;
160
- }
161
-
162
- [ Test ]
163
- public void BracketInCommentsOrText ( )
164
- {
165
- var sci = GetBaseScintillaControl ( ) ;
166
- sci . ConfigurationLanguage = "haxe" ;
167
- sci . Text = "function test(arg:String='{', arg2:String=\" {\" ):void/*{*/{\r \n }" ;
168
- sci . Colourise ( 0 , - 1 ) ;
169
- int funcBodyStart = ASGenerator . GetBodyStart ( 0 , 1 , sci ) ;
170
-
171
- Assert . AreEqual ( 60 , funcBodyStart ) ;
172
- }
173
-
174
- [ Test ]
175
- public void MultiByteCharacters ( )
176
- {
177
- var sci = GetBaseScintillaControl ( ) ;
178
- sci . Text = "function test():void/*áéíóú*/\r \n {}" ;
179
- sci . ConfigurationLanguage = "haxe" ;
180
- sci . Colourise ( 0 , - 1 ) ;
181
-
182
- int funcBodyStart = ASGenerator . GetBodyStart ( 0 , 1 , sci ) ;
183
-
184
- Assert . AreEqual ( 40 , funcBodyStart ) ;
185
- Assert . AreEqual ( "function test():void/*áéíóú*/\r \n {\r \n \t \r \n }" , sci . Text ) ;
186
- }
187
-
188
- [ Test ]
189
- [ Ignore ( "Having only LineFrom and LineTo for members is not enough to handle these cases. FlashDevelop in general is not too kind when it comes to several members in the same line, but we could change the method to use positions and try to get the proper position before." ) ]
190
- public void WithAnotherMemberInTheSameLine ( )
191
- {
192
- var sci = GetBaseScintillaControl ( ) ;
193
- sci . Text = "function tricky():void {} function test():void{\r \n \t \t \t }" ;
194
- int funcBodyStart = ASGenerator . GetBodyStart ( 0 , 1 , sci ) ;
195
-
196
- Assert . AreEqual ( 49 , funcBodyStart ) ;
72
+ get
73
+ {
74
+ yield return new TestCaseData ( "function test():void{\r \n \t \t \t \r \n }" , 0 , 1 , "function test():void{\r \n \t \t \t \r \n }" , 26 ) . SetName ( "SimpleCase" ) ;
75
+ // Should we reindent the second line?
76
+ yield return new TestCaseData ( "function test():void{\r \n \t \t \t }" , 0 , 1 , "function test():void{\r \n \t \t \t \r \n }" , 26 ) . SetName ( "EndOnSecondLine" ) ;
77
+ yield return new TestCaseData ( "function test():void{\r \n }" , 0 , 1 , "function test():void{\r \n \t \r \n }" , 24 ) . SetName ( "EndOnSecondLineNoExtraIndent" ) ;
78
+ yield return new TestCaseData ( "function test():void{\r \n \t \t \t //comment}" , 0 , 1 , "function test():void{\r \n \t \t \t //comment}" , 26 ) . SetName ( "CharOnSecondLine" ) ;
79
+ yield return new TestCaseData ( "function test():void{}" , 0 , 0 , "function test():void{\r \n \t \r \n }" , 24 ) . SetName ( "EndOnSameDeclarationLine" ) ;
80
+ yield return new TestCaseData ( "function test():void\r \n \r \n {}\r \n " , 0 , 2 , "function test():void\r \n \r \n {\r \n \t \r \n }\r \n " , 28 ) . SetName ( "EndOnSameLine" ) ;
81
+ yield return new TestCaseData ( "function test():void {trace(1);}" , 0 , 0 , "function test():void {\r \n \t trace(1);}" , 25 ) . SetName ( "TextOnStartLine" ) ;
82
+ yield return new TestCaseData ( "function test(arg:String='{', arg2:String=\" {\" ):void/*{*/{\r \n }" , 0 , 1 , "function test(arg:String='{', arg2:String=\" {\" ):void/*{*/{\r \n \t \r \n }" , 60 )
83
+ . SetName ( "BracketInCommentsOrText" ) ;
84
+ yield return new TestCaseData ( "function test():void/*áéíóú*/\r \n {}" , 0 , 1 , "function test():void/*áéíóú*/\r \n {\r \n \t \r \n }" , 40 ) . SetName ( "MultiByteCharacters" ) ;
85
+ yield return new TestCaseData ( "function tricky():void {} function test():void{\r \n \t \t \t }" , 0 , 1 , "function tricky():void {} function test():void{\r \n \t \t \t }" , 49 )
86
+ . SetName ( "WithAnotherMemberInTheSameLine" )
87
+ . Ignore ( "Having only LineFrom and LineTo for members is not enough to handle these cases. FlashDevelop in general is not too kind when it comes to several members in the same line, but we could change the method to use positions and try to get the proper position before." ) ;
88
+ yield return new TestCaseData ( "function test<T:{}>(arg:T):void{\r \n \r \n }" , 0 , 1 , "function test<T:{}>(arg:T):void{\r \n \r \n }" , 34 ) . SetName ( "BracketsInGenericConstraint" ) ;
89
+ }
197
90
}
198
91
199
-
200
- [ Test ]
201
- public void BracketsInGenericConstraint ( )
92
+ [ Test , TestCaseSource ( "GetBodyStartTestCases" ) ]
93
+ public void Common ( string text , int lineStart , int lineEnd , string resultText , int bodyStart )
202
94
{
203
95
var sci = GetBaseScintillaControl ( ) ;
96
+ sci . Text = text ;
204
97
sci . ConfigurationLanguage = "haxe" ;
205
- sci . Text = "function test<T:{}>(arg:T):void{\r \n \r \n }" ;
206
98
sci . Colourise ( 0 , - 1 ) ;
207
- int funcBodyStart = ASGenerator . GetBodyStart ( 0 , 1 , sci ) ;
99
+ int funcBodyStart = ASGenerator . GetBodyStart ( lineStart , lineEnd , sci ) ;
208
100
209
- Assert . AreEqual ( 34 , funcBodyStart ) ;
210
- Assert . AreEqual ( "function test<T:{}>(arg:T):void{ \r \n \r \n }" , sci . Text ) ;
101
+ Assert . AreEqual ( bodyStart , funcBodyStart ) ;
102
+ Assert . AreEqual ( resultText , sci . Text ) ;
211
103
}
212
104
}
213
105
0 commit comments