/// 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", "SimpleSpeak", 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", "SimpleSpeak", 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", "SimpleSpeak", expr, "inverse sine of x"); } #[test] fn trig_squared() { let expr = "sin2x"; test("en", "SimpleSpeak", expr, "sine squared of x"); } #[test] fn trig_cubed() { let expr = "tan3x"; test("en", "SimpleSpeak", expr, "tangent cubed of x"); } #[test] fn trig_fourth() { let expr = "sec4x"; test("en", "SimpleSpeak", expr, "the fourth power of, secant of x"); } #[test] fn trig_power_other() { let expr = "sinh>n-1x"; test("en", "SimpleSpeak", expr, "the n minus 1 power of, hyperbolic sine of x"); } #[test] fn simple_log() { let expr = " logx "; test("en", "SimpleSpeak", expr, "log x"); } #[test] fn normal_log() { let expr = "log(x+y)"; test("en", "SimpleSpeak", expr, "the log of, open paren x plus y, close paren"); } #[test] fn simple_log_with_base() { let expr = " logbx "; test("en", "SimpleSpeak", expr, "the log base b of x"); } #[test] fn normal_log_with_base() { let expr = "logb(x+y)"; test("en", "SimpleSpeak", expr, "the log base b of, open paren x plus y, close paren"); } #[test] fn simple_ln() { let expr = " lnx "; test("en", "SimpleSpeak", expr, "natural log x"); } #[test] fn normal_ln() { let expr = "ln(x+y)"; test("en", "SimpleSpeak", expr, "the natural log of, open paren x plus y, close paren"); } #[test] fn normal_ln_terse() { let expr = "ln(x+y)"; test_prefs("en", "SimpleSpeak", vec![("Verbosity", "Terse")], expr, "l n of, open x plus y close"); } #[test] fn simple_ln_terse() { let expr = " lnx "; test_prefs("en", "SimpleSpeak", vec![("Verbosity", "Terse")], expr, "l n x"); } #[test] fn other_names() { let expr = " Covx "; test_prefs("en", "SimpleSpeak", vec![("Verbosity", "Terse")], expr, "Cov x"); test_prefs("en", "SimpleSpeak", vec![("Verbosity", "Medium")], expr, "covariance x"); let expr = " exp(x) "; test_prefs("en", "SimpleSpeak", vec![("Verbosity", "Terse")], expr, "exp x"); test_prefs("en", "SimpleSpeak", vec![("Verbosity", "Medium")], expr, "exponential of x"); } #[test] fn explicit_function_call_with_parens() { let expr = "t(x)"; test("en", "SimpleSpeak", expr, "t of x"); } #[test] fn explicit_times_with_parens() { let expr = "t(x)"; test("en", "SimpleSpeak", expr, "t times x"); } #[test] fn explicit_function_call() { let expr = "tx"; test("en", "SimpleSpeak", expr, "t of x"); } #[test] fn explicit_times() { let expr = "tx"; test("en", "SimpleSpeak", expr, "t x"); } /* * Tests for times */ #[test] fn no_times_binomial() { let expr = "x y"; test("en", "SimpleSpeak", expr, "x y"); } #[test] fn times_following_paren() { let expr = " 2 ( 3 ) "; test("en", "SimpleSpeak", expr, "2 times 3"); } #[test] fn times_preceding_paren() { let expr = " ( 2 ) 3 "; test("en", "SimpleSpeak", expr, "2 times 3"); } #[test] fn no_times_sqrt() { let expr = " a b = ab "; test("en", "SimpleSpeak", expr, "the square root of eigh; the square root of b; is equal to, the square root of eigh b end root,"); test_prefs("en", "SimpleSpeak", vec![("Impairment", "LearningDisability")], expr, "the square root of eigh; the square root of b; is equal to, the square root of eigh b,"); } /* * Tests for parens */ #[test] fn no_parens_number() { let expr = " ( 25 ) x "; test("en", "SimpleSpeak", expr, "25 times x"); } #[test] fn no_parens_monomial() { let expr = " b ( xy ) "; test("en", "SimpleSpeak", expr, "b x y"); } #[test] fn no_parens_negative_number() { let expr = " 2+ ( 2 ) "; test("en", "SimpleSpeak", expr, "2 plus negative 2"); } #[test] fn no_parens_negative_number_with_var() { let expr = " ( 2x ) +1 "; test("en", "SimpleSpeak", expr, "negative 2 x, plus 1"); } #[test] fn parens_superscript() { let expr = " ( 2x ) 2 "; test("en", "SimpleSpeak", expr, "open paren 2 x close paren squared"); } #[test] fn no_parens_fraction() { let expr = " 2 + ( 12 ) "; test("en", "SimpleSpeak", expr, "2 plus 1 half"); } // Tests for the four types of intervals in SimpleSpeak #[test] fn parens_interval_open_open() { let expr = " ( (c,d) ) "; test("en", "SimpleSpeak",expr, "the open interval from c to d"); } #[test] fn parens_interval_closed_open() { let expr = " [ [(]c,d) ) "; test("en", "SimpleSpeak",expr, "the closed open interval from c to d"); } #[test] fn parens_interval_open_closed() { let expr = " ( (c,d] ] "; test("en", "SimpleSpeak",expr,"the open closed interval from c to d"); } #[test] fn parens_interval_closed_closed() { let expr = " [ [(]c,d] ] "; test("en", "SimpleSpeak",expr, "the closed interval from c to d"); } #[test] fn parens_interval_neg_infinity_open_open() { let expr = " ( - ,d) ) "; test("en", "SimpleSpeak",expr, "the open interval from negative infinity to d"); } #[test] fn parens_interval_neg_infinity_open_closed() { let expr = " ( - ,d] ] "; test("en", "SimpleSpeak",expr, "the open closed interval from negative infinity to d"); }