4
4
import static twg2 .parser .test .utils .FieldAssert .assertField ;
5
5
import static twg2 .parser .test .utils .MethodAssert .assertParameter ;
6
6
import static twg2 .parser .test .utils .TypeAssert .assertType ;
7
+ import static twg2 .parser .test .utils .TypeAssert .ary ;
7
8
import static twg2 .parser .test .utils .TypeAssert .ls ;
8
9
9
10
import java .io .IOException ;
10
11
import java .nio .file .Paths ;
11
- import java .util .Arrays ;
12
12
import java .util .Collections ;
13
13
import java .util .List ;
14
14
import java .util .Map .Entry ;
41
41
* @since 2016-1-1
42
42
*/
43
43
public class CsClassParseTest {
44
- private static List <String > srcLines = Arrays . asList (
44
+ private static List <String > srcLines = ls (
45
45
"namespace ParserExamples.Samples {" ,
46
46
"" ,
47
47
" /// <summary>" ,
@@ -111,7 +111,7 @@ public class CsClassParseTest {
111
111
private CodeFileAndAst <CsBlock > simpleCs = CodeFileAndAst .<CsBlock >parse (CodeLanguageOptions .C_SHARP , "SimpleCs.cs" , "ParserExamples.Samples.SimpleCs" , true , srcLines );
112
112
113
113
@ Parameter
114
- private CodeFileSrc file = ParseCodeFile .parseFiles (Arrays . asList (Paths .get ("rsc/csharp/ParserExamples/Models/TrackInfo.cs" )), FileReadUtil .threadLocalInst (), null ).get (0 );
114
+ private CodeFileSrc file = ParseCodeFile .parseFiles (ls (Paths .get ("rsc/csharp/ParserExamples/Models/TrackInfo.cs" )), FileReadUtil .threadLocalInst (), null ).get (0 );
115
115
116
116
117
117
public CsClassParseTest () throws IOException {
@@ -128,6 +128,8 @@ public void parseBlocksTest() {
128
128
ClassAst .SimpleImpl <CsBlock > trackInfoBlock = blocks .get (0 ).getValue ();
129
129
Assert .assertEquals (CsBlock .CLASS , trackInfoBlock .getBlockType ());
130
130
Assert .assertEquals ("TrackInfo" , trackInfoBlock .getSignature ().getSimpleName ());
131
+
132
+ Assert .assertEquals (ls ("ISerializable" , "IComparable<TrackInfo>" ), trackInfoBlock .getSignature ().getExtendImplementSimpleNames ());
131
133
}
132
134
133
135
@@ -145,9 +147,9 @@ public void simpleCsParseTest() {
145
147
146
148
List <FieldSig > fs = clas .getFields ();
147
149
assertField (fs , 0 , fullClassName + ".mod" , "int" );
148
- Assert .assertEquals (Arrays .asList (" <value>The modification count.</value>\n " ), fs .get (0 ).getComments ());
149
- // annotation: EmptyAnnotation()
150
+ Assert .assertEquals (ls (" <value>The modification count.</value>\n " ), fs .get (0 ).getComments ());
150
151
List <AnnotationSig > as = fs .get (0 ).getAnnotations ();
152
+ // annotation: EmptyAnnotation()
151
153
assertAnnotation (as , 0 , "EmptyAnnotation" , new String [0 ], new String [0 ]);
152
154
// annotation: IntAnnotation(-1)
153
155
assertAnnotation (as , 1 , "IntAnnotation" , new String [] { "value" }, "-1" );
@@ -163,7 +165,7 @@ public void simpleCsParseTest() {
163
165
assertAnnotation (as , 6 , "MultiNamedArgAnnotation" , new String [] { "num" , "flag" , "value" }, "1.23" , "false" , "abc" );
164
166
165
167
assertField (fs , 1 , fullClassName + "._name" , "string" );
166
- assertField (fs , 2 , fullClassName + ".Names" , ls ("IList" , ls ("string" )));
168
+ assertField (fs , 2 , fullClassName + ".Names" , ary ("IList" , ary ("string" )));
167
169
assertField (fs , 3 , fullClassName + ".Count" , "int" );
168
170
assertField (fs , 4 , fullClassName + ".C2" , "float" );
169
171
assertField (fs , 5 , fullClassName + ".C3" , "decimal" );
@@ -175,13 +177,13 @@ public void simpleCsParseTest() {
175
177
// AddName(...)
176
178
MethodSigSimple m = clas .getMethods ().get (0 );
177
179
Assert .assertEquals (fullClassName + ".AddName" , NameUtil .joinFqName (m .fullName ));
178
- Assert .assertEquals (Arrays . asList (" <summary>Add name</summary>\n " ,
180
+ Assert .assertEquals (ls (" <summary>Add name</summary>\n " ,
179
181
" <param name=\" name\" >the name</param>\n " ,
180
182
" <returns>the names</returns>\n " ), m .comments );
181
183
List <ParameterSig > ps = m .paramSigs ;
182
184
Assert .assertEquals (2 , ps .size ());
183
- assertParameter (ps , 0 , "name" , "string" , null , Arrays . asList (new AnnotationSig ("NotNull" , NameUtil .splitFqName ("NotNull" ), Collections .emptyMap ())));
184
- assertParameter (ps , 1 , "zest" , "int" , null , null );
185
+ assertParameter (ps , 0 , "name" , "string" , null , null , ls (new AnnotationSig ("NotNull" , NameUtil .splitFqName ("NotNull" ), Collections .emptyMap ())));
186
+ assertParameter (ps , 1 , "zest" , "int" , "0" , null , null );
185
187
// annotations:
186
188
//{"name": "OperationContract", "arguments": { } },
187
189
assertAnnotation (m .annotations , 0 , "OperationContract" , new String [0 ], new String [0 ]);
@@ -193,15 +195,15 @@ public void simpleCsParseTest() {
193
195
assertAnnotation (m .annotations , 2 , "TransactionFlow" , new String [] { "value" }, new String [] { "TransactionFlowOption.Allowed" });
194
196
195
197
//returnType: {"typeName": "Result", "genericParameters": [ {"typeName": "IList", "genericParameters": [ {"typeName": "String"}]}]}
196
- assertType (ls ("Result" , ls ("IList" , ls ("String" ))), m .returnType );
198
+ assertType (ary ("Result" , ary ("IList" , ary ("String" ))), m .returnType );
197
199
198
200
// SetNames(...)
199
201
m = clas .getMethods ().get (1 );
200
202
Assert .assertEquals (fullClassName + ".SetNames" , NameUtil .joinFqName (m .fullName ));
201
- List < ParameterSig > params = m .paramSigs ;
202
- assertParameter (params , 0 , "inst" , "SimpleCs" , Arrays . asList (CsKeyword .THIS ), null );
203
- assertParameter (params , 1 , "constraints" , "Constraints" , Arrays . asList (CsKeyword .REF ), null );
204
- assertParameter (params , 2 , "names" , "string[]" , Arrays . asList (CsKeyword .PARAMS ), null );
203
+ ps = m .paramSigs ;
204
+ assertParameter (ps , 0 , "inst" , "SimpleCs" , null , ls (CsKeyword .THIS ), null );
205
+ assertParameter (ps , 1 , "constraints" , "Constraints" , null , ls (CsKeyword .REF ), null );
206
+ assertParameter (ps , 2 , "names" , "string[]" , null , ls (CsKeyword .PARAMS ), null );
205
207
}
206
208
207
209
}
0 commit comments