1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#![recursion_limit = "1024"]
#[macro_use]
extern crate error_chain;
pub mod errors {
error_chain! {
}
}
#[macro_use]
extern crate lazy_static;
#[macro_use]
extern crate bitflags;
#[macro_use]
extern crate log;
#[macro_use]
extern crate cfg_if;
pub mod interface;
mod canonicalize;
mod infer_intent;
pub mod speech;
mod braille;
mod navigate;
mod prefs;
mod tts;
mod xpath_functions;
mod definitions;
mod pretty_print;
mod chemistry;
pub mod shim_filesystem; pub use shim_filesystem::ZIPPED_RULE_FILES;
pub use interface::*;
#[cfg(test)]
pub fn init_logger() {
env_logger::Builder::from_env(env_logger::Env::default().default_filter_or("debug"))
.is_test(true)
.format_timestamp(None)
.format_module_path(false)
.format_indent(None)
.format_level(false)
.init();
}
#[cfg(test)]
pub fn abs_rules_dir_path() -> String {
return std::env::current_exe().unwrap().parent().unwrap()
.join("../../../Rules")
.to_str().unwrap().to_string();
}
#[cfg(test)]
pub fn are_strs_canonically_equal(test: &str, target: &str) -> bool {
use crate::interface::*;
use sxd_document::parser;
use crate::canonicalize::canonicalize;
crate::interface::set_rules_dir(abs_rules_dir_path()).unwrap();
crate::speech::SPEECH_RULES.with(|_| true);
let package1 = &parser::parse(test).expect("Failed to parse test input");
let mathml = get_element(package1);
trim_element(&mathml);
let mathml_test = canonicalize(mathml).unwrap();
let package2 = &parser::parse(target).expect("Failed to parse target input");
let mathml_target = get_element(package2);
trim_element(&mathml_target);
match is_same_element(&mathml_test, &mathml_target) {
Ok(_) => return true,
Err(e) => panic!("{}", e),
}
}