Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit c3ef684

Browse files
committed
Add tests for trivia types
1 parent 3be229f commit c3ef684

4 files changed

Lines changed: 83 additions & 0 deletions

File tree

csharp/ql/test/library-tests/comments/BindingAfter.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,4 @@
5555
| comments2.cs:118:5:118:21 | // ... | comments2.cs:119:11:119:25 | GenericClass<> | GenericClass<> |
5656
| comments2.cs:124:5:124:16 | // ... | comments2.cs:125:9:125:20 | GenericFn | GenericFn |
5757
| comments2.cs:127:20:127:23 | // ... | comments2.cs:128:9:128:17 | return ...; | x |
58+
| trivia.cs:1:1:3:15 | // ... | trivia.cs:14:7:14:9 | Tr1 | semmle-extractor-options: --standalone |

csharp/ql/test/library-tests/comments/Comments.expected

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ singlelineComment
7070
| comments2.cs:124:5:124:16 | // ... | comments2.cs:124:5:124:16 | // ... | 1 | GenericFn | // GenericFn |
7171
| comments2.cs:127:20:127:23 | // ... | comments2.cs:127:20:127:23 | // ... | 1 | x | // x |
7272
| comments2.cs:132:1:132:21 | // ... | comments2.cs:132:1:132:21 | // ... | 1 | End of comment2.cs | // End of comment2.cs |
73+
| trivia.cs:1:1:3:15 | // ... | trivia.cs:1:1:1:42 | // ... | 3 | semmle-extractor-options: --standalone | // semmle-extractor-options: --standalone |
74+
| trivia.cs:1:1:3:15 | // ... | trivia.cs:2:1:2:21 | // ... | 3 | Start of trivia.cs | // Start of trivia.cs |
75+
| trivia.cs:1:1:3:15 | // ... | trivia.cs:3:1:3:15 | // ... | 3 | Unassociated | // Unassociated |
7376
multilineComment
7477
| comments1.cs:11:1:11:25 | /* ... */ | comments1.cs:11:1:11:25 | /* ... */ | 1 | A multiline comment | /* A multiline comment */ |
7578
| comments1.cs:25:1:25:43 | /* ... */ | comments1.cs:25:1:25:15 | /* ... */ | 2 | This is a | /* This is a */ |

csharp/ql/test/library-tests/comments/Orphans.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,4 @@
1414
| comments2.cs:5:27:5:41 | // ... |
1515
| comments2.cs:8:1:8:15 | // ... |
1616
| comments2.cs:132:1:132:21 | // ... |
17+
| trivia.cs:1:1:3:15 | // ... |
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
// semmle-extractor-options: --standalone
2+
// Start of trivia.cs
3+
// Unassociated
4+
#define DEBUG
5+
6+
#undef DEBUG
7+
8+
using System;
9+
using System.Collections;
10+
using System.Collections.Generic;
11+
12+
#pragma warning disable 414, CS3021
13+
#pragma checksum "file.cs" "{406EA660-64CF-4C82-B6F0-42D48172A799}" "ab007f1d23d9" // New checksum
14+
class Tr1
15+
{
16+
static void M1()
17+
{
18+
#line 200 "Special"
19+
int i;
20+
int j;
21+
#line default
22+
char c;
23+
#pragma warning restore
24+
float f;
25+
#line hidden // numbering not affected
26+
string s;
27+
#line default
28+
double d;
29+
}
30+
}
31+
32+
class Tr2
33+
{
34+
static void M1()
35+
{
36+
#region fields
37+
int i;
38+
#region nested
39+
int j;
40+
#endregion
41+
#endregion
42+
}
43+
}
44+
45+
class Tr3
46+
{
47+
static void M1()
48+
{
49+
#nullable disable// Sets the nullable annotation and warning contexts to disabled.
50+
#nullable enable// Sets the nullable annotation and warning contexts to enabled.
51+
#nullable restore// Restores the nullable annotation and warning contexts to project settings.
52+
#nullable disable annotations// Sets the nullable annotation context to disabled.
53+
#nullable enable annotations// Sets the nullable annotation context to enabled.
54+
#nullable restore annotations// Restores the nullable annotation context to project settings.
55+
#nullable disable warnings// Sets the nullable warning context to disabled.
56+
#nullable enable warnings// Sets the nullable warning context to enabled.
57+
#nullable restore warnings// Restores the nullable warning context to project settings.
58+
}
59+
}
60+
61+
class Tr4
62+
{
63+
static void M1()
64+
{
65+
#if DEBUG
66+
#warning DEBUG is defined
67+
var i = 0;
68+
#if NESTED
69+
i--;
70+
#endif
71+
#elif (NOTDEBUG == true) || !(TEST)
72+
#error NOTDEBUG is defined or TEST is not
73+
var i = 1;
74+
#else
75+
var i = 2;
76+
#endif
77+
}
78+
}

0 commit comments

Comments
 (0)