refactor: use &Path instead of (&)PathBuf in tests

This commit is contained in:
ljedrz 2020-10-16 17:21:18 +02:00
parent 64774cdab6
commit 4591a0eb04
3 changed files with 13 additions and 13 deletions

View File

@ -78,7 +78,7 @@ pub(crate) fn parse_input(bytes: &[u8]) -> Result<EdwardsTestCompiler, CompilerE
let input_string = String::from_utf8_lossy(bytes);
let path = PathBuf::new();
compiler.parse_input(&input_string, path.clone(), EMPTY_FILE, path)?;
compiler.parse_input(&input_string, &path, EMPTY_FILE, &path)?;
Ok(compiler)
}
@ -88,7 +88,7 @@ pub(crate) fn parse_state(bytes: &[u8]) -> Result<EdwardsTestCompiler, CompilerE
let state_string = String::from_utf8_lossy(bytes);
let path = PathBuf::new();
compiler.parse_input(EMPTY_FILE, path.clone(), &state_string, path)?;
compiler.parse_input(EMPTY_FILE, &path, &state_string, &path)?;
Ok(compiler)
}
@ -102,7 +102,7 @@ pub(crate) fn parse_input_and_state(
let state_string = String::from_utf8_lossy(state_bytes);
let path = PathBuf::new();
compiler.parse_input(&input_string, path.clone(), &state_string, path)?;
compiler.parse_input(&input_string, &path, &state_string, &path)?;
Ok(compiler)
}
@ -117,7 +117,7 @@ pub fn parse_program_with_input(
let input_string = String::from_utf8_lossy(input_bytes);
let path = PathBuf::new();
compiler.parse_input(&input_string, path.clone(), EMPTY_FILE, path)?;
compiler.parse_input(&input_string, &path, EMPTY_FILE, &path)?;
compiler.parse_program_from_string(&program_string)?;
Ok(compiler)
@ -133,7 +133,7 @@ pub fn parse_program_with_state(
let state_string = String::from_utf8_lossy(state_bytes);
let path = PathBuf::new();
compiler.parse_input(EMPTY_FILE, path.clone(), &state_string, path)?;
compiler.parse_input(EMPTY_FILE, &path, &state_string, &path)?;
compiler.parse_program_from_string(&program_string)?;
Ok(compiler)
@ -151,7 +151,7 @@ pub fn parse_program_with_input_and_state(
let state_string = String::from_utf8_lossy(state_bytes);
let path = PathBuf::new();
compiler.parse_input(&input_string, path.clone(), &state_string, path)?;
compiler.parse_input(&input_string, &path, &state_string, &path)?;
compiler.parse_program_from_string(&program_string)?;
Ok(compiler)

View File

@ -23,7 +23,7 @@ use std::{
convert::TryFrom,
fs::File,
io::{Read, Write},
path::Path,
path::{Path, PathBuf},
};
const OLD_MANIFEST_FORMAT: &str = r#"[package]
@ -57,7 +57,7 @@ fn create_outdated_manifest_file(path: PathBuf) -> PathBuf {
/// Read the manifest file into a string.
fn read_manifest_file(path: &Path) -> String {
let mut file = File::open(path.clone()).unwrap();
let mut file = File::open(path).unwrap();
let size = file.metadata().unwrap().len() as usize;
let mut buffer = String::with_capacity(size);
@ -96,7 +96,7 @@ fn test_manifest_no_refactors() {
let manifest_path = create_outdated_manifest_file(test_directory);
// Load the manifest file, and discard the new struct.
let _manifest = Manifest::try_from(&manifest_path).unwrap();
let _manifest = Manifest::try_from(manifest_path.as_path()).unwrap();
// Check that the manifest file project has NOT been updated.
assert!(!project_is_updated(&manifest_path));
@ -116,7 +116,7 @@ fn test_manifest_refactor_remote() {
let manifest_path = create_outdated_manifest_file(test_directory);
// Load the manifest file, and discard the new struct.
let _manifest = Manifest::try_from(&manifest_path).unwrap();
let _manifest = Manifest::try_from(manifest_path.as_path()).unwrap();
// Check that the manifest file project has NOT been updated.
assert!(!project_is_updated(&manifest_path));
@ -136,7 +136,7 @@ fn test_manifest_refactor_project() {
let manifest_path = create_outdated_manifest_file(test_directory);
// Load the manifest file, and discard the new struct.
let _manifest = Manifest::try_from(&manifest_path).unwrap();
let _manifest = Manifest::try_from(manifest_path.as_path()).unwrap();
// Check that the manifest file project has been updated.
assert!(project_is_updated(&manifest_path));
@ -159,7 +159,7 @@ fn test_manifest_refactors() {
let manifest_path = create_outdated_manifest_file(test_directory);
// Load the manifest file, and discard the new struct.
let _manifest = Manifest::try_from(&manifest_path).unwrap();
let _manifest = Manifest::try_from(manifest_path.as_path()).unwrap();
// Check that the manifest file project has been updated.
assert!(project_is_updated(&manifest_path));

View File

@ -17,7 +17,7 @@
use leo_ast::LeoAst;
use leo_typed::LeoTypedAst;
use std::path::Path;
use std::path::{Path, PathBuf};
fn to_typed_ast(program_filepath: &Path) -> LeoTypedAst {
// Loads the Leo code as a string from the given file path.