Compare commits

..

No commits in common. "c1b471208d893fbaceca397a5923502e40d73ee3" and "a4a83d047d0f78eb90d1b13bc68652429f06a81e" have entirely different histories.

5 changed files with 27 additions and 76 deletions

View File

@ -4,13 +4,15 @@ use serde::Serialize;
use super::ast_node::WasmAstNode;
use super::macros::to_wasm;
use super::to_wasm::ToWasm;
use super::AdditionalProperties;
use crate::compare::ElispFact;
use crate::types::Comment;
use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Debug, Serialize, Deserialize)]
pub struct WasmComment {
pub(crate) value: String,
#[serde(flatten)]
pub(crate) additional_properties: AdditionalProperties,
}
to_wasm!(
@ -19,12 +21,12 @@ to_wasm!(
original,
wasm_context,
{ WasmAstNode::Comment(original) },
{ "comment".into() },
{ "TODO".into() },
{
Ok((
Vec::new(),
WasmComment {
value: original.get_value(),
additional_properties: AdditionalProperties::default(),
},
))
}

View File

@ -6,7 +6,6 @@ use super::macros::to_wasm;
use super::to_wasm::ToWasm;
use super::AdditionalProperties;
use crate::compare::ElispFact;
use crate::types::GetAffiliatedKeywords;
use crate::types::Keyword;
use crate::wasm::to_wasm::ToWasmStandardProperties;
@ -14,8 +13,6 @@ use crate::wasm::to_wasm::ToWasmStandardProperties;
pub struct WasmKeyword {
#[serde(flatten)]
pub(crate) additional_properties: AdditionalProperties,
pub(crate) key: String,
pub(crate) value: String,
}
to_wasm!(
@ -24,18 +21,12 @@ to_wasm!(
original,
wasm_context,
{ WasmAstNode::Keyword(original) },
{ "keyword".into() },
{ "TODO".into() },
{
let additional_properties = original
.get_affiliated_keywords()
.to_wasm(wasm_context.clone())?;
Ok((
Vec::new(),
WasmKeyword {
additional_properties,
key: original.key.to_uppercase(),
value: original.value.to_owned(),
additional_properties: AdditionalProperties::default(),
},
))
}

View File

@ -6,17 +6,13 @@ use super::macros::to_wasm;
use super::to_wasm::ToWasm;
use super::AdditionalProperties;
use crate::compare::ElispFact;
use crate::types::GetAffiliatedKeywords;
use crate::types::PlainList;
use crate::types::PlainListType;
use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Debug, Serialize, Deserialize)]
pub struct WasmPlainList {
#[serde(flatten)]
pub(crate) additional_properties: AdditionalProperties,
#[serde(rename = "type")]
pub(crate) list_type: String,
}
to_wasm!(
@ -25,12 +21,8 @@ to_wasm!(
original,
wasm_context,
{ WasmAstNode::PlainList(original) },
{ "plain-list".into() },
{ "TODO".into() },
{
let additional_properties = original
.get_affiliated_keywords()
.to_wasm(wasm_context.clone())?;
let children = original
.children
.iter()
@ -44,13 +36,7 @@ to_wasm!(
Ok((
children,
WasmPlainList {
additional_properties,
list_type: match original.list_type {
PlainListType::Unordered => "unordered",
PlainListType::Ordered => "ordered",
PlainListType::Descriptive => "descriptive",
}
.to_owned(),
additional_properties: AdditionalProperties::default(),
},
))
}

View File

@ -4,20 +4,15 @@ use serde::Serialize;
use super::ast_node::WasmAstNode;
use super::macros::to_wasm;
use super::to_wasm::ToWasm;
use super::AdditionalProperties;
use crate::compare::ElispFact;
use crate::types::CheckboxType;
use crate::types::PlainListItem;
use crate::types::PlainListItemCounter;
use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Debug, Serialize, Deserialize)]
pub struct WasmPlainListItem {
pub(crate) tag: Vec<WasmAstNode>,
pub(crate) bullet: String,
pub(crate) counter: Option<PlainListItemCounter>,
pub(crate) checkbox: Option<String>,
#[serde(rename = "pre-blank")]
pub(crate) pre_blank: usize,
#[serde(flatten)]
pub(crate) additional_properties: AdditionalProperties,
}
to_wasm!(
@ -26,7 +21,7 @@ to_wasm!(
original,
wasm_context,
{ WasmAstNode::PlainListItem(original) },
{ "item".into() },
{ "TODO".into() },
{
let children = original
.children
@ -41,18 +36,7 @@ to_wasm!(
Ok((
children,
WasmPlainListItem {
tag: Vec::new(),
bullet: original.bullet.to_owned(),
counter: original.counter.clone(),
checkbox: original.checkbox.as_ref().map(|(checkbox_type, _)| {
match checkbox_type {
CheckboxType::On => "on",
CheckboxType::Trans => "trans",
CheckboxType::Off => "off",
}
.to_owned()
}),
pre_blank: 0, // TODO: Should this be a no-op?
additional_properties: AdditionalProperties::default(),
},
))
}

View File

@ -411,7 +411,7 @@ pub(crate) fn wasm_get_emacs_standard_properties(
fn wasm_compare_list<'e, 's: 'e, 'w, EI, WI>(
source: &'s str,
mut emacs: EI,
emacs: EI,
wasm: WI,
) -> Result<WasmDiffResult<'s>, Box<dyn std::error::Error>>
where
@ -420,11 +420,6 @@ where
{
let emacs_length = emacs.len();
let wasm_length = wasm.len();
if emacs_length == 1 && wasm_length == 0 {
if emacs.all(|t| matches!(t.as_atom(), Ok(r#""""#))) {
return Ok(WasmDiffResult::default());
}
}
if emacs_length != wasm_length {
return Ok(WasmDiffResult {
status: vec![WasmDiffStatus::Bad(
@ -574,11 +569,11 @@ fn compare_object_tree<'e, 's, 'w>(
.expect("If-statement proves this will be Some.");
result.extend(compare_json_value(source, emacs_val, wasm_val)?)?;
} else {
// If optval is not null, then the emacs array should contain a list, the first child of which is a list for optval, and all other entries to the outer list are the val.
if emacs_attribute.len() < 2 {
// If optval is not null, then the emacs array should contain 3 values, the optval, a dot, and the val.
if emacs_attribute.len() != 3 {
result.status.push(WasmDiffStatus::Bad(
format!(
"Emacs middle layer in object tree should have a length of at least 2. Emacs=({emacs:?}) Wasm=({wasm:?}).",
"Emacs middle layer in object tree should have a length of 3. Emacs=({emacs:?}) Wasm=({wasm:?}).",
emacs = emacs_attribute,
wasm = wasm_attribute
)
@ -586,27 +581,20 @@ fn compare_object_tree<'e, 's, 'w>(
));
return Ok(result);
}
let emacs_optval = emacs_attribute.iter().skip(1);
let emacs_optval = emacs_attribute
.first()
.expect("If-statement proves this will be Some.");
let wasm_optval = wasm_attribute
.first()
.expect("If-statement proves this will be Some.")
.as_array()
.ok_or("first value in wasm object tree should be a list.")?;
.expect("If-statement proves this will be Some.");
let emacs_val = emacs_attribute
.first()
.ok_or("If-statement proves this will be Some.")?
.as_list()?;
.get(2)
.expect("If-statement proves this will be Some.");
let wasm_val = wasm_attribute
.get(1)
.expect("If-statement proves this will be Some.")
.as_array()
.ok_or("2nd value in wasm object tree should be a list.")?;
result.extend(wasm_compare_list(source, emacs_optval, wasm_optval.iter())?)?;
result.extend(wasm_compare_list(
source,
emacs_val.iter(),
wasm_val.iter(),
)?)?;
.expect("If-statement proves this will be Some.");
result.extend(compare_json_value(source, emacs_optval, wasm_optval)?)?;
result.extend(compare_json_value(source, emacs_val, wasm_val)?)?;
}
}