Compare commits
6 Commits
a4a83d047d
...
c1b471208d
Author | SHA1 | Date | |
---|---|---|---|
![]() |
c1b471208d | ||
![]() |
606bab9e6d | ||
![]() |
0edf5620a2 | ||
![]() |
cdf87641c5 | ||
![]() |
eb2995dd3b | ||
![]() |
cd6a64c015 |
@ -4,15 +4,13 @@ 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 {
|
||||
#[serde(flatten)]
|
||||
pub(crate) additional_properties: AdditionalProperties,
|
||||
pub(crate) value: String,
|
||||
}
|
||||
|
||||
to_wasm!(
|
||||
@ -21,12 +19,12 @@ to_wasm!(
|
||||
original,
|
||||
wasm_context,
|
||||
{ WasmAstNode::Comment(original) },
|
||||
{ "TODO".into() },
|
||||
{ "comment".into() },
|
||||
{
|
||||
Ok((
|
||||
Vec::new(),
|
||||
WasmComment {
|
||||
additional_properties: AdditionalProperties::default(),
|
||||
value: original.get_value(),
|
||||
},
|
||||
))
|
||||
}
|
||||
|
@ -6,6 +6,7 @@ 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;
|
||||
|
||||
@ -13,6 +14,8 @@ 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!(
|
||||
@ -21,12 +24,18 @@ to_wasm!(
|
||||
original,
|
||||
wasm_context,
|
||||
{ WasmAstNode::Keyword(original) },
|
||||
{ "TODO".into() },
|
||||
{ "keyword".into() },
|
||||
{
|
||||
let additional_properties = original
|
||||
.get_affiliated_keywords()
|
||||
.to_wasm(wasm_context.clone())?;
|
||||
|
||||
Ok((
|
||||
Vec::new(),
|
||||
WasmKeyword {
|
||||
additional_properties: AdditionalProperties::default(),
|
||||
additional_properties,
|
||||
key: original.key.to_uppercase(),
|
||||
value: original.value.to_owned(),
|
||||
},
|
||||
))
|
||||
}
|
||||
|
@ -6,13 +6,17 @@ 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!(
|
||||
@ -21,8 +25,12 @@ to_wasm!(
|
||||
original,
|
||||
wasm_context,
|
||||
{ WasmAstNode::PlainList(original) },
|
||||
{ "TODO".into() },
|
||||
{ "plain-list".into() },
|
||||
{
|
||||
let additional_properties = original
|
||||
.get_affiliated_keywords()
|
||||
.to_wasm(wasm_context.clone())?;
|
||||
|
||||
let children = original
|
||||
.children
|
||||
.iter()
|
||||
@ -36,7 +44,13 @@ to_wasm!(
|
||||
Ok((
|
||||
children,
|
||||
WasmPlainList {
|
||||
additional_properties: AdditionalProperties::default(),
|
||||
additional_properties,
|
||||
list_type: match original.list_type {
|
||||
PlainListType::Unordered => "unordered",
|
||||
PlainListType::Ordered => "ordered",
|
||||
PlainListType::Descriptive => "descriptive",
|
||||
}
|
||||
.to_owned(),
|
||||
},
|
||||
))
|
||||
}
|
||||
|
@ -4,15 +4,20 @@ 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 {
|
||||
#[serde(flatten)]
|
||||
pub(crate) additional_properties: AdditionalProperties,
|
||||
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,
|
||||
}
|
||||
|
||||
to_wasm!(
|
||||
@ -21,7 +26,7 @@ to_wasm!(
|
||||
original,
|
||||
wasm_context,
|
||||
{ WasmAstNode::PlainListItem(original) },
|
||||
{ "TODO".into() },
|
||||
{ "item".into() },
|
||||
{
|
||||
let children = original
|
||||
.children
|
||||
@ -36,7 +41,18 @@ to_wasm!(
|
||||
Ok((
|
||||
children,
|
||||
WasmPlainListItem {
|
||||
additional_properties: AdditionalProperties::default(),
|
||||
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?
|
||||
},
|
||||
))
|
||||
}
|
||||
|
@ -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,
|
||||
emacs: EI,
|
||||
mut emacs: EI,
|
||||
wasm: WI,
|
||||
) -> Result<WasmDiffResult<'s>, Box<dyn std::error::Error>>
|
||||
where
|
||||
@ -420,6 +420,11 @@ 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(
|
||||
@ -569,11 +574,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 3 values, the optval, a dot, and the val.
|
||||
if emacs_attribute.len() != 3 {
|
||||
// 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 {
|
||||
result.status.push(WasmDiffStatus::Bad(
|
||||
format!(
|
||||
"Emacs middle layer in object tree should have a length of 3. Emacs=({emacs:?}) Wasm=({wasm:?}).",
|
||||
"Emacs middle layer in object tree should have a length of at least 2. Emacs=({emacs:?}) Wasm=({wasm:?}).",
|
||||
emacs = emacs_attribute,
|
||||
wasm = wasm_attribute
|
||||
)
|
||||
@ -581,20 +586,27 @@ fn compare_object_tree<'e, 's, 'w>(
|
||||
));
|
||||
return Ok(result);
|
||||
}
|
||||
let emacs_optval = emacs_attribute
|
||||
.first()
|
||||
.expect("If-statement proves this will be Some.");
|
||||
let emacs_optval = emacs_attribute.iter().skip(1);
|
||||
let wasm_optval = wasm_attribute
|
||||
.first()
|
||||
.expect("If-statement proves this will be Some.");
|
||||
.expect("If-statement proves this will be Some.")
|
||||
.as_array()
|
||||
.ok_or("first value in wasm object tree should be a list.")?;
|
||||
let emacs_val = emacs_attribute
|
||||
.get(2)
|
||||
.expect("If-statement proves this will be Some.");
|
||||
.first()
|
||||
.ok_or("If-statement proves this will be Some.")?
|
||||
.as_list()?;
|
||||
let wasm_val = wasm_attribute
|
||||
.get(1)
|
||||
.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)?)?;
|
||||
.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(),
|
||||
)?)?;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user