about summary refs log tree commit diff
path: root/src/tools/clippy/tests/ui-toml/functions_maxlines/test.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/clippy/tests/ui-toml/functions_maxlines/test.rs')
-rw-r--r--src/tools/clippy/tests/ui-toml/functions_maxlines/test.rs45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/tools/clippy/tests/ui-toml/functions_maxlines/test.rs b/src/tools/clippy/tests/ui-toml/functions_maxlines/test.rs
new file mode 100644
index 00000000000..a47677a1f3a
--- /dev/null
+++ b/src/tools/clippy/tests/ui-toml/functions_maxlines/test.rs
@@ -0,0 +1,45 @@
+#![warn(clippy::too_many_lines)]
+
+// This function should be considered one line.
+fn many_comments_but_one_line_of_code() {
+    /* println!("This is good."); */
+    // println!("This is good.");
+    /* */ // println!("This is good.");
+    /* */ // println!("This is good.");
+    /* */ // println!("This is good.");
+    /* */ // println!("This is good.");
+    /* println!("This is good.");
+    println!("This is good.");
+    println!("This is good."); */
+    println!("This is good.");
+}
+
+// This should be considered two and a fail.
+fn too_many_lines() {
+    println!("This is bad.");
+    println!("This is bad.");
+}
+
+// This should be considered one line.
+#[rustfmt::skip]
+fn comment_starts_after_code() {
+    let _ = 5; /* closing comment. */ /*
+    this line shouldn't be counted theoretically.
+    */
+}
+
+// This should be considered one line.
+fn comment_after_code() {
+    let _ = 5; /* this line should get counted once. */
+}
+
+// This should fail since it is technically two lines.
+#[rustfmt::skip]
+fn comment_before_code() {
+    let _ = "test";
+    /* This comment extends to the front of
+    the code but this line should still count. */ let _ = 5;
+}
+
+// This should be considered one line.
+fn main() {}