From dd1f7c7777f290315474fde873c2dcef1197fc81 Mon Sep 17 00:00:00 2001 From: Tom Alexander Date: Fri, 29 Dec 2023 23:21:30 -0500 Subject: [PATCH] Support a no-op for headline pre-blank. --- src/wasm/headline.rs | 8 ++++++-- src/wasm/plain_list_item.rs | 5 +++-- src/wasm_test/compare.rs | 17 ++++++++++++++++- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/src/wasm/headline.rs b/src/wasm/headline.rs index 2c999aa..237019c 100644 --- a/src/wasm/headline.rs +++ b/src/wasm/headline.rs @@ -37,9 +37,13 @@ pub struct WasmHeadline { pub(crate) deadline: Option>, pub(crate) closed: Option>, #[serde(rename = "pre-blank")] - pub(crate) pre_blank: usize, + pub(crate) pre_blank: Noop, } +#[derive(Debug, Serialize, Deserialize)] +#[serde(tag = "noop")] +pub struct Noop {} + to_wasm!( WasmHeadline, Heading<'s>, @@ -129,7 +133,7 @@ to_wasm!( }) .map_or(Ok(None), |r| r.map(Some))? .map(|child| Box::new(child)), - pre_blank: 0, // TODO: Should this be a no-op? + pre_blank: Noop {}, }, )) } diff --git a/src/wasm/plain_list_item.rs b/src/wasm/plain_list_item.rs index 70c2300..d5f1b29 100644 --- a/src/wasm/plain_list_item.rs +++ b/src/wasm/plain_list_item.rs @@ -8,6 +8,7 @@ use crate::compare::ElispFact; use crate::types::CheckboxType; use crate::types::PlainListItem; use crate::types::PlainListItemCounter; +use crate::types::PlainListItemPreBlank; use crate::wasm::to_wasm::ToWasmStandardProperties; #[derive(Debug, Serialize, Deserialize)] @@ -17,7 +18,7 @@ pub struct WasmPlainListItem { pub(crate) counter: Option, pub(crate) checkbox: Option, #[serde(rename = "pre-blank")] - pub(crate) pre_blank: usize, + pub(crate) pre_blank: PlainListItemPreBlank, } to_wasm!( @@ -52,7 +53,7 @@ to_wasm!( } .to_owned() }), - pre_blank: 0, // TODO: Should this be a no-op? + pre_blank: original.pre_blank, }, )) } diff --git a/src/wasm_test/compare.rs b/src/wasm_test/compare.rs index 873033d..bb50122 100644 --- a/src/wasm_test/compare.rs +++ b/src/wasm_test/compare.rs @@ -77,12 +77,27 @@ fn compare_json_value<'b, 's>( (serde_json::Value::Number(w), Token::Atom(e)) if w.to_string().as_str() == (*e) => { Ok(WasmDiffResult::default()) } + (serde_json::Value::Number(w), Token::Atom(e)) => { + let mut result = WasmDiffResult::default(); + result.status.push(WasmDiffStatus::Bad( + format!( + "Value mismatch. Emacs=({emacs:?}) Wasm=({wasm:?}).", + emacs = e, + wasm = w, + ) + .into(), + )); + Ok(result) + } (serde_json::Value::Array(w), Token::Atom("nil")) if w.is_empty() => { Ok(WasmDiffResult::default()) } (serde_json::Value::String(w), Token::Atom(e)) if w.as_str() == *e => { Ok(WasmDiffResult::default()) } + (serde_json::Value::Object(w), Token::Atom(_)) if w.contains_key("noop") => { + Ok(WasmDiffResult::default()) + } (serde_json::Value::Null, Token::Atom(_)) => todo!(), (serde_json::Value::Null, Token::List(_)) => todo!(), (serde_json::Value::Null, Token::TextWithProperties(_)) => todo!(), @@ -91,7 +106,7 @@ fn compare_json_value<'b, 's>( (serde_json::Value::Bool(_), Token::List(_)) => todo!(), (serde_json::Value::Bool(_), Token::TextWithProperties(_)) => todo!(), (serde_json::Value::Bool(_), Token::Vector(_)) => todo!(), - (serde_json::Value::Number(_), Token::Atom(_)) => todo!(), + // (serde_json::Value::Number(_), Token::Atom(_)) => todo!(), (serde_json::Value::Number(_), Token::List(_)) => todo!(), (serde_json::Value::Number(_), Token::TextWithProperties(_)) => todo!(), (serde_json::Value::Number(_), Token::Vector(_)) => todo!(),