Skip to content

Commit 7a77740

Browse files
committed
C#: Extractor tests for
- While statements - Object initializers
1 parent 727ab94 commit 7a77740

File tree

4 files changed

+38
-0
lines changed

4 files changed

+38
-0
lines changed

csharp/ql/test/library-tests/regressions/Program.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,28 @@ int Test()
8181
return 0;
8282
}
8383
}
84+
85+
class WhileIs
86+
{
87+
void Test()
88+
{
89+
object x = null;
90+
while(x is string s)
91+
{
92+
var y = s;
93+
}
94+
}
95+
}
96+
97+
class ObjectInitializerType
98+
{
99+
struct Point
100+
{
101+
public object Name;
102+
}
103+
104+
void F()
105+
{
106+
new Point() { Name = "Bob" };
107+
}
108+
}

csharp/ql/test/library-tests/regressions/TypeMentions.expected

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,10 @@
3939
| Program.cs:69:5:69:8 | Boolean |
4040
| Program.cs:69:16:69:18 | Int32 |
4141
| Program.cs:75:5:75:7 | Int32 |
42+
| Program.cs:87:5:87:8 | Void |
43+
| Program.cs:89:9:89:14 | Object |
44+
| Program.cs:90:20:90:25 | String |
45+
| Program.cs:92:13:92:15 | String |
46+
| Program.cs:101:16:101:21 | Object |
47+
| Program.cs:104:5:104:8 | Void |
48+
| Program.cs:106:13:106:17 | Point |
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
| Program.cs:92:21:92:21 | access to local variable s |
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import csharp
2+
3+
from LocalVariable decl
4+
where decl.getName() = "s"
5+
select decl.getAnAccess()

0 commit comments

Comments
 (0)