Compare commits
No commits in common. "c1b471208d893fbaceca397a5923502e40d73ee3" and "a4a83d047d0f78eb90d1b13bc68652429f06a81e" have entirely different histories.
c1b471208d
...
a4a83d047d
@ -4,13 +4,15 @@ use serde::Serialize;
|
|||||||
use super::ast_node::WasmAstNode;
|
use super::ast_node::WasmAstNode;
|
||||||
use super::macros::to_wasm;
|
use super::macros::to_wasm;
|
||||||
use super::to_wasm::ToWasm;
|
use super::to_wasm::ToWasm;
|
||||||
|
use super::AdditionalProperties;
|
||||||
use crate::compare::ElispFact;
|
use crate::compare::ElispFact;
|
||||||
use crate::types::Comment;
|
use crate::types::Comment;
|
||||||
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
pub struct WasmComment {
|
pub struct WasmComment {
|
||||||
pub(crate) value: String,
|
#[serde(flatten)]
|
||||||
|
pub(crate) additional_properties: AdditionalProperties,
|
||||||
}
|
}
|
||||||
|
|
||||||
to_wasm!(
|
to_wasm!(
|
||||||
@ -19,12 +21,12 @@ to_wasm!(
|
|||||||
original,
|
original,
|
||||||
wasm_context,
|
wasm_context,
|
||||||
{ WasmAstNode::Comment(original) },
|
{ WasmAstNode::Comment(original) },
|
||||||
{ "comment".into() },
|
{ "TODO".into() },
|
||||||
{
|
{
|
||||||
Ok((
|
Ok((
|
||||||
Vec::new(),
|
Vec::new(),
|
||||||
WasmComment {
|
WasmComment {
|
||||||
value: original.get_value(),
|
additional_properties: AdditionalProperties::default(),
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,6 @@ use super::macros::to_wasm;
|
|||||||
use super::to_wasm::ToWasm;
|
use super::to_wasm::ToWasm;
|
||||||
use super::AdditionalProperties;
|
use super::AdditionalProperties;
|
||||||
use crate::compare::ElispFact;
|
use crate::compare::ElispFact;
|
||||||
use crate::types::GetAffiliatedKeywords;
|
|
||||||
use crate::types::Keyword;
|
use crate::types::Keyword;
|
||||||
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
|
|
||||||
@ -14,8 +13,6 @@ use crate::wasm::to_wasm::ToWasmStandardProperties;
|
|||||||
pub struct WasmKeyword {
|
pub struct WasmKeyword {
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
pub(crate) additional_properties: AdditionalProperties,
|
pub(crate) additional_properties: AdditionalProperties,
|
||||||
pub(crate) key: String,
|
|
||||||
pub(crate) value: String,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
to_wasm!(
|
to_wasm!(
|
||||||
@ -24,18 +21,12 @@ to_wasm!(
|
|||||||
original,
|
original,
|
||||||
wasm_context,
|
wasm_context,
|
||||||
{ WasmAstNode::Keyword(original) },
|
{ WasmAstNode::Keyword(original) },
|
||||||
{ "keyword".into() },
|
{ "TODO".into() },
|
||||||
{
|
{
|
||||||
let additional_properties = original
|
|
||||||
.get_affiliated_keywords()
|
|
||||||
.to_wasm(wasm_context.clone())?;
|
|
||||||
|
|
||||||
Ok((
|
Ok((
|
||||||
Vec::new(),
|
Vec::new(),
|
||||||
WasmKeyword {
|
WasmKeyword {
|
||||||
additional_properties,
|
additional_properties: AdditionalProperties::default(),
|
||||||
key: original.key.to_uppercase(),
|
|
||||||
value: original.value.to_owned(),
|
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
@ -6,17 +6,13 @@ use super::macros::to_wasm;
|
|||||||
use super::to_wasm::ToWasm;
|
use super::to_wasm::ToWasm;
|
||||||
use super::AdditionalProperties;
|
use super::AdditionalProperties;
|
||||||
use crate::compare::ElispFact;
|
use crate::compare::ElispFact;
|
||||||
use crate::types::GetAffiliatedKeywords;
|
|
||||||
use crate::types::PlainList;
|
use crate::types::PlainList;
|
||||||
use crate::types::PlainListType;
|
|
||||||
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
pub struct WasmPlainList {
|
pub struct WasmPlainList {
|
||||||
#[serde(flatten)]
|
#[serde(flatten)]
|
||||||
pub(crate) additional_properties: AdditionalProperties,
|
pub(crate) additional_properties: AdditionalProperties,
|
||||||
#[serde(rename = "type")]
|
|
||||||
pub(crate) list_type: String,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
to_wasm!(
|
to_wasm!(
|
||||||
@ -25,12 +21,8 @@ to_wasm!(
|
|||||||
original,
|
original,
|
||||||
wasm_context,
|
wasm_context,
|
||||||
{ WasmAstNode::PlainList(original) },
|
{ WasmAstNode::PlainList(original) },
|
||||||
{ "plain-list".into() },
|
{ "TODO".into() },
|
||||||
{
|
{
|
||||||
let additional_properties = original
|
|
||||||
.get_affiliated_keywords()
|
|
||||||
.to_wasm(wasm_context.clone())?;
|
|
||||||
|
|
||||||
let children = original
|
let children = original
|
||||||
.children
|
.children
|
||||||
.iter()
|
.iter()
|
||||||
@ -44,13 +36,7 @@ to_wasm!(
|
|||||||
Ok((
|
Ok((
|
||||||
children,
|
children,
|
||||||
WasmPlainList {
|
WasmPlainList {
|
||||||
additional_properties,
|
additional_properties: AdditionalProperties::default(),
|
||||||
list_type: match original.list_type {
|
|
||||||
PlainListType::Unordered => "unordered",
|
|
||||||
PlainListType::Ordered => "ordered",
|
|
||||||
PlainListType::Descriptive => "descriptive",
|
|
||||||
}
|
|
||||||
.to_owned(),
|
|
||||||
},
|
},
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
|
@ -4,20 +4,15 @@ use serde::Serialize;
|
|||||||
use super::ast_node::WasmAstNode;
|
use super::ast_node::WasmAstNode;
|
||||||
use super::macros::to_wasm;
|
use super::macros::to_wasm;
|
||||||
use super::to_wasm::ToWasm;
|
use super::to_wasm::ToWasm;
|
||||||
|
use super::AdditionalProperties;
|
||||||
use crate::compare::ElispFact;
|
use crate::compare::ElispFact;
|
||||||
use crate::types::CheckboxType;
|
|
||||||
use crate::types::PlainListItem;
|
use crate::types::PlainListItem;
|
||||||
use crate::types::PlainListItemCounter;
|
|
||||||
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
use crate::wasm::to_wasm::ToWasmStandardProperties;
|
||||||
|
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
pub struct WasmPlainListItem {
|
pub struct WasmPlainListItem {
|
||||||
pub(crate) tag: Vec<WasmAstNode>,
|
#[serde(flatten)]
|
||||||
pub(crate) bullet: String,
|
pub(crate) additional_properties: AdditionalProperties,
|
||||||
pub(crate) counter: Option<PlainListItemCounter>,
|
|
||||||
pub(crate) checkbox: Option<String>,
|
|
||||||
#[serde(rename = "pre-blank")]
|
|
||||||
pub(crate) pre_blank: usize,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
to_wasm!(
|
to_wasm!(
|
||||||
@ -26,7 +21,7 @@ to_wasm!(
|
|||||||
original,
|
original,
|
||||||
wasm_context,
|
wasm_context,
|
||||||
{ WasmAstNode::PlainListItem(original) },
|
{ WasmAstNode::PlainListItem(original) },
|
||||||
{ "item".into() },
|
{ "TODO".into() },
|
||||||
{
|
{
|
||||||
let children = original
|
let children = original
|
||||||
.children
|
.children
|
||||||
@ -41,18 +36,7 @@ to_wasm!(
|
|||||||
Ok((
|
Ok((
|
||||||
children,
|
children,
|
||||||
WasmPlainListItem {
|
WasmPlainListItem {
|
||||||
tag: Vec::new(),
|
additional_properties: AdditionalProperties::default(),
|
||||||
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>(
|
fn wasm_compare_list<'e, 's: 'e, 'w, EI, WI>(
|
||||||
source: &'s str,
|
source: &'s str,
|
||||||
mut emacs: EI,
|
emacs: EI,
|
||||||
wasm: WI,
|
wasm: WI,
|
||||||
) -> Result<WasmDiffResult<'s>, Box<dyn std::error::Error>>
|
) -> Result<WasmDiffResult<'s>, Box<dyn std::error::Error>>
|
||||||
where
|
where
|
||||||
@ -420,11 +420,6 @@ where
|
|||||||
{
|
{
|
||||||
let emacs_length = emacs.len();
|
let emacs_length = emacs.len();
|
||||||
let wasm_length = wasm.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 {
|
if emacs_length != wasm_length {
|
||||||
return Ok(WasmDiffResult {
|
return Ok(WasmDiffResult {
|
||||||
status: vec![WasmDiffStatus::Bad(
|
status: vec![WasmDiffStatus::Bad(
|
||||||
@ -574,11 +569,11 @@ fn compare_object_tree<'e, 's, 'w>(
|
|||||||
.expect("If-statement proves this will be Some.");
|
.expect("If-statement proves this will be Some.");
|
||||||
result.extend(compare_json_value(source, emacs_val, wasm_val)?)?;
|
result.extend(compare_json_value(source, emacs_val, wasm_val)?)?;
|
||||||
} else {
|
} 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 optval is not null, then the emacs array should contain 3 values, the optval, a dot, and the val.
|
||||||
if emacs_attribute.len() < 2 {
|
if emacs_attribute.len() != 3 {
|
||||||
result.status.push(WasmDiffStatus::Bad(
|
result.status.push(WasmDiffStatus::Bad(
|
||||||
format!(
|
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,
|
emacs = emacs_attribute,
|
||||||
wasm = wasm_attribute
|
wasm = wasm_attribute
|
||||||
)
|
)
|
||||||
@ -586,27 +581,20 @@ fn compare_object_tree<'e, 's, 'w>(
|
|||||||
));
|
));
|
||||||
return Ok(result);
|
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
|
let wasm_optval = wasm_attribute
|
||||||
.first()
|
.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
|
let emacs_val = emacs_attribute
|
||||||
.first()
|
.get(2)
|
||||||
.ok_or("If-statement proves this will be Some.")?
|
.expect("If-statement proves this will be Some.");
|
||||||
.as_list()?;
|
|
||||||
let wasm_val = wasm_attribute
|
let wasm_val = wasm_attribute
|
||||||
.get(1)
|
.get(1)
|
||||||
.expect("If-statement proves this will be Some.")
|
.expect("If-statement proves this will be Some.");
|
||||||
.as_array()
|
result.extend(compare_json_value(source, emacs_optval, wasm_optval)?)?;
|
||||||
.ok_or("2nd value in wasm object tree should be a list.")?;
|
result.extend(compare_json_value(source, emacs_val, wasm_val)?)?;
|
||||||
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