Invoking wasm_compare_document.
Some checks failed
clippy Build clippy has failed
rust-foreign-document-test Build rust-foreign-document-test has succeeded
rust-build Build rust-build has succeeded
rust-test Build rust-test has succeeded

This commit is contained in:
Tom Alexander 2023-12-27 09:31:54 -05:00
parent 23f4ba4205
commit 99376515ef
Signed by: talexander
GPG Key ID: D3A179C9A53C0EDE
7 changed files with 21 additions and 9 deletions

View File

@ -13,3 +13,4 @@ pub use compare::run_compare_on_file_with_settings;
pub use compare::silent_anonymous_compare;
pub use compare::silent_compare_on_file;
pub use sexp::sexp;
pub use sexp::Token;

View File

@ -8,7 +8,8 @@
extern crate test;
#[cfg(feature = "compare")]
// TODO: I only include compare to use some shared stuff like sexp and DiffResult. Ideally, this would be moved to a shared module.
#[cfg(any(feature = "compare", feature = "wasm_test"))]
pub mod compare;
#[cfg(any(feature = "compare", feature = "wasm_test"))]
pub mod util;

View File

@ -1,16 +1,16 @@
use crate::types::Document;
use serde::Serialize;
use super::ast_node::WasmAstNode;
use super::macros::to_wasm;
use super::standard_properties::WasmStandardProperties;
use super::to_wasm::ToWasm;
use crate::types::Document;
use crate::wasm::to_wasm::ToWasmStandardProperties;
#[derive(Debug, Serialize)]
#[serde(tag = "ast_node")]
#[serde(rename = "org-data")]
pub(crate) struct WasmDocument<'s> {
pub struct WasmDocument<'s> {
standard_properties: WasmStandardProperties,
additional_properties: Vec<(String, &'s str)>,
children: Vec<WasmAstNode<'s>>,

View File

@ -62,6 +62,7 @@ mod underline;
mod verbatim;
mod verse_block;
pub use document::WasmDocument;
pub use parse_result::wasm_parse_org;
pub use parse_result::ParseResult;
pub(crate) use to_wasm::ToWasm;

9
src/wasm_test/compare.rs Normal file
View File

@ -0,0 +1,9 @@
use crate::compare::Token;
use crate::wasm::WasmDocument;
pub fn wasm_compare_document<'b, 's>(
emacs: &'b Token<'s>,
wasm: &'b WasmDocument<'s>,
) -> Result<(), Box<dyn std::error::Error>> {
todo!()
}

View File

@ -1,3 +1,4 @@
mod compare;
mod runner;
pub use runner::wasm_run_anonymous_compare;

View File

@ -1,9 +1,9 @@
use super::compare::wasm_compare_document;
use crate::compare::sexp;
use crate::context::GlobalSettings;
use crate::parser::parse_with_settings;
use crate::util::emacs_parse_anonymous_org_document;
use crate::util::print_versions;
use crate::wasm::ParseResult;
use crate::wasm::ToWasm;
use crate::wasm::ToWasmContext;
@ -26,10 +26,9 @@ pub async fn wasm_run_anonymous_compare_with_settings<'g, 's, P: AsRef<str>>(
}
let rust_parsed = parse_with_settings(org_contents, global_settings)?;
let to_wasm_context = ToWasmContext::new(org_contents);
let wasm_parsed = match rust_parsed.to_wasm(to_wasm_context) {
Ok(wasm_document) => ParseResult::Success(wasm_document),
Err(err) => ParseResult::Error(format!("{:?}", err)),
};
let wasm_parsed = rust_parsed
.to_wasm(to_wasm_context)
.map_err(|_e| "Failed to convert to wasm.")?;
let org_sexp = emacs_parse_anonymous_org_document(org_contents, global_settings).await?;
let (_remaining, parsed_sexp) = sexp(org_sexp.as_str()).map_err(|e| e.to_string())?;
@ -41,7 +40,7 @@ pub async fn wasm_run_anonymous_compare_with_settings<'g, 's, P: AsRef<str>>(
}
// We do the diffing after printing out both parsed forms in case the diffing panics
// let diff_result = compare_document(&parsed_sexp, &rust_parsed)?;
let diff_result = wasm_compare_document(&parsed_sexp, &wasm_parsed)?;
// if !silent {
// diff_result.print(org_contents)?;
// }