Skip to content

Commit f12befd

Browse files
committed
Add extra test for collection initialization
1 parent 8fd4098 commit f12befd

File tree

3 files changed

+15
-0
lines changed

3 files changed

+15
-0
lines changed

csharp/ql/test/library-tests/csharp9/AnonymousObjectCreation.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,9 @@ public AnonObj M1(AnonObj t)
1919
void M2(int x) { }
2020

2121
D GetM() { return new(M2); }
22+
23+
void MethodAdd()
24+
{
25+
List<int> list = new();// { 1, 2, 3 }; todo: the initializer causes an extraction error
26+
}
2227
}

csharp/ql/test/library-tests/csharp9/AnonymousObjectCreation.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@ implicitlyTypedObjectCreation
22
| AnonymousObjectCreation.cs:7:31:7:35 | object creation of type List<AnonObj> |
33
| AnonymousObjectCreation.cs:13:17:13:35 | object creation of type AnonObj |
44
| AnonymousObjectCreation.cs:14:16:14:20 | object creation of type AnonObj |
5+
| AnonymousObjectCreation.cs:25:26:25:30 | object creation of type List<Int32> |
56
implicitlyTypedDelegateCreation
67
| AnonymousObjectCreation.cs:21:23:21:29 | delegate creation of type D |

csharp/ql/test/library-tests/csharp9/PrintAst.expected

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,15 @@ AnonymousObjectCreation.cs:
4545
# 21| 0: [ExplicitDelegateCreation] delegate creation of type D
4646
# 21| 0: [ImplicitDelegateCreation] delegate creation of type D
4747
# 21| 0: [MethodAccess] access to method M2
48+
# 23| 11: [Method] MethodAdd
49+
# 23| -1: [TypeMention] Void
50+
# 24| 4: [BlockStmt] {...}
51+
# 25| 0: [LocalVariableDeclStmt] ... ...;
52+
# 25| 0: [LocalVariableDeclAndInitExpr] List<Int32> list = ...
53+
# 25| -1: [TypeMention] List<Int32>
54+
# 25| 1: [TypeMention] int
55+
# 25| 0: [LocalVariableAccess] access to local variable list
56+
# 25| 1: [ObjectCreation] object creation of type List<Int32>
4857
Discard.cs:
4958
# 3| [Class] Discard
5059
# 5| 5: [Method] M1

0 commit comments

Comments
 (0)