Switch everything over to the new to_wasm macro.
This commit is contained in:
@@ -7,6 +7,7 @@ use crate::compare::EmacsField;
|
||||
use crate::compare::Token;
|
||||
use crate::wasm::WasmAngleLink;
|
||||
use crate::wasm::WasmAstNode;
|
||||
use crate::wasm::WasmAstNodeWrapper;
|
||||
use crate::wasm::WasmBabelCall;
|
||||
use crate::wasm::WasmBold;
|
||||
use crate::wasm::WasmCenterBlock;
|
||||
@@ -69,7 +70,7 @@ use crate::wasm_test::macros::wasm_compare;
|
||||
pub fn wasm_compare_document<'e, 's, 'w>(
|
||||
source: &'s str,
|
||||
emacs: &'e Token<'s>,
|
||||
wasm: &'w WasmDocument,
|
||||
wasm: &'w WasmAstNodeWrapper<WasmDocument>,
|
||||
) -> Result<WasmDiffResult<'s>, Box<dyn std::error::Error>> {
|
||||
let wasm_json = serde_json::to_string(&wasm)?;
|
||||
let wasm_json_parsed = serde_json::from_str(&wasm_json)?;
|
||||
@@ -153,6 +154,11 @@ fn compare_ast_node<'b, 's, 'p>(
|
||||
.next()
|
||||
.ok_or("Should have an attributes child.")?
|
||||
.as_map()?;
|
||||
let wasm_attributes_map = wasm
|
||||
.get("properties")
|
||||
.ok_or(r#"Wasm ast node should have a "properties" attribute."#)?
|
||||
.as_object()
|
||||
.ok_or(r#"Wasm ast node "properties" attribute should be an object."#)?;
|
||||
|
||||
{
|
||||
// Compare attribute names.
|
||||
@@ -160,11 +166,10 @@ fn compare_ast_node<'b, 's, 'p>(
|
||||
.keys()
|
||||
.map(|s| (*s).to_owned())
|
||||
.collect();
|
||||
let wasm_keys: std::collections::BTreeSet<String> = wasm
|
||||
.keys()
|
||||
.filter(|k| !k.starts_with("__"))
|
||||
.map(wasm_key_to_emacs_key)
|
||||
.collect();
|
||||
let wasm_keys: std::collections::BTreeSet<String> =
|
||||
std::iter::once(":standard-properties".to_owned())
|
||||
.chain(wasm_attributes_map.keys().map(wasm_key_to_emacs_key))
|
||||
.collect();
|
||||
let emacs_only_attributes: Vec<&String> = emacs_keys.difference(&wasm_keys).collect();
|
||||
let wasm_only_attributes: Vec<&String> = wasm_keys.difference(&emacs_keys).collect();
|
||||
if !emacs_only_attributes.is_empty() {
|
||||
@@ -201,13 +206,10 @@ fn compare_ast_node<'b, 's, 'p>(
|
||||
|
||||
{
|
||||
// Compare attributes.
|
||||
for attribute_name in wasm
|
||||
.keys()
|
||||
.filter(|k| !k.starts_with("__") && k.as_str() != "standard-properties")
|
||||
{
|
||||
for attribute_name in wasm_attributes_map.keys() {
|
||||
let mut layer = WasmDiffResult::default();
|
||||
layer.name = Cow::Owned(attribute_name.clone());
|
||||
let wasm_attribute_value = wasm
|
||||
let wasm_attribute_value = wasm_attributes_map
|
||||
.get(attribute_name)
|
||||
.ok_or("Key should exist in both wasm and elisp at this point.")?;
|
||||
let emacs_key = wasm_key_to_emacs_key(attribute_name);
|
||||
|
||||
Reference in New Issue
Block a user