Separate out the wasm test into its own feature/binary.
This commit is contained in:
1
src/wasm/compare/mod.rs
Normal file
1
src/wasm/compare/mod.rs
Normal file
@@ -0,0 +1 @@
|
||||
mod runner;
|
||||
7
src/wasm/compare/runner.rs
Normal file
7
src/wasm/compare/runner.rs
Normal file
@@ -0,0 +1,7 @@
|
||||
// pub async fn run_anonymous_compare_with_settings<'g, 's, P: AsRef<str>>(
|
||||
// org_contents: P,
|
||||
// global_settings: &GlobalSettings<'g, 's>,
|
||||
// silent: bool,
|
||||
// ) -> Result<bool, Box<dyn std::error::Error>> {
|
||||
// todo!()
|
||||
// }
|
||||
@@ -9,6 +9,8 @@ mod clock;
|
||||
mod code;
|
||||
mod comment;
|
||||
mod comment_block;
|
||||
#[cfg(feature = "wasm_test")]
|
||||
mod compare;
|
||||
mod diary_sexp;
|
||||
mod document;
|
||||
mod drawer;
|
||||
@@ -62,6 +64,7 @@ mod underline;
|
||||
mod verbatim;
|
||||
mod verse_block;
|
||||
|
||||
pub(crate) use parse_result::wasm_parse_org;
|
||||
pub(crate) use parse_result::ParseResult;
|
||||
pub(crate) use to_wasm::ToWasm;
|
||||
pub(crate) use to_wasm::ToWasmContext;
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
use serde::Deserialize;
|
||||
use organic::parser::parse_with_settings;
|
||||
use organic::settings::GlobalSettings;
|
||||
use serde::Serialize;
|
||||
|
||||
use super::document::WasmDocument;
|
||||
use super::ToWasm;
|
||||
use super::ToWasmContext;
|
||||
|
||||
#[derive(Debug, Serialize)]
|
||||
#[serde(tag = "status", content = "content")]
|
||||
@@ -12,3 +15,18 @@ pub(crate) enum ParseResult<'s> {
|
||||
#[serde(rename = "error")]
|
||||
Error(String),
|
||||
}
|
||||
|
||||
pub(crate) fn wasm_parse_org(org_contents: &str) -> ParseResult<'_> {
|
||||
let global_settings = GlobalSettings::default();
|
||||
let to_wasm_context = ToWasmContext::new(org_contents);
|
||||
let rust_parsed = match parse_with_settings(org_contents, &global_settings)
|
||||
.map(|document| document.to_wasm(to_wasm_context))
|
||||
.map(|wasm_document| match wasm_document {
|
||||
Ok(wasm_document) => ParseResult::Success(wasm_document),
|
||||
Err(err) => ParseResult::Error(format!("{:?}", err)),
|
||||
}) {
|
||||
Ok(wasm_document) => wasm_document,
|
||||
Err(err) => ParseResult::Error(format!("{:?}", err)),
|
||||
};
|
||||
rust_parsed
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user