compare_properties clock.
This commit is contained in:
parent
ec755bae8b
commit
384242af87
@ -2173,51 +2173,46 @@ fn compare_src_block<'b, 's>(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn compare_clock<'b, 's>(
|
fn compare_clock<'b, 's>(
|
||||||
_source: &'s str,
|
source: &'s str,
|
||||||
emacs: &'b Token<'s>,
|
emacs: &'b Token<'s>,
|
||||||
rust: &'b Clock<'s>,
|
rust: &'b Clock<'s>,
|
||||||
) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> {
|
) -> Result<DiffEntry<'b, 's>, Box<dyn std::error::Error>> {
|
||||||
let mut child_status = Vec::new();
|
|
||||||
let mut this_status = DiffStatus::Good;
|
let mut this_status = DiffStatus::Good;
|
||||||
|
let mut child_status = Vec::new();
|
||||||
let mut message = None;
|
let mut message = None;
|
||||||
|
|
||||||
// Compare value
|
assert_no_children(emacs, &mut this_status, &mut message)?;
|
||||||
let value = get_property(emacs, ":value")?;
|
|
||||||
match value {
|
|
||||||
Some(e) => {
|
|
||||||
let result = compare_ast_node(_source, e, (&rust.timestamp).into())?;
|
|
||||||
child_status.push(artificial_diff_scope("value", vec![result])?);
|
|
||||||
}
|
|
||||||
None => {
|
|
||||||
this_status = DiffStatus::Bad;
|
|
||||||
message = Some(format!(
|
|
||||||
"Value mismatch (emacs != rust) {:?} != {:?}",
|
|
||||||
value, rust.timestamp
|
|
||||||
));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Compare duration
|
for diff in compare_properties!(
|
||||||
let duration = get_property_quoted_string(emacs, ":duration")?;
|
source,
|
||||||
if duration.as_ref().map(String::as_str) != rust.duration {
|
emacs,
|
||||||
this_status = DiffStatus::Bad;
|
rust,
|
||||||
message = Some(format!(
|
(
|
||||||
"Duration mismatch (emacs != rust) {:?} != {:?}",
|
EmacsField::Required(":value"),
|
||||||
duration, rust.duration
|
|r| Some(&r.timestamp),
|
||||||
));
|
compare_property_single_ast_node
|
||||||
|
),
|
||||||
|
(
|
||||||
|
EmacsField::Required(":duration"),
|
||||||
|
|r| r.duration,
|
||||||
|
compare_property_quoted_string
|
||||||
|
),
|
||||||
|
(
|
||||||
|
EmacsField::Required(":status"),
|
||||||
|
|r| Some(match r.status {
|
||||||
|
ClockStatus::Running => "running",
|
||||||
|
ClockStatus::Closed => "closed",
|
||||||
|
}),
|
||||||
|
compare_property_unquoted_atom
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
match diff {
|
||||||
|
ComparePropertiesResult::NoChange => {}
|
||||||
|
ComparePropertiesResult::SelfChange(new_status, new_message) => {
|
||||||
|
this_status = new_status;
|
||||||
|
message = new_message
|
||||||
}
|
}
|
||||||
|
ComparePropertiesResult::DiffEntry(diff_entry) => child_status.push(diff_entry),
|
||||||
// Compare status
|
|
||||||
let status = get_property_unquoted_atom(emacs, ":status")?;
|
|
||||||
match (status, &rust.status) {
|
|
||||||
(Some("running"), ClockStatus::Running) => {}
|
|
||||||
(Some("closed"), ClockStatus::Closed) => {}
|
|
||||||
_ => {
|
|
||||||
this_status = DiffStatus::Bad;
|
|
||||||
message = Some(format!(
|
|
||||||
"Status mismatch (emacs != rust) {:?} != {:?}",
|
|
||||||
status, rust.status
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user