Skip to content

Commit 61b207f

Browse files
committed
Rework type mention test
1 parent c0e0bd2 commit 61b207f

File tree

8 files changed

+69
-43
lines changed

8 files changed

+69
-43
lines changed

csharp/ql/test/library-tests/typeMentions/nullable-enable/Program.cs renamed to csharp/ql/test/library-tests/typeMentions/NullableEnabled.cs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,6 @@ public void M1()
1919
I1? i0 = new Str();
2020
I1 i1 = new Str();
2121
}
22-
}
22+
}
23+
24+
// semmle-extractor-options: --separate-compilation
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
typeMentions
2+
| NullableDisabled.cs:6:24:6:27 | Base |
3+
| NullableDisabled.cs:8:23:8:24 | I0 |
4+
| NullableDisabled.cs:9:21:9:22 | I1 |
5+
| NullableDisabled.cs:13:12:13:15 | Void |
6+
| NullableDisabled.cs:15:9:15:15 | Derived |
7+
| NullableDisabled.cs:15:27:15:33 | Derived |
8+
| NullableDisabled.cs:16:9:16:15 | Derived |
9+
| NullableDisabled.cs:16:26:16:32 | Derived |
10+
| NullableDisabled.cs:17:9:17:11 | Str |
11+
| NullableDisabled.cs:17:9:17:12 | Nullable<Str> |
12+
| NullableDisabled.cs:17:23:17:25 | Str |
13+
| NullableDisabled.cs:18:9:18:11 | Str |
14+
| NullableDisabled.cs:18:22:18:24 | Str |
15+
| NullableDisabled.cs:19:9:19:10 | I1 |
16+
| NullableDisabled.cs:19:22:19:24 | Str |
17+
| NullableDisabled.cs:20:9:20:10 | I1 |
18+
| NullableDisabled.cs:20:21:20:23 | Str |
19+
| NullableEnabled.cs:6:24:6:27 | Base |
20+
| NullableEnabled.cs:8:23:8:24 | I0 |
21+
| NullableEnabled.cs:9:21:9:22 | I1 |
22+
| NullableEnabled.cs:13:12:13:15 | Void |
23+
| NullableEnabled.cs:15:9:15:15 | Derived |
24+
| NullableEnabled.cs:15:27:15:33 | Derived |
25+
| NullableEnabled.cs:16:9:16:15 | Derived |
26+
| NullableEnabled.cs:16:26:16:32 | Derived |
27+
| NullableEnabled.cs:17:9:17:11 | Str |
28+
| NullableEnabled.cs:17:9:17:12 | Nullable<Str> |
29+
| NullableEnabled.cs:17:23:17:25 | Str |
30+
| NullableEnabled.cs:18:9:18:11 | Str |
31+
| NullableEnabled.cs:18:22:18:24 | Str |
32+
| NullableEnabled.cs:19:9:19:10 | I1 |
33+
| NullableEnabled.cs:19:22:19:24 | Str |
34+
| NullableEnabled.cs:20:9:20:10 | I1 |
35+
| NullableEnabled.cs:20:21:20:23 | Str |
36+
duplicates
37+
diff
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import csharp
2+
3+
private predicate matchingLineLoc(TypeMention tm0, TypeMention tm1) {
4+
tm0.getLocation().getStartLine() = tm1.getLocation().getStartLine() and
5+
tm0.getLocation().getEndLine() = tm1.getLocation().getEndLine() and
6+
tm0.getLocation().getStartColumn() = tm1.getLocation().getStartColumn() and
7+
tm0.getLocation().getEndColumn() = tm1.getLocation().getEndColumn()
8+
}
9+
10+
private predicate matchingFile(TypeMention tm0, TypeMention tm1) {
11+
tm0.getLocation().getFile().getStem() = tm1.getLocation().getFile().getStem()
12+
}
13+
14+
query predicate typeMentions(TypeMention tm) { any() }
15+
16+
query predicate duplicates(TypeMention tm) {
17+
exists(TypeMention other |
18+
matchingLineLoc(other, tm) and
19+
matchingFile(other, tm) and
20+
other != tm
21+
)
22+
}
23+
24+
query predicate diff(TypeMention tm) {
25+
not exists(TypeMention other |
26+
matchingLineLoc(other, tm) and
27+
not matchingFile(other, tm)
28+
)
29+
}

csharp/ql/test/library-tests/typeMentions/nullable-disable/TypeMentions.expected

Lines changed: 0 additions & 17 deletions
This file was deleted.

csharp/ql/test/library-tests/typeMentions/nullable-disable/TypeMentions.ql

Lines changed: 0 additions & 4 deletions
This file was deleted.

csharp/ql/test/library-tests/typeMentions/nullable-enable/TypeMentions.expected

Lines changed: 0 additions & 17 deletions
This file was deleted.

csharp/ql/test/library-tests/typeMentions/nullable-enable/TypeMentions.ql

Lines changed: 0 additions & 4 deletions
This file was deleted.

0 commit comments

Comments
 (0)