Skip to content

Commit f5fc15e

Browse files
committed
C#: Add some testcases to cover mixed assignment and declarations in tuples.
1 parent 0cf4b3f commit f5fc15e

File tree

3 files changed

+59
-0
lines changed

3 files changed

+59
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using System;
2+
3+
public class Deconstruction
4+
{
5+
public void M1()
6+
{
7+
// Declaration and Assignment
8+
(int x1, int y1) = (10, 11);
9+
10+
// Assignment
11+
int x2 = 0;
12+
int y2 = 0;
13+
(x2, y2) = (20, 21);
14+
15+
// Mixed
16+
int y3 = 0;
17+
(int x3, y3) = (30, 31);
18+
19+
int x4 = 0;
20+
(x4, int y4) = (40, 41);
21+
22+
// Nested, Mixed
23+
int x5 = 0;
24+
int y51 = 0;
25+
(x5, (int y50, y51)) = (50, (51, 52));
26+
}
27+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
declarations
2+
| Tuples.cs:8:14:8:15 | Int32 x1 |
3+
| Tuples.cs:8:22:8:23 | Int32 y1 |
4+
| Tuples.cs:17:14:17:15 | Int32 x3 |
5+
| Tuples.cs:20:18:20:19 | Int32 y4 |
6+
| Tuples.cs:25:19:25:21 | Int32 y50 |
7+
assignments
8+
| Tuples.cs:8:9:8:35 | ... = ... | Tuples.cs:8:14:8:15 | x1 | 0 |
9+
| Tuples.cs:8:9:8:35 | ... = ... | Tuples.cs:8:22:8:23 | y1 | 1 |
10+
| Tuples.cs:13:9:13:27 | ... = ... | Tuples.cs:11:13:11:14 | x2 | 0 |
11+
| Tuples.cs:13:9:13:27 | ... = ... | Tuples.cs:12:13:12:14 | y2 | 1 |
12+
| Tuples.cs:17:9:17:31 | ... = ... | Tuples.cs:16:13:16:14 | y3 | 1 |
13+
| Tuples.cs:17:9:17:31 | ... = ... | Tuples.cs:17:14:17:15 | x3 | 0 |
14+
| Tuples.cs:20:9:20:31 | ... = ... | Tuples.cs:19:13:19:14 | x4 | 0 |
15+
| Tuples.cs:20:9:20:31 | ... = ... | Tuples.cs:20:18:20:19 | y4 | 1 |
16+
| Tuples.cs:25:9:25:45 | ... = ... | Tuples.cs:23:13:23:14 | x5 | 0 |
17+
| Tuples.cs:25:9:25:45 | ... = ... | Tuples.cs:24:13:24:15 | y51 | 2 |
18+
| Tuples.cs:25:9:25:45 | ... = ... | Tuples.cs:25:19:25:21 | y50 | 1 |
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import csharp
2+
3+
private predicate relevant(Element e) { e.getFile().getBaseName() = "Tuples.cs" }
4+
5+
query predicate declarations(LocalVariableDeclExpr d) {
6+
relevant(d) and
7+
d.getParent*() instanceof TupleExpr
8+
}
9+
10+
query predicate assignments(AssignableDefinitions::TupleAssignmentDefinition t, Assignable a, int o) {
11+
relevant(t.getAssignment()) and
12+
a = t.getTarget() and
13+
o = t.getEvaluationOrder()
14+
}

0 commit comments

Comments
 (0)