mirror of
https://github.com/loot/loot-condition-interpreter.git
synced 2026-07-27 14:16:09 -07:00
Apply clippy --fix changes
This commit is contained in:
+13
-17
@@ -368,10 +368,7 @@ mod tests {
|
|||||||
game_type: GameType::Oblivion,
|
game_type: GameType::Oblivion,
|
||||||
data_path,
|
data_path,
|
||||||
additional_data_paths,
|
additional_data_paths,
|
||||||
active_plugins: active_plugins
|
active_plugins: active_plugins.iter().map(|s| s.to_lowercase()).collect(),
|
||||||
.into_iter()
|
|
||||||
.map(|s| s.to_lowercase())
|
|
||||||
.collect(),
|
|
||||||
crc_cache: RwLock::default(),
|
crc_cache: RwLock::default(),
|
||||||
plugin_versions: plugin_versions
|
plugin_versions: plugin_versions
|
||||||
.iter()
|
.iter()
|
||||||
@@ -413,7 +410,7 @@ mod tests {
|
|||||||
|
|
||||||
copy(
|
copy(
|
||||||
Path::new("tests/testing-plugins/Oblivion/Data/Blank.esp"),
|
Path::new("tests/testing-plugins/Oblivion/Data/Blank.esp"),
|
||||||
&state.data_path.join("Blank.esp.ghost"),
|
state.data_path.join("Blank.esp.ghost"),
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
@@ -430,7 +427,7 @@ mod tests {
|
|||||||
|
|
||||||
copy(
|
copy(
|
||||||
Path::new("Cargo.toml"),
|
Path::new("Cargo.toml"),
|
||||||
&state.data_path.join("Cargo.toml.ghost"),
|
state.data_path.join("Cargo.toml.ghost"),
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
@@ -482,7 +479,7 @@ mod tests {
|
|||||||
|
|
||||||
copy(
|
copy(
|
||||||
Path::new("tests/testing-plugins/Oblivion/Data/Blank.esm"),
|
Path::new("tests/testing-plugins/Oblivion/Data/Blank.esm"),
|
||||||
&state.data_path.join("Blank.esm.ghost"),
|
state.data_path.join("Blank.esm.ghost"),
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
@@ -586,8 +583,7 @@ mod tests {
|
|||||||
.read_dir()
|
.read_dir()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.flat_map(|res| res.map(|e| e.file_name()).into_iter())
|
.flat_map(|res| res.map(|e| e.file_name()).into_iter())
|
||||||
.find(|name| name == relative_path)
|
.any(|name| &name == relative_path);
|
||||||
.is_some();
|
|
||||||
|
|
||||||
assert!(entry_exists);
|
assert!(entry_exists);
|
||||||
|
|
||||||
@@ -734,12 +730,12 @@ mod tests {
|
|||||||
|
|
||||||
copy(
|
copy(
|
||||||
Path::new("tests/testing-plugins/Oblivion/Data/Blank.esm"),
|
Path::new("tests/testing-plugins/Oblivion/Data/Blank.esm"),
|
||||||
&state.data_path.join("Blank.esm.ghost"),
|
state.data_path.join("Blank.esm.ghost"),
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
copy(
|
copy(
|
||||||
Path::new("tests/testing-plugins/Oblivion/Data/Blank.esp"),
|
Path::new("tests/testing-plugins/Oblivion/Data/Blank.esp"),
|
||||||
&state.data_path.join("Blank.esp.ghost"),
|
state.data_path.join("Blank.esp.ghost"),
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
@@ -824,7 +820,7 @@ mod tests {
|
|||||||
|
|
||||||
copy(
|
copy(
|
||||||
Path::new("tests/testing-plugins/Oblivion/Data/Blank.esm"),
|
Path::new("tests/testing-plugins/Oblivion/Data/Blank.esm"),
|
||||||
&state.data_path.join("Blank.esm.ghost"),
|
state.data_path.join("Blank.esm.ghost"),
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
@@ -841,7 +837,7 @@ mod tests {
|
|||||||
|
|
||||||
copy(
|
copy(
|
||||||
Path::new("tests/testing-plugins/Oblivion/Data/Blank.bsa"),
|
Path::new("tests/testing-plugins/Oblivion/Data/Blank.bsa"),
|
||||||
&state.data_path.join("Blank.bsa.ghost"),
|
state.data_path.join("Blank.bsa.ghost"),
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
@@ -867,7 +863,7 @@ mod tests {
|
|||||||
|
|
||||||
copy(
|
copy(
|
||||||
Path::new("tests/testing-plugins/Oblivion/Data/Blank.esm"),
|
Path::new("tests/testing-plugins/Oblivion/Data/Blank.esm"),
|
||||||
&state.data_path.join("Blank.esm"),
|
state.data_path.join("Blank.esm"),
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
@@ -878,7 +874,7 @@ mod tests {
|
|||||||
// Change the CRC of the file to test that the cached value is used.
|
// Change the CRC of the file to test that the cached value is used.
|
||||||
copy(
|
copy(
|
||||||
Path::new("tests/testing-plugins/Oblivion/Data/Blank.bsa"),
|
Path::new("tests/testing-plugins/Oblivion/Data/Blank.bsa"),
|
||||||
&state.data_path.join("Blank.esm"),
|
state.data_path.join("Blank.esm"),
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
@@ -893,13 +889,13 @@ mod tests {
|
|||||||
let data_path = tmp_dir.path().join("Data");
|
let data_path = tmp_dir.path().join("Data");
|
||||||
let state = state(data_path);
|
let state = state(data_path);
|
||||||
|
|
||||||
copy(Path::new("Cargo.toml"), &state.data_path.join("Cargo.toml")).unwrap();
|
copy(Path::new("Cargo.toml"), state.data_path.join("Cargo.toml")).unwrap();
|
||||||
|
|
||||||
let function = Function::FilePath(PathBuf::from("Cargo.toml"));
|
let function = Function::FilePath(PathBuf::from("Cargo.toml"));
|
||||||
|
|
||||||
assert!(function.eval(&state).unwrap());
|
assert!(function.eval(&state).unwrap());
|
||||||
|
|
||||||
remove_file(&state.data_path.join("Cargo.toml")).unwrap();
|
remove_file(state.data_path.join("Cargo.toml")).unwrap();
|
||||||
|
|
||||||
assert!(function.eval(&state).unwrap());
|
assert!(function.eval(&state).unwrap());
|
||||||
}
|
}
|
||||||
|
|||||||
+32
-35
@@ -254,21 +254,21 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn parse_regex_should_produce_case_insensitive_regex() {
|
fn parse_regex_should_produce_case_insensitive_regex() {
|
||||||
let (_, regex) = parse_regex("cargo.*".into()).unwrap();
|
let (_, regex) = parse_regex("cargo.*").unwrap();
|
||||||
|
|
||||||
assert!(regex.is_match("Cargo.toml"));
|
assert!(regex.is_match("Cargo.toml"));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn parse_regex_should_produce_a_regex_that_does_not_partially_match() {
|
fn parse_regex_should_produce_a_regex_that_does_not_partially_match() {
|
||||||
let (_, regex) = parse_regex("cargo.".into()).unwrap();
|
let (_, regex) = parse_regex("cargo.").unwrap();
|
||||||
|
|
||||||
assert!(!regex.is_match("Cargo.toml"));
|
assert!(!regex.is_match("Cargo.toml"));
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn function_parse_should_parse_a_file_path_function() {
|
fn function_parse_should_parse_a_file_path_function() {
|
||||||
let output = Function::parse("file(\"Cargo.toml\")".into()).unwrap();
|
let output = Function::parse("file(\"Cargo.toml\")").unwrap();
|
||||||
|
|
||||||
assert!(output.0.is_empty());
|
assert!(output.0.is_empty());
|
||||||
match output.1 {
|
match output.1 {
|
||||||
@@ -279,12 +279,12 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn function_parse_should_error_if_the_file_path_is_outside_the_game_directory() {
|
fn function_parse_should_error_if_the_file_path_is_outside_the_game_directory() {
|
||||||
assert!(Function::parse("file(\"../../Cargo.toml\")".into()).is_err());
|
assert!(Function::parse("file(\"../../Cargo.toml\")").is_err());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn function_parse_should_parse_a_file_regex_function_with_no_parent_path() {
|
fn function_parse_should_parse_a_file_regex_function_with_no_parent_path() {
|
||||||
let output = Function::parse("file(\"Cargo.*\")".into()).unwrap();
|
let output = Function::parse("file(\"Cargo.*\")").unwrap();
|
||||||
|
|
||||||
assert!(output.0.is_empty());
|
assert!(output.0.is_empty());
|
||||||
match output.1 {
|
match output.1 {
|
||||||
@@ -298,7 +298,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn function_parse_should_parse_a_file_regex_function_with_a_parent_path() {
|
fn function_parse_should_parse_a_file_regex_function_with_a_parent_path() {
|
||||||
let output = Function::parse("file(\"subdir/Cargo.*\")".into()).unwrap();
|
let output = Function::parse("file(\"subdir/Cargo.*\")").unwrap();
|
||||||
|
|
||||||
assert!(output.0.is_empty());
|
assert!(output.0.is_empty());
|
||||||
match output.1 {
|
match output.1 {
|
||||||
@@ -312,17 +312,17 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn function_parse_should_error_if_given_a_file_regex_function_ending_in_a_forward_slash() {
|
fn function_parse_should_error_if_given_a_file_regex_function_ending_in_a_forward_slash() {
|
||||||
assert!(Function::parse("file(\"sub\\dir/\")".into()).is_err());
|
assert!(Function::parse("file(\"sub\\dir/\")").is_err());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn function_parse_should_error_if_the_file_regex_parent_path_is_outside_the_game_directory() {
|
fn function_parse_should_error_if_the_file_regex_parent_path_is_outside_the_game_directory() {
|
||||||
assert!(Function::parse("file(\"../../Cargo.*\")".into()).is_err());
|
assert!(Function::parse("file(\"../../Cargo.*\")").is_err());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn function_parse_should_parse_a_readable_function() {
|
fn function_parse_should_parse_a_readable_function() {
|
||||||
let output = Function::parse("readable(\"Cargo.toml\")".into()).unwrap();
|
let output = Function::parse("readable(\"Cargo.toml\")").unwrap();
|
||||||
|
|
||||||
assert!(output.0.is_empty());
|
assert!(output.0.is_empty());
|
||||||
match output.1 {
|
match output.1 {
|
||||||
@@ -333,12 +333,12 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn function_parse_should_error_if_the_readable_path_is_outside_the_game_directory() {
|
fn function_parse_should_error_if_the_readable_path_is_outside_the_game_directory() {
|
||||||
assert!(Function::parse("readable(\"../../Cargo.toml\")".into()).is_err());
|
assert!(Function::parse("readable(\"../../Cargo.toml\")").is_err());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn function_parse_should_parse_an_active_path_function() {
|
fn function_parse_should_parse_an_active_path_function() {
|
||||||
let output = Function::parse("active(\"Cargo.toml\")".into()).unwrap();
|
let output = Function::parse("active(\"Cargo.toml\")").unwrap();
|
||||||
|
|
||||||
assert!(output.0.is_empty());
|
assert!(output.0.is_empty());
|
||||||
match output.1 {
|
match output.1 {
|
||||||
@@ -351,12 +351,12 @@ mod tests {
|
|||||||
fn function_parse_should_error_if_the_active_path_is_outside_the_game_directory() {
|
fn function_parse_should_error_if_the_active_path_is_outside_the_game_directory() {
|
||||||
// Trying to check if a path that isn't a plugin in the data folder is
|
// Trying to check if a path that isn't a plugin in the data folder is
|
||||||
// active is pointless, but it's not worth having a more specific check.
|
// active is pointless, but it's not worth having a more specific check.
|
||||||
assert!(Function::parse("active(\"../../Cargo.toml\")".into()).is_err());
|
assert!(Function::parse("active(\"../../Cargo.toml\")").is_err());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn function_parse_should_parse_an_active_regex_function() {
|
fn function_parse_should_parse_an_active_regex_function() {
|
||||||
let output = Function::parse("active(\"Cargo.*\")".into()).unwrap();
|
let output = Function::parse("active(\"Cargo.*\")").unwrap();
|
||||||
|
|
||||||
assert!(output.0.is_empty());
|
assert!(output.0.is_empty());
|
||||||
match output.1 {
|
match output.1 {
|
||||||
@@ -369,7 +369,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn function_parse_should_parse_an_is_master_function() {
|
fn function_parse_should_parse_an_is_master_function() {
|
||||||
let output = Function::parse("is_master(\"Blank.esm\")".into()).unwrap();
|
let output = Function::parse("is_master(\"Blank.esm\")").unwrap();
|
||||||
|
|
||||||
assert!(output.0.is_empty());
|
assert!(output.0.is_empty());
|
||||||
match output.1 {
|
match output.1 {
|
||||||
@@ -382,12 +382,12 @@ mod tests {
|
|||||||
fn function_parse_should_error_if_the_is_master_path_is_outside_the_game_directory() {
|
fn function_parse_should_error_if_the_is_master_path_is_outside_the_game_directory() {
|
||||||
// Trying to check if a path that isn't a plugin in the data folder is
|
// Trying to check if a path that isn't a plugin in the data folder is
|
||||||
// active is pointless, but it's not worth having a more specific check.
|
// active is pointless, but it's not worth having a more specific check.
|
||||||
assert!(Function::parse("is_master(\"../../Blank.esm\")".into()).is_err());
|
assert!(Function::parse("is_master(\"../../Blank.esm\")").is_err());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn function_parse_should_parse_a_many_function_with_no_parent_path() {
|
fn function_parse_should_parse_a_many_function_with_no_parent_path() {
|
||||||
let output = Function::parse("many(\"Cargo.*\")".into()).unwrap();
|
let output = Function::parse("many(\"Cargo.*\")").unwrap();
|
||||||
|
|
||||||
assert!(output.0.is_empty());
|
assert!(output.0.is_empty());
|
||||||
match output.1 {
|
match output.1 {
|
||||||
@@ -401,7 +401,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn function_parse_should_parse_a_many_function_with_a_parent_path() {
|
fn function_parse_should_parse_a_many_function_with_a_parent_path() {
|
||||||
let output = Function::parse("many(\"subdir/Cargo.*\")".into()).unwrap();
|
let output = Function::parse("many(\"subdir/Cargo.*\")").unwrap();
|
||||||
|
|
||||||
assert!(output.0.is_empty());
|
assert!(output.0.is_empty());
|
||||||
match output.1 {
|
match output.1 {
|
||||||
@@ -415,17 +415,17 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn function_parse_should_error_if_given_a_many_function_ending_in_a_forward_slash() {
|
fn function_parse_should_error_if_given_a_many_function_ending_in_a_forward_slash() {
|
||||||
assert!(Function::parse("many(\"subdir/\")".into()).is_err());
|
assert!(Function::parse("many(\"subdir/\")").is_err());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn function_parse_should_error_if_the_many_parent_path_is_outside_the_game_directory() {
|
fn function_parse_should_error_if_the_many_parent_path_is_outside_the_game_directory() {
|
||||||
assert!(Function::parse("file(\"../../Cargo.*\")".into()).is_err());
|
assert!(Function::parse("file(\"../../Cargo.*\")").is_err());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn function_parse_should_parse_a_many_active_function() {
|
fn function_parse_should_parse_a_many_active_function() {
|
||||||
let output = Function::parse("many_active(\"Cargo.*\")".into()).unwrap();
|
let output = Function::parse("many_active(\"Cargo.*\")").unwrap();
|
||||||
|
|
||||||
assert!(output.0.is_empty());
|
assert!(output.0.is_empty());
|
||||||
match output.1 {
|
match output.1 {
|
||||||
@@ -438,7 +438,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn function_parse_should_parse_a_checksum_function() {
|
fn function_parse_should_parse_a_checksum_function() {
|
||||||
let output = Function::parse("checksum(\"Cargo.toml\", DEADBEEF)".into()).unwrap();
|
let output = Function::parse("checksum(\"Cargo.toml\", DEADBEEF)").unwrap();
|
||||||
|
|
||||||
assert!(output.0.is_empty());
|
assert!(output.0.is_empty());
|
||||||
match output.1 {
|
match output.1 {
|
||||||
@@ -452,12 +452,12 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn function_parse_should_error_if_the_checksum_path_is_outside_the_game_directory() {
|
fn function_parse_should_error_if_the_checksum_path_is_outside_the_game_directory() {
|
||||||
assert!(Function::parse("checksum(\"../../Cargo.toml\", DEADBEEF)".into()).is_err());
|
assert!(Function::parse("checksum(\"../../Cargo.toml\", DEADBEEF)").is_err());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn function_parse_should_parse_a_version_equals_function() {
|
fn function_parse_should_parse_a_version_equals_function() {
|
||||||
let output = Function::parse("version(\"Cargo.toml\", \"1.2\", ==)".into()).unwrap();
|
let output = Function::parse("version(\"Cargo.toml\", \"1.2\", ==)").unwrap();
|
||||||
|
|
||||||
assert!(output.0.is_empty());
|
assert!(output.0.is_empty());
|
||||||
match output.1 {
|
match output.1 {
|
||||||
@@ -472,7 +472,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn function_parse_should_parse_a_version_not_equals_function() {
|
fn function_parse_should_parse_a_version_not_equals_function() {
|
||||||
let output = Function::parse("version(\"Cargo.toml\", \"1.2\", !=)".into()).unwrap();
|
let output = Function::parse("version(\"Cargo.toml\", \"1.2\", !=)").unwrap();
|
||||||
|
|
||||||
assert!(output.0.is_empty());
|
assert!(output.0.is_empty());
|
||||||
match output.1 {
|
match output.1 {
|
||||||
@@ -487,7 +487,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn function_parse_should_parse_a_version_less_than_function() {
|
fn function_parse_should_parse_a_version_less_than_function() {
|
||||||
let output = Function::parse("version(\"Cargo.toml\", \"1.2\", <)".into()).unwrap();
|
let output = Function::parse("version(\"Cargo.toml\", \"1.2\", <)").unwrap();
|
||||||
|
|
||||||
assert!(output.0.is_empty());
|
assert!(output.0.is_empty());
|
||||||
match output.1 {
|
match output.1 {
|
||||||
@@ -502,7 +502,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn function_parse_should_parse_a_version_greater_than_function() {
|
fn function_parse_should_parse_a_version_greater_than_function() {
|
||||||
let output = Function::parse("version(\"Cargo.toml\", \"1.2\", >)".into()).unwrap();
|
let output = Function::parse("version(\"Cargo.toml\", \"1.2\", >)").unwrap();
|
||||||
|
|
||||||
assert!(output.0.is_empty());
|
assert!(output.0.is_empty());
|
||||||
match output.1 {
|
match output.1 {
|
||||||
@@ -517,7 +517,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn function_parse_should_parse_a_version_less_than_or_equal_to_function() {
|
fn function_parse_should_parse_a_version_less_than_or_equal_to_function() {
|
||||||
let output = Function::parse("version(\"Cargo.toml\", \"1.2\", <=)".into()).unwrap();
|
let output = Function::parse("version(\"Cargo.toml\", \"1.2\", <=)").unwrap();
|
||||||
|
|
||||||
assert!(output.0.is_empty());
|
assert!(output.0.is_empty());
|
||||||
match output.1 {
|
match output.1 {
|
||||||
@@ -532,7 +532,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn function_parse_should_parse_a_version_greater_than_or_equal_to_function() {
|
fn function_parse_should_parse_a_version_greater_than_or_equal_to_function() {
|
||||||
let output = Function::parse("version(\"Cargo.toml\", \"1.2\", >=)".into()).unwrap();
|
let output = Function::parse("version(\"Cargo.toml\", \"1.2\", >=)").unwrap();
|
||||||
|
|
||||||
assert!(output.0.is_empty());
|
assert!(output.0.is_empty());
|
||||||
match output.1 {
|
match output.1 {
|
||||||
@@ -547,7 +547,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn function_parse_should_parse_a_version_with_a_path_containing_backslashes() {
|
fn function_parse_should_parse_a_version_with_a_path_containing_backslashes() {
|
||||||
let output = Function::parse("version(\"..\\Cargo.toml\", \"1.2\", ==)".into()).unwrap();
|
let output = Function::parse("version(\"..\\Cargo.toml\", \"1.2\", ==)").unwrap();
|
||||||
|
|
||||||
assert!(output.0.is_empty());
|
assert!(output.0.is_empty());
|
||||||
match output.1 {
|
match output.1 {
|
||||||
@@ -562,13 +562,12 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn function_parse_should_error_if_the_version_path_is_outside_the_game_directory() {
|
fn function_parse_should_error_if_the_version_path_is_outside_the_game_directory() {
|
||||||
assert!(Function::parse("version(\"../../Cargo.toml\", \"1.2\", ==)".into()).is_err());
|
assert!(Function::parse("version(\"../../Cargo.toml\", \"1.2\", ==)").is_err());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn function_parse_should_parse_a_product_version_equals_function() {
|
fn function_parse_should_parse_a_product_version_equals_function() {
|
||||||
let output =
|
let output = Function::parse("product_version(\"Cargo.toml\", \"1.2\", ==)").unwrap();
|
||||||
Function::parse("product_version(\"Cargo.toml\", \"1.2\", ==)".into()).unwrap();
|
|
||||||
|
|
||||||
assert!(output.0.is_empty());
|
assert!(output.0.is_empty());
|
||||||
match output.1 {
|
match output.1 {
|
||||||
@@ -583,8 +582,6 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn function_parse_should_error_if_the_product_version_path_is_outside_the_game_directory() {
|
fn function_parse_should_error_if_the_product_version_path_is_outside_the_game_directory() {
|
||||||
assert!(
|
assert!(Function::parse("product_version(\"../../Cargo.toml\", \"1.2\", ==)").is_err());
|
||||||
Function::parse("product_version(\"../../Cargo.toml\", \"1.2\", ==)".into()).is_err()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-21
@@ -408,9 +408,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn compound_condition_parse_should_handle_a_single_condition() {
|
fn compound_condition_parse_should_handle_a_single_condition() {
|
||||||
let result = CompoundCondition::parse("file(\"Cargo.toml\")".into())
|
let result = CompoundCondition::parse("file(\"Cargo.toml\")").unwrap().1;
|
||||||
.unwrap()
|
|
||||||
.1;
|
|
||||||
|
|
||||||
match result.0.as_slice() {
|
match result.0.as_slice() {
|
||||||
[Condition::Function(Function::FilePath(f))] => {
|
[Condition::Function(Function::FilePath(f))] => {
|
||||||
@@ -425,10 +423,9 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn compound_condition_parse_should_handle_multiple_conditions() {
|
fn compound_condition_parse_should_handle_multiple_conditions() {
|
||||||
let result =
|
let result = CompoundCondition::parse("file(\"Cargo.toml\") and file(\"README.md\")")
|
||||||
CompoundCondition::parse("file(\"Cargo.toml\") and file(\"README.md\")".into())
|
.unwrap()
|
||||||
.unwrap()
|
.1;
|
||||||
.1;
|
|
||||||
|
|
||||||
match result.0.as_slice() {
|
match result.0.as_slice() {
|
||||||
[Condition::Function(Function::FilePath(f1)), Condition::Function(Function::FilePath(f2))] =>
|
[Condition::Function(Function::FilePath(f1)), Condition::Function(Function::FilePath(f2))] =>
|
||||||
@@ -445,7 +442,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn condition_parse_should_handle_a_function() {
|
fn condition_parse_should_handle_a_function() {
|
||||||
let result = Condition::parse("file(\"Cargo.toml\")".into()).unwrap().1;
|
let result = Condition::parse("file(\"Cargo.toml\")").unwrap().1;
|
||||||
|
|
||||||
match result {
|
match result {
|
||||||
Condition::Function(Function::FilePath(f)) => {
|
Condition::Function(Function::FilePath(f)) => {
|
||||||
@@ -460,9 +457,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn condition_parse_should_handle_an_inverted_function() {
|
fn condition_parse_should_handle_an_inverted_function() {
|
||||||
let result = Condition::parse("not file(\"Cargo.toml\")".into())
|
let result = Condition::parse("not file(\"Cargo.toml\")").unwrap().1;
|
||||||
.unwrap()
|
|
||||||
.1;
|
|
||||||
|
|
||||||
match result {
|
match result {
|
||||||
Condition::InvertedFunction(Function::FilePath(f)) => {
|
Condition::InvertedFunction(Function::FilePath(f)) => {
|
||||||
@@ -477,9 +472,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn condition_parse_should_handle_an_expression_in_parentheses() {
|
fn condition_parse_should_handle_an_expression_in_parentheses() {
|
||||||
let result = Condition::parse("(not file(\"Cargo.toml\"))".into())
|
let result = Condition::parse("(not file(\"Cargo.toml\"))").unwrap().1;
|
||||||
.unwrap()
|
|
||||||
.1;
|
|
||||||
|
|
||||||
match result {
|
match result {
|
||||||
Condition::Expression(_) => {}
|
Condition::Expression(_) => {}
|
||||||
@@ -492,9 +485,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn condition_parse_should_handle_an_expression_in_parentheses_with_whitespace() {
|
fn condition_parse_should_handle_an_expression_in_parentheses_with_whitespace() {
|
||||||
let result = Condition::parse("( not file(\"Cargo.toml\") )".into())
|
let result = Condition::parse("( not file(\"Cargo.toml\") )").unwrap().1;
|
||||||
.unwrap()
|
|
||||||
.1;
|
|
||||||
|
|
||||||
match result {
|
match result {
|
||||||
Condition::Expression(_) => {}
|
Condition::Expression(_) => {}
|
||||||
@@ -507,9 +498,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn condition_parse_should_handle_an_inverted_expression_in_parentheses() {
|
fn condition_parse_should_handle_an_inverted_expression_in_parentheses() {
|
||||||
let result = Condition::parse("not(not file(\"Cargo.toml\"))".into())
|
let result = Condition::parse("not(not file(\"Cargo.toml\"))").unwrap().1;
|
||||||
.unwrap()
|
|
||||||
.1;
|
|
||||||
|
|
||||||
match result {
|
match result {
|
||||||
Condition::InvertedExpression(_) => {}
|
Condition::InvertedExpression(_) => {}
|
||||||
@@ -522,7 +511,7 @@ mod tests {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn condition_parse_should_handle_an_inverted_expression_in_parentheses_with_whitespace() {
|
fn condition_parse_should_handle_an_inverted_expression_in_parentheses_with_whitespace() {
|
||||||
let result = Condition::parse("not ( not file(\"Cargo.toml\") )".into())
|
let result = Condition::parse("not ( not file(\"Cargo.toml\") )")
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.1;
|
.1;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user