Skip to content

Commit cd0f094

Browse files
committed
Move tests to the end of the file in utils mod.rs
1 parent f1a72e9 commit cd0f094

File tree

1 file changed

+81
-81
lines changed

1 file changed

+81
-81
lines changed

clippy_lints/src/utils/mod.rs

Lines changed: 81 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1198,87 +1198,6 @@ pub fn is_normalizable<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, param_env: ty::Para
11981198
})
11991199
}
12001200

1201-
#[cfg(test)]
1202-
mod test {
1203-
use super::{trim_multiline, without_block_comments};
1204-
1205-
#[test]
1206-
fn test_trim_multiline_single_line() {
1207-
assert_eq!("", trim_multiline("".into(), false));
1208-
assert_eq!("...", trim_multiline("...".into(), false));
1209-
assert_eq!("...", trim_multiline(" ...".into(), false));
1210-
assert_eq!("...", trim_multiline("\t...".into(), false));
1211-
assert_eq!("...", trim_multiline("\t\t...".into(), false));
1212-
}
1213-
1214-
#[test]
1215-
#[rustfmt::skip]
1216-
fn test_trim_multiline_block() {
1217-
assert_eq!("\
1218-
if x {
1219-
y
1220-
} else {
1221-
z
1222-
}", trim_multiline(" if x {
1223-
y
1224-
} else {
1225-
z
1226-
}".into(), false));
1227-
assert_eq!("\
1228-
if x {
1229-
\ty
1230-
} else {
1231-
\tz
1232-
}", trim_multiline(" if x {
1233-
\ty
1234-
} else {
1235-
\tz
1236-
}".into(), false));
1237-
}
1238-
1239-
#[test]
1240-
#[rustfmt::skip]
1241-
fn test_trim_multiline_empty_line() {
1242-
assert_eq!("\
1243-
if x {
1244-
y
1245-
1246-
} else {
1247-
z
1248-
}", trim_multiline(" if x {
1249-
y
1250-
1251-
} else {
1252-
z
1253-
}".into(), false));
1254-
}
1255-
1256-
#[test]
1257-
fn test_without_block_comments_lines_without_block_comments() {
1258-
let result = without_block_comments(vec!["/*", "", "*/"]);
1259-
println!("result: {:?}", result);
1260-
assert!(result.is_empty());
1261-
1262-
let result = without_block_comments(vec!["", "/*", "", "*/", "#[crate_type = \"lib\"]", "/*", "", "*/", ""]);
1263-
assert_eq!(result, vec!["", "#[crate_type = \"lib\"]", ""]);
1264-
1265-
let result = without_block_comments(vec!["/* rust", "", "*/"]);
1266-
assert!(result.is_empty());
1267-
1268-
let result = without_block_comments(vec!["/* one-line comment */"]);
1269-
assert!(result.is_empty());
1270-
1271-
let result = without_block_comments(vec!["/* nested", "/* multi-line", "comment", "*/", "test", "*/"]);
1272-
assert!(result.is_empty());
1273-
1274-
let result = without_block_comments(vec!["/* nested /* inline /* comment */ test */ */"]);
1275-
assert!(result.is_empty());
1276-
1277-
let result = without_block_comments(vec!["foo", "bar", "baz"]);
1278-
assert_eq!(result, vec!["foo", "bar", "baz"]);
1279-
}
1280-
}
1281-
12821201
pub fn match_def_path<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, did: DefId, syms: &[&str]) -> bool {
12831202
let path = cx.get_def_path(did);
12841203
path.len() == syms.len() && path.into_iter().zip(syms.iter()).all(|(a, &b)| a.as_str() == b)
@@ -1426,3 +1345,84 @@ pub fn is_trait_impl_item(cx: &LateContext<'_, '_>, hir_id: HirId) -> bool {
14261345
false
14271346
}
14281347
}
1348+
1349+
#[cfg(test)]
1350+
mod test {
1351+
use super::{trim_multiline, without_block_comments};
1352+
1353+
#[test]
1354+
fn test_trim_multiline_single_line() {
1355+
assert_eq!("", trim_multiline("".into(), false, None));
1356+
assert_eq!("...", trim_multiline("...".into(), false, None));
1357+
assert_eq!("...", trim_multiline(" ...".into(), false, None));
1358+
assert_eq!("...", trim_multiline("\t...".into(), false, None));
1359+
assert_eq!("...", trim_multiline("\t\t...".into(), false, None));
1360+
}
1361+
1362+
#[test]
1363+
#[rustfmt::skip]
1364+
fn test_trim_multiline_block() {
1365+
assert_eq!("\
1366+
if x {
1367+
y
1368+
} else {
1369+
z
1370+
}", trim_multiline(" if x {
1371+
y
1372+
} else {
1373+
z
1374+
}".into(), false, None));
1375+
assert_eq!("\
1376+
if x {
1377+
\ty
1378+
} else {
1379+
\tz
1380+
}", trim_multiline(" if x {
1381+
\ty
1382+
} else {
1383+
\tz
1384+
}".into(), false, None));
1385+
}
1386+
1387+
#[test]
1388+
#[rustfmt::skip]
1389+
fn test_trim_multiline_empty_line() {
1390+
assert_eq!("\
1391+
if x {
1392+
y
1393+
1394+
} else {
1395+
z
1396+
}", trim_multiline(" if x {
1397+
y
1398+
1399+
} else {
1400+
z
1401+
}".into(), false, None));
1402+
}
1403+
1404+
#[test]
1405+
fn test_without_block_comments_lines_without_block_comments() {
1406+
let result = without_block_comments(vec!["/*", "", "*/"]);
1407+
println!("result: {:?}", result);
1408+
assert!(result.is_empty());
1409+
1410+
let result = without_block_comments(vec!["", "/*", "", "*/", "#[crate_type = \"lib\"]", "/*", "", "*/", ""]);
1411+
assert_eq!(result, vec!["", "#[crate_type = \"lib\"]", ""]);
1412+
1413+
let result = without_block_comments(vec!["/* rust", "", "*/"]);
1414+
assert!(result.is_empty());
1415+
1416+
let result = without_block_comments(vec!["/* one-line comment */"]);
1417+
assert!(result.is_empty());
1418+
1419+
let result = without_block_comments(vec!["/* nested", "/* multi-line", "comment", "*/", "test", "*/"]);
1420+
assert!(result.is_empty());
1421+
1422+
let result = without_block_comments(vec!["/* nested /* inline /* comment */ test */ */"]);
1423+
assert!(result.is_empty());
1424+
1425+
let result = without_block_comments(vec!["foo", "bar", "baz"]);
1426+
assert_eq!(result, vec!["foo", "bar", "baz"]);
1427+
}
1428+
}

0 commit comments

Comments
 (0)