/// Tests for: /// * functions including trig functions, logs, and functions to powers /// * implied times/functional call and explicit times/function call /// * parens /// These are all intertwined, so they are in one file use crate::common::*; #[test] fn trig_names() { let expr = " sinx+ cosy+ tanz+ secα+ cscϕ+ cotφ "; test("en", "ClearSpeak", expr, "sine of x plus cosine of y plus tangent of z plus secant of alpha, plus cosecant of phi, plus cotangent of phi"); } #[test] fn hyperbolic_trig_names() { let expr = " sinhx+ coshy+ tanhz+ sechα+ cschϕ+ cothφ "; test("en", "ClearSpeak", expr, "hyperbolic sine of x, plus \ hyperbolic cosine of y, plus \ hyperbolic tangent of z, plus \ hyperbolic secant of alpha, plus \ hyperbolic cosecant of phi, plus \ hyperbolic cotangent of phi"); } #[test] fn inverse_trig() { let expr = "sin-1x"; test("en", "ClearSpeak", expr, "inverse sine of x"); } #[test] fn inverse_trig_trig_inverse() { let expr = "tan-1x"; test_ClearSpeak("en", "ClearSpeak_Trig", "TrigInverse",expr, "tangent inverse of x"); } #[test] fn inverse_trig_arc() { let expr = "cosh-1x"; test_ClearSpeak("en", "ClearSpeak_Trig", "ArcTrig",expr, "arc hyperbolic cosine of x"); } #[test] fn trig_squared() { let expr = "sin2x"; test("en", "ClearSpeak", expr, "sine squared of x"); } #[test] fn trig_cubed() { let expr = "tan3x"; test("en", "ClearSpeak", expr, "tangent cubed of x"); } #[test] fn trig_fourth() { let expr = "sec4x"; test("en", "ClearSpeak", expr, "the fourth power of, secant of x"); } #[test] fn trig_power_other() { let expr = "sinh>n-1x"; test("en", "ClearSpeak", expr, "the n minus 1 power of, hyperbolic sine of x"); } #[test] fn simple_log() { let expr = " logx "; test("en", "ClearSpeak", expr, "log x"); } #[test] fn normal_log() { let expr = "log(x+y)"; test("en", "ClearSpeak", expr, "the log of, open paren x plus y, close paren"); } #[test] fn simple_log_with_base() { let expr = " logbx "; test("en", "ClearSpeak", expr, "the log base b of x"); } #[test] fn normal_log_with_base() { let expr = "logb(x+y)"; test("en", "ClearSpeak", expr, "the log base b of, open paren x plus y, close paren"); } #[test] fn simple_ln() { let expr = " lnx "; test("en", "ClearSpeak", expr, "l n x"); } #[test] fn normal_ln() { let expr = "ln(x+y)"; test("en", "ClearSpeak", expr, "the l n of, open paren x plus y, close paren"); } #[test] fn simple_natural_log() { let expr = " lnx "; test_ClearSpeak("en", "ClearSpeak_Log", "LnAsNaturalLog",expr, "natural log x"); } #[test] fn natural_log() { let expr = "ln(x+y)"; test_ClearSpeak("en", "ClearSpeak_Log", "LnAsNaturalLog",expr, "the natural log of, open paren x plus y, close paren"); } #[test] fn explicit_function_call_with_parens() { let expr = "t(x)"; test("en", "ClearSpeak", expr, "t of x"); } #[test] fn explicit_times_with_parens() { let expr = "t(x)"; test("en", "ClearSpeak", expr, "t times x"); } #[test] fn explicit_function_call() { let expr = "tx"; test("en", "ClearSpeak", expr, "t of x"); } #[test] fn explicit_times() { let expr = "tx"; test("en", "ClearSpeak", expr, "t x"); } #[test] fn test_functions_none_pref() { let expr = " log(x+y) + f(x+y) "; test_ClearSpeak("en", "ClearSpeak_Functions", "None",expr, "the log of, open paren x plus y, close paren; plus, f times, open paren x plus y, close paren"); } #[test] fn test_functions_none_pref_multiple_args() { let expr = " B ( 2,6 ) "; test_ClearSpeak("en", "ClearSpeak_Functions", "None",expr, "cap b times, open paren 2 comma 6, close paren"); } /* * Tests for times */ #[test] fn no_times_binomial() { let expr = "x y"; test("en", "ClearSpeak", expr, "x y"); } #[test] fn times_following_paren() { let expr = " 2 ( 3 ) "; test("en", "ClearSpeak", expr, "2 times 3"); } #[test] fn times_preceding_paren() { let expr = " ( 2 ) 3 "; test("en", "ClearSpeak", expr, "2 times 3"); } #[test] fn no_times_sqrt() { let expr = " a b = ab "; test("en", "ClearSpeak", expr, "the square root of eigh; the square root of b; is equal to, the square root of eigh b,"); } #[test] fn more_implied_times() { let expr = " ( 2x ) 2 "; test_ClearSpeak("en", "ClearSpeak_ImpliedTimes", "MoreImpliedTimes",expr, "open paren 2 times x, close paren squared"); } #[test] fn explicit_times_more_implied_times() { let expr = "tx"; test_ClearSpeak("en", "ClearSpeak_ImpliedTimes", "MoreImpliedTimes",expr, "t times x"); } #[test] fn explicit_times_none_simple_right() { let expr = "2[3 ]"; test_ClearSpeak("en", "ClearSpeak_ImpliedTimes", "None", expr, "2, open bracket 3 close bracket"); } #[test] fn explicit_times_none_simple_left() { let expr = "(21)x"; test_ClearSpeak("en", "ClearSpeak_ImpliedTimes", "None", expr, "open paren 2 minus 1, close paren; x"); } #[test] fn explicit_times_none_superscript() { let expr = " f(x)= x 2 ( x+1 ) "; test_ClearSpeak_prefs("en", vec![("ClearSpeak_ImpliedTimes", "None"), ("ClearSpeak_Functions", "None")], expr, "f open paren x close paren; is equal to; x squared, open paren x plus 1, close paren"); } /* * Tests for parens */ #[test] fn no_parens_number() { let expr = " ( 25 ) x "; test("en", "ClearSpeak", expr, "25 times x"); } #[test] fn no_parens_monomial() { let expr = " b ( xy ) "; test("en", "ClearSpeak", expr, "b x y"); } #[test] fn no_parens_negative_number() { let expr = " 2+ ( 2 ) "; test("en", "ClearSpeak", expr, "2 plus negative 2"); } #[test] fn no_parens_negative_number_with_var() { let expr = " ( 2x ) +1 "; test("en", "ClearSpeak", expr, "negative 2 x, plus 1"); } #[test] fn parens_superscript() { let expr = " ( 2x ) 2 "; test("en", "ClearSpeak", expr, "open paren 2 x close paren squared"); } #[test] fn no_parens_fraction() { let expr = " 2 + ( 12 ) "; test("en", "ClearSpeak", expr, "2 plus 1 half"); } // Tests for the ten types of intervals in ClearSpeak #[test] fn parens_interval_open_open() { let expr = " ( c,d ) "; test_ClearSpeak("en", "ClearSpeak_Paren", "Interval",expr, "the interval from c to d, not including c or d"); } #[test] fn parens_interval_closed_open() { let expr = " [ c,d ) "; test_ClearSpeak("en", "ClearSpeak_Paren", "Interval ",expr, "the interval from c to d, including c but not including d"); } #[test] fn parens_interval_open_closed() { let expr = " ( c,d ] "; test_ClearSpeak("en", "ClearSpeak_Paren", "Interval ",expr, "the interval from c to d, not including c but including d"); } #[test] fn parens_interval_closed_closed() { let expr = " [ c,d ] "; test_ClearSpeak("en", "ClearSpeak_Paren", "Interval ",expr, "the interval from c to d, including c and d"); } #[test] fn parens_interval_neg_infinity_open_open() { let expr = " ( - ,d ) "; test_ClearSpeak("en", "ClearSpeak_Paren", "Interval ",expr, "the interval from negative infinity to d, not including d"); } #[test] fn parens_interval_neg_infinity_closed_open() { let expr = " ( - ,d ] "; test_ClearSpeak("en", "ClearSpeak_Paren", "Interval ",expr, "the interval from negative infinity to d, including d"); } #[test] fn parens_interval_open_open_infinity() { let expr = " ( c, ) "; test_ClearSpeak("en", "ClearSpeak_Paren", "Interval ",expr, "the interval from c to infinity, not including c"); } #[test] fn parens_interval_closed_open_infinity() { let expr = " [ c, ) "; test_ClearSpeak("en", "ClearSpeak_Paren", "Interval ",expr, "the interval from c to infinity, including c"); } #[test] fn parens_interval_neg_infinity_to_infinity() { let expr = " ( - , ) "; test_ClearSpeak("en", "ClearSpeak_Paren", "Interval ",expr, "the interval from negative infinity to infinity,"); } #[test] fn parens_interval_neg_infinity_to_pos_infinity() { let expr = " ( - ,+ ) "; test_ClearSpeak("en", "ClearSpeak_Paren", "Interval ",expr, "the interval from negative infinity to positive infinity,"); }