Move wasm test to a top-level module.
For some unknown reason, this makes rust-analyzer not angry.
This commit is contained in:
@@ -1,4 +0,0 @@
|
||||
mod runner;
|
||||
|
||||
pub use runner::wasm_run_anonymous_compare;
|
||||
pub use runner::wasm_run_anonymous_compare_with_settings;
|
||||
@@ -1,49 +0,0 @@
|
||||
use crate::context::GlobalSettings;
|
||||
use crate::parser::parse_with_settings;
|
||||
use crate::util::print_versions;
|
||||
|
||||
pub async fn wasm_run_anonymous_compare<P: AsRef<str>>(
|
||||
org_contents: P,
|
||||
) -> Result<bool, Box<dyn std::error::Error>> {
|
||||
wasm_run_anonymous_compare_with_settings(org_contents, &GlobalSettings::default(), false).await
|
||||
}
|
||||
|
||||
pub async fn wasm_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: This is a work-around to pretend that dos line endings do not exist. It would be better to handle the difference in line endings.
|
||||
let org_contents = org_contents.as_ref().replace("\r\n", "\n");
|
||||
let org_contents = org_contents.as_str();
|
||||
if !silent {
|
||||
print_versions().await?;
|
||||
}
|
||||
let rust_parsed = parse_with_settings(org_contents, global_settings)?;
|
||||
// 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())?;
|
||||
|
||||
if !silent {
|
||||
println!("{}\n\n\n", org_contents);
|
||||
// println!("{}", org_sexp);
|
||||
println!("{:#?}", rust_parsed);
|
||||
}
|
||||
|
||||
// We do the diffing after printing out both parsed forms in case the diffing panics
|
||||
// let diff_result = compare_document(&parsed_sexp, &rust_parsed)?;
|
||||
// if !silent {
|
||||
// diff_result.print(org_contents)?;
|
||||
// }
|
||||
|
||||
// if diff_result.is_bad() {
|
||||
// return Ok(false);
|
||||
// } else if !silent {
|
||||
// println!(
|
||||
// "{color}Entire document passes.{reset}",
|
||||
// color = DiffResult::foreground_color(0, 255, 0),
|
||||
// reset = DiffResult::reset_color(),
|
||||
// );
|
||||
// }
|
||||
|
||||
Ok(true)
|
||||
}
|
||||
@@ -9,8 +9,6 @@ mod clock;
|
||||
mod code;
|
||||
mod comment;
|
||||
mod comment_block;
|
||||
#[cfg(feature = "wasm_test")]
|
||||
pub mod compare;
|
||||
mod diary_sexp;
|
||||
mod document;
|
||||
mod drawer;
|
||||
|
||||
Reference in New Issue
Block a user