summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorLaurenz <laurmaedje@gmail.com>2023-04-18 19:10:55 +0200
committerLaurenz <laurmaedje@gmail.com>2023-04-18 19:16:13 +0200
commitd10b53df0b487036b0d639b6033f4568648cfff1 (patch)
tree5209581e847af37c9a770e2e7e43d95bff2e113f /tests
parent35302d20047c58baa99065a4574eafe1920e7be6 (diff)
Clippy
Diffstat (limited to 'tests')
-rw-r--r--tests/src/benches.rs6
-rw-r--r--tests/src/tests.rs16
2 files changed, 12 insertions, 10 deletions
diff --git a/tests/src/benches.rs b/tests/src/benches.rs
index b1e77692..9e9b98d0 100644
--- a/tests/src/benches.rs
+++ b/tests/src/benches.rs
@@ -30,8 +30,8 @@ fn bench_decode(iai: &mut Iai) {
// We don't use chars().count() because that has a special
// superfast implementation.
let mut count = 0;
- let mut chars = black_box(TEXT).chars();
- while let Some(_) = chars.next() {
+ let chars = black_box(TEXT).chars();
+ for _ in chars {
count += 1;
}
count
@@ -42,7 +42,7 @@ fn bench_scan(iai: &mut Iai) {
iai.run(|| {
let mut count = 0;
let mut scanner = Scanner::new(black_box(TEXT));
- while let Some(_) = scanner.eat() {
+ while scanner.eat().is_some() {
count += 1;
}
count
diff --git a/tests/src/tests.rs b/tests/src/tests.rs
index fef8c0cf..46bf343c 100644
--- a/tests/src/tests.rs
+++ b/tests/src/tests.rs
@@ -1,3 +1,5 @@
+#![allow(clippy::comparison_chain)]
+
use std::cell::{RefCell, RefMut};
use std::collections::HashMap;
use std::env;
@@ -324,10 +326,10 @@ fn read(path: &Path) -> FileResult<Vec<u8>> {
.unwrap_or_else(|_| path.into());
let f = |e| FileError::from_io(e, &suffix);
- if fs::metadata(&path).map_err(f)?.is_dir() {
+ if fs::metadata(path).map_err(f)?.is_dir() {
Err(FileError::IsDirectory)
} else {
- fs::read(&path).map_err(f)
+ fs::read(path).map_err(f)
}
}
@@ -379,7 +381,7 @@ fn test(
if compare_ever {
if let Some(pdf_path) = pdf_path {
let pdf_data = typst::export::pdf(&document);
- fs::create_dir_all(&pdf_path.parent().unwrap()).unwrap();
+ fs::create_dir_all(pdf_path.parent().unwrap()).unwrap();
fs::write(pdf_path, pdf_data).unwrap();
}
@@ -390,7 +392,7 @@ fn test(
}
let canvas = render(&document.pages);
- fs::create_dir_all(&png_path.parent().unwrap()).unwrap();
+ fs::create_dir_all(png_path.parent().unwrap()).unwrap();
canvas.save_png(png_path).unwrap();
if let Ok(ref_pixmap) = sk::Pixmap::load_png(ref_path) {
@@ -438,7 +440,7 @@ fn test_part(
println!("Syntax Tree:\n{:#?}\n", source.root())
}
- let (local_compare_ref, mut ref_errors) = parse_metadata(&source);
+ let (local_compare_ref, mut ref_errors) = parse_metadata(source);
let compare_ref = local_compare_ref.unwrap_or(compare_ref);
ok &= test_spans(source.root());
@@ -482,14 +484,14 @@ fn test_part(
for error in errors.iter() {
if !ref_errors.contains(error) {
print!(" Not annotated | ");
- print_error(&source, line, error);
+ print_error(source, line, error);
}
}
for error in ref_errors.iter() {
if !errors.contains(error) {
print!(" Not emitted | ");
- print_error(&source, line, error);
+ print_error(source, line, error);
}
}
}