mirror of
https://github.com/nushell/nushell.git
synced 2025-08-09 14:25:55 +02:00
BytesAt command tests
This commit is contained in:
committed by
Simon Curtis
parent
cd6ff56d04
commit
b99d8c1016
@ -139,6 +139,7 @@ pub fn eval_block(
|
||||
}
|
||||
|
||||
pub fn check_example_evaluates_to_expected_output(
|
||||
cmd_name: &str,
|
||||
example: &Example,
|
||||
cwd: &std::path::Path,
|
||||
engine_state: &mut Box<EngineState>,
|
||||
@ -159,11 +160,19 @@ pub fn check_example_evaluates_to_expected_output(
|
||||
// If the command you are testing requires to compare another case, then
|
||||
// you need to define its equality in the Value struct
|
||||
if let Some(expected) = example.result.as_ref() {
|
||||
assert_eq!(
|
||||
DebuggableValue(&result),
|
||||
DebuggableValue(expected),
|
||||
"The example result differs from the expected value",
|
||||
)
|
||||
let expected = DebuggableValue(expected);
|
||||
let result = DebuggableValue(&result);
|
||||
if result != expected {
|
||||
panic!(
|
||||
"\x1b[31mError:\x1b[0m The result of example \x1b[34m'{}'\x1b[0m for the command \x1b[34m'{}'\x1b[0m differs from the expected value.\n\n\
|
||||
Expected: {:?}\n\
|
||||
Actual: {:?}\n",
|
||||
example.description,
|
||||
cmd_name,
|
||||
expected,
|
||||
result
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -44,7 +44,12 @@ mod test_examples {
|
||||
signature.operates_on_cell_paths(),
|
||||
),
|
||||
);
|
||||
check_example_evaluates_to_expected_output(&example, cwd.as_path(), &mut engine_state);
|
||||
check_example_evaluates_to_expected_output(
|
||||
cmd.name(),
|
||||
&example,
|
||||
cwd.as_path(),
|
||||
&mut engine_state,
|
||||
);
|
||||
}
|
||||
|
||||
check_all_signature_input_output_types_entries_have_examples(
|
||||
|
Reference in New Issue
Block a user