From 879ac263bd378316525fb073d3fd122fbf429d22 Mon Sep 17 00:00:00 2001 From: Roy Ivy III Date: Sun, 30 May 2021 18:37:45 -0500 Subject: [PATCH] refactor/test ~ polish spelling (comments, names, and exceptions) --- src/uu/test/src/parser.rs | 2 ++ src/uu/test/src/test.rs | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/uu/test/src/parser.rs b/src/uu/test/src/parser.rs index a77bfabb3..d4302bd67 100644 --- a/src/uu/test/src/parser.rs +++ b/src/uu/test/src/parser.rs @@ -5,6 +5,8 @@ // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. +// spell-checker:ignore (grammar) BOOLOP STRLEN FILETEST FILEOP INTOP STRINGOP ; (vars) LParen StrlenOp + use std::ffi::OsString; use std::iter::Peekable; diff --git a/src/uu/test/src/test.rs b/src/uu/test/src/test.rs index 86950ecc2..acf0f7eca 100644 --- a/src/uu/test/src/test.rs +++ b/src/uu/test/src/test.rs @@ -6,7 +6,7 @@ // For the full copyright and license information, please view the LICENSE // file that was distributed with this source code. -// spell-checker:ignore (ToDO) retval paren prec subprec cond +// spell-checker:ignore (vars) FiletestOp StrlenOp mod parser; @@ -122,7 +122,7 @@ fn eval(stack: &mut Vec) -> Result { } } -fn integers(a: &OsStr, b: &OsStr, cond: &OsStr) -> Result { +fn integers(a: &OsStr, b: &OsStr, op: &OsStr) -> Result { let format_err = |value| format!("invalid integer ‘{}’", value); let a = a.to_string_lossy(); @@ -131,15 +131,15 @@ fn integers(a: &OsStr, b: &OsStr, cond: &OsStr) -> Result { let b = b.to_string_lossy(); let b: i64 = b.parse().map_err(|_| format_err(b))?; - let cond = cond.to_string_lossy(); - Ok(match cond.as_ref() { + let operator = op.to_string_lossy(); + Ok(match operator.as_ref() { "-eq" => a == b, "-ne" => a != b, "-gt" => a > b, "-ge" => a >= b, "-lt" => a < b, "-le" => a <= b, - _ => return Err(format!("unknown operator ‘{}’", cond)), + _ => return Err(format!("unknown operator ‘{}’", operator)), }) } @@ -177,7 +177,7 @@ enum PathCondition { } #[cfg(not(windows))] -fn path(path: &OsStr, cond: PathCondition) -> bool { +fn path(path: &OsStr, condition: PathCondition) -> bool { use std::fs::{self, Metadata}; use std::os::unix::fs::{FileTypeExt, MetadataExt}; @@ -208,7 +208,7 @@ fn path(path: &OsStr, cond: PathCondition) -> bool { } }; - let metadata = if cond == PathCondition::SymLink { + let metadata = if condition == PathCondition::SymLink { fs::symlink_metadata(path) } else { fs::metadata(path) @@ -223,7 +223,7 @@ fn path(path: &OsStr, cond: PathCondition) -> bool { let file_type = metadata.file_type(); - match cond { + match condition { PathCondition::BlockSpecial => file_type.is_block_device(), PathCondition::CharacterSpecial => file_type.is_char_device(), PathCondition::Directory => file_type.is_dir(), @@ -242,7 +242,7 @@ fn path(path: &OsStr, cond: PathCondition) -> bool { } #[cfg(windows)] -fn path(path: &OsStr, cond: PathCondition) -> bool { +fn path(path: &OsStr, condition: PathCondition) -> bool { use std::fs::metadata; let stat = match metadata(path) { @@ -250,7 +250,7 @@ fn path(path: &OsStr, cond: PathCondition) -> bool { _ => return false, }; - match cond { + match condition { PathCondition::BlockSpecial => false, PathCondition::CharacterSpecial => false, PathCondition::Directory => stat.is_dir(),