Skip to content

Commit 8c87b66

Browse files
committed
Rust: Add more test cases for comments.
1 parent 8243f87 commit 8c87b66

File tree

7 files changed

+74
-13
lines changed

7 files changed

+74
-13
lines changed

rust/ql/test/query-tests/diagnostics/ExtractedFiles.expected

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
| comments.rs:0:0:0:0 | comments.rs | File successfully extracted. |
12
| does_not_compile.rs:0:0:0:0 | does_not_compile.rs | File successfully extracted. |
23
| error.rs:0:0:0:0 | error.rs | File successfully extracted. |
34
| lib.rs:0:0:0:0 | lib.rs | File successfully extracted. |
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
| 46 |
1+
| 68 |
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
| 46 |
1+
| 68 |
Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
| comments.rs:0:0:0:0 | comments.rs | 20 |
12
| my_struct.rs:0:0:0:0 | my_struct.rs | 20 |
2-
| main.rs:0:0:0:0 | main.rs | 7 |
3+
| main.rs:0:0:0:0 | main.rs | 8 |
4+
| lib.rs:0:0:0:0 | lib.rs | 7 |
35
| my_macro.rs:0:0:0:0 | my_macro.rs | 7 |
4-
| lib.rs:0:0:0:0 | lib.rs | 6 |
56
| does_not_compile.rs:0:0:0:0 | does_not_compile.rs | 3 |
67
| error.rs:0:0:0:0 | error.rs | 3 |
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
| Elements extracted | 216 |
1+
| Elements extracted | 290 |
22
| Elements unextracted | 0 |
3-
| Files extracted | 6 |
4-
| Lines of code extracted | 46 |
5-
| Lines of user code extracted | 46 |
3+
| Files extracted | 7 |
4+
| Lines of code extracted | 68 |
5+
| Lines of user code extracted | 68 |
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/**
2+
* total lines in this file: 61
3+
* of which code: 16
4+
* of which only comments: 33
5+
* of which blank: 12
6+
*/
7+
8+
// a comment
9+
10+
/**
11+
* Comment attached to a struct.
12+
*/
13+
struct StructWithComments
14+
{
15+
/**
16+
* Another attached comment.
17+
*/
18+
a: i32,
19+
20+
// And another attached comment.
21+
b: i32,
22+
23+
/*
24+
* And yet another attached comment.
25+
*/
26+
c: i32,
27+
28+
// informal
29+
// comment
30+
// block.
31+
cd: i32,
32+
33+
// Just a comment.
34+
}
35+
36+
pub fn my_simple_func()
37+
{
38+
}
39+
40+
/**
41+
* Comment attached to a function.
42+
*/
43+
pub fn my_func_with_comments()
44+
{
45+
// comment
46+
let a = 1; // comment
47+
// comment
48+
let b = 2;
49+
50+
// comment
51+
52+
/*
53+
* Comment.
54+
*/
55+
my_simple_func();
56+
}
57+
58+
/**
59+
* Comment.
60+
*/

rust/ql/test/query-tests/diagnostics/main.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
11
/**
22
* total lines in this file: 18
3-
* of which code: 7
4-
* of which only comments: 7
3+
* of which code: 8
4+
* of which only comments: 6
55
* of which blank: 4
66
*/
77

88
mod my_struct;
99
mod my_macro;
10+
mod comments;
1011

11-
// another comment
12-
13-
fn main() { // another comment
12+
fn main() {
1413
println!("Hello, world!");
1514

1615
my_struct::my_func();

0 commit comments

Comments
 (0)