Skip to content

Commit 48b96a8

Browse files
committed
C#: Add more testcases and update expected output.
1 parent bd1392e commit 48b96a8

3 files changed

Lines changed: 20 additions & 12 deletions

File tree

csharp/ql/test/library-tests/spans/Slice.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,20 @@
22

33
public class C
44
{
5-
public void M(int a)
5+
public void M(int a, int b)
66
{
77
var s = "hello world";
88
var sub1 = s[1..a];
99
var sub2 = s[..2];
1010
var sub3 = s[3..];
1111
var sub4 = s[..^4];
12+
var sub5 = s[a..^b];
1213

1314
Span<int> sp = null;
1415
var slice1 = sp[5..a];
1516
var slice2 = sp[..6];
1617
var slice3 = sp[7..];
1718
var slice4 = sp[..^8];
19+
var slice5 = sp[a..^b];
1820
}
1921
}

csharp/ql/test/library-tests/spans/slice.expected

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,22 @@ methodCalls
77
| Slice.cs:10:20:10:25 | call to method Substring | Substring(int, int) | 1 | access to property Length - 3 |
88
| Slice.cs:11:20:11:26 | call to method Substring | Substring(int, int) | 0 | 0 |
99
| Slice.cs:11:20:11:26 | call to method Substring | Substring(int, int) | 1 | access to property Length - 4 |
10-
| Slice.cs:14:22:14:29 | call to method Slice | Slice(int, int) | 0 | 5 |
11-
| Slice.cs:14:22:14:29 | call to method Slice | Slice(int, int) | 1 | access to parameter a - 5 |
12-
| Slice.cs:15:22:15:28 | call to method Slice | Slice(int, int) | 0 | 0 |
13-
| Slice.cs:15:22:15:28 | call to method Slice | Slice(int, int) | 1 | 6 |
14-
| Slice.cs:16:22:16:28 | call to method Slice | Slice(int, int) | 0 | 7 |
15-
| Slice.cs:16:22:16:28 | call to method Slice | Slice(int, int) | 1 | access to property Length - 7 |
16-
| Slice.cs:17:22:17:29 | call to method Slice | Slice(int, int) | 0 | 0 |
17-
| Slice.cs:17:22:17:29 | call to method Slice | Slice(int, int) | 1 | access to property Length - 8 |
10+
| Slice.cs:12:20:12:27 | call to method Substring | Substring(int, int) | 0 | access to parameter a |
11+
| Slice.cs:12:20:12:27 | call to method Substring | Substring(int, int) | 1 | access to property Length - access to parameter b - access to parameter a |
12+
| Slice.cs:15:22:15:29 | call to method Slice | Slice(int, int) | 0 | 5 |
13+
| Slice.cs:15:22:15:29 | call to method Slice | Slice(int, int) | 1 | access to parameter a - 5 |
14+
| Slice.cs:16:22:16:28 | call to method Slice | Slice(int, int) | 0 | 0 |
15+
| Slice.cs:16:22:16:28 | call to method Slice | Slice(int, int) | 1 | 6 |
16+
| Slice.cs:17:22:17:28 | call to method Slice | Slice(int, int) | 0 | 7 |
17+
| Slice.cs:17:22:17:28 | call to method Slice | Slice(int, int) | 1 | access to property Length - 7 |
18+
| Slice.cs:18:22:18:29 | call to method Slice | Slice(int, int) | 0 | 0 |
19+
| Slice.cs:18:22:18:29 | call to method Slice | Slice(int, int) | 1 | access to property Length - 8 |
20+
| Slice.cs:19:22:19:30 | call to method Slice | Slice(int, int) | 0 | access to parameter a |
21+
| Slice.cs:19:22:19:30 | call to method Slice | Slice(int, int) | 1 | access to property Length - access to parameter b - access to parameter a |
1822
propertyCalls
1923
| Slice.cs:10:20:10:25 | access to property Length | Slice.cs:10:20:10:20 | access to local variable s |
2024
| Slice.cs:11:20:11:26 | access to property Length | Slice.cs:11:20:11:20 | access to local variable s |
21-
| Slice.cs:16:22:16:28 | access to property Length | Slice.cs:16:22:16:23 | access to local variable sp |
22-
| Slice.cs:17:22:17:29 | access to property Length | Slice.cs:17:22:17:23 | access to local variable sp |
25+
| Slice.cs:12:20:12:27 | access to property Length | Slice.cs:12:20:12:20 | access to local variable s |
26+
| Slice.cs:17:22:17:28 | access to property Length | Slice.cs:17:22:17:23 | access to local variable sp |
27+
| Slice.cs:18:22:18:29 | access to property Length | Slice.cs:18:22:18:23 | access to local variable sp |
28+
| Slice.cs:19:22:19:30 | access to property Length | Slice.cs:19:22:19:23 | access to local variable sp |

csharp/ql/test/library-tests/spans/slice.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import csharp
33
private string printExpr(Expr e) {
44
e =
55
any(SubExpr sub |
6-
result = sub.getLeftOperand().toString() + " - " + sub.getRightOperand().toString()
6+
result = printExpr(sub.getLeftOperand()) + " - " + printExpr(sub.getRightOperand())
77
)
88
or
99
not e instanceof SubExpr and

0 commit comments

Comments
 (0)