(mathml: &str, target: &str, intent_error_recovery: &str)
| 426 | |
| 427 | |
| 428 | fn test_intent(mathml: &str, target: &str, intent_error_recovery: &str) -> bool { |
| 429 | use crate::interface::*; |
| 430 | // this forces initialization |
| 431 | crate::interface::set_rules_dir(super::super::abs_rules_dir_path()).unwrap(); |
| 432 | crate::speech::SpeechRules::initialize_all_rules().unwrap(); |
| 433 | set_preference("IntentErrorRecovery".to_string(), intent_error_recovery.to_string()).unwrap(); |
| 434 | let package1 = &parser::parse(mathml).expect("Failed to parse test input"); |
| 435 | let mathml = get_element(package1); |
| 436 | trim_element(&mathml); |
| 437 | debug!("test: {}", crate::pretty_print::mml_to_string(&mathml)); |
| 438 | |
| 439 | let package2 = &parser::parse(target).expect("Failed to parse target input"); |
| 440 | let target = get_element(package2); |
| 441 | trim_element(&target); |
| 442 | debug!("target: {}", crate::pretty_print::mml_to_string(&target)); |
| 443 | |
| 444 | let result = match crate::speech::intent_from_mathml(mathml, package2.as_document()) { |
| 445 | Ok(e) => e, |
| 446 | Err(e) => { |
| 447 | debug!("{}", crate::interface::errors_to_string(&e)); |
| 448 | return false; // could be intentional failure |
| 449 | } |
| 450 | }; |
| 451 | debug!("result: {}", crate::pretty_print::mml_to_string(&result)); |
| 452 | match is_same_element(&result, &target) { |
| 453 | Ok(_) => return true, |
| 454 | Err(e) => panic!("{}", e), |
| 455 | } |
| 456 | } |
| 457 | |
| 458 | #[test] |
| 459 | fn infer_binomial() { |
nothing calls this directly
no test coverage detected