/// 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("fi", "ClearSpeak", expr, "sini arvolla x, plus kosini arvolla y, plus tangentti arvolla z, plus sekantti arvolla alfa, plus, kosekantti arvolla suora fii, plus kotangentti arvolla fii"); } #[test] fn hyperbolic_trig_names() { let expr = " sinhx+ coshy+ tanhz+ sechα+ cschϕ+ cothφ "; test("fi", "ClearSpeak", expr, "hyperbolinen sini arvolla x, plus, hyperbolinen kosini arvolla y, plus, hyperbolinen tangentti, arvolla z, plus, hyperbolinen sekantti, arvolla alfa; plus, hyperbolinen kosekantti, arvolla suora fii; plus, hyperbolinen kotangentti, arvolla fii"); } #[test] fn inverse_trig() { let expr = "sin-1x"; test("fi", "ClearSpeak", expr, "käänteis sini arvolla x"); } #[test] fn inverse_trig_trig_inverse() { let expr = "tan-1x"; test_ClearSpeak("fi", "ClearSpeak_Trig", "TrigInverse",expr, "käänteis tangentti arvolla x"); } #[test] fn inverse_trig_arc() { let expr = "cosh-1x"; test_ClearSpeak("fi", "ClearSpeak_Trig", "ArcTrig",expr, "arkus hyperbolinen kosini, arvolla x"); } #[test] fn trig_squared() { let expr = "sin2x"; test("fi", "ClearSpeak", expr, "sini toiseen arvolla x"); } #[test] fn trig_cubed() { let expr = "tan3x"; test("fi", "ClearSpeak", expr, "tangentti kolmanteen arvolla x"); } #[test] fn trig_fourth() { let expr = "sec4x"; test("fi", "ClearSpeak", expr, "sekantti potenssiin 4, arvolla x"); } #[test] fn trig_power_other() { let expr = "sinh>n-1x"; test("fi", "ClearSpeak", expr, "hyperbolinen sini potenssiin n miinus 1; arvolla x"); } #[test] fn simple_log() { let expr = " logx "; test("fi", "ClearSpeak", expr, "log x"); } #[test] fn normal_log() { let expr = "log(x+y)"; test("fi", "ClearSpeak", expr, "log arvolla, auki sulku x plus y, kiinni sulku"); test_prefs("fi", "ClearSpeak", vec![("Verbosity", "Verbose")], expr, "logaritmi arvolla, auki sulku x plus y, kiinni sulku"); } #[test] fn simple_log_with_base() { let expr = " logbx "; test("fi", "ClearSpeak", expr, "log kanta b arvolla x"); } #[test] fn normal_log_with_base() { let expr = "logb(x+y)"; test("fi", "ClearSpeak", expr, "log kanta b arvolla, auki sulku x plus y, kiinni sulku"); } #[test] fn simple_ln() { let expr = " lnx "; test("fi", "ClearSpeak", expr, "l n x"); } #[test] fn normal_ln() { let expr = "ln(x+y)"; test("fi", "ClearSpeak", expr, "l n arvolla, auki sulku x plus y, kiinni sulku"); test_prefs("fi", "ClearSpeak", vec![("Verbosity", "Verbose")], expr, "luonnollinen logaritmi arvolla, auki sulku x plus y, kiinni sulku"); } #[test] fn simple_lg() { let expr = " lgx "; test("fi", "ClearSpeak", expr, "l g x"); } #[test] fn normal_lg() { let expr = "lg(x+y)"; test("fi", "ClearSpeak", expr, "l g arvolla, auki sulku x plus y, kiinni sulku"); test_prefs("fi", "ClearSpeak", vec![("Verbosity", "Verbose")], expr, "kymmenkantainen logaritmi arvolla, auki sulku x plus y, kiinni sulku"); } #[test] fn simple_natural_log() { let expr = " lnx "; test_ClearSpeak("fi", "ClearSpeak_Log", "LnAsNaturalLog",expr, "luonnollinen log x"); } #[test] fn natural_log() { let expr = "ln(x+y)"; test_ClearSpeak("fi", "ClearSpeak_Log", "LnAsNaturalLog",expr, "luonnollinen logaritmi arvolla, auki sulku x plus y, kiinni sulku"); } #[test] fn explicit_function_call_with_parens() { let expr = "t(x)"; test("fi", "ClearSpeak", expr, "t arvolla x"); } #[test] fn explicit_times_with_parens() { let expr = "t(x)"; test("fi", "ClearSpeak", expr, "t kertaa x"); } #[test] fn explicit_function_call() { let expr = "tx"; test("fi", "ClearSpeak", expr, "t arvolla x"); } #[test] fn explicit_times() { let expr = "tx"; test("fi", "ClearSpeak", expr, "t x"); } #[test] fn test_functions_none_pref() { let expr = " log(x+y) + f(x+y) "; test_ClearSpeak("fi", "ClearSpeak_Functions", "None",expr, "log arvolla, auki sulku x plus y, kiinni sulku; plus, f kertaa, auki sulku x plus y, kiinni sulku"); } #[test] fn test_functions_none_pref_multiple_args() { let expr = " B ( 2,6 ) "; test_ClearSpeak("fi", "ClearSpeak_Functions", "None",expr, "iso b kertaa, auki sulku 2 pilkku 6, kiinni sulku"); } /* * Tests for times */ #[test] fn no_times_binomial() { let expr = "x y"; test("fi", "ClearSpeak", expr, "x y"); } #[test] fn times_following_paren() { let expr = " 2 ( 3 ) "; test("fi", "ClearSpeak", expr, "2 kertaa 3"); } #[test] fn times_preceding_paren() { let expr = " ( 2 ) 3 "; test("fi", "ClearSpeak", expr, "2 kertaa 3"); } #[test] fn no_times_sqrt() { let expr = " a b = ab "; test("fi", "ClearSpeak", expr, "neliöjuuri a, neliöjuuri b; on yhtä suuri kuin, neliöjuuri a b,"); } #[test] fn more_implied_times() { let expr = " ( 2x ) 2 "; test_ClearSpeak("fi", "ClearSpeak_ImpliedTimes", "MoreImpliedTimes",expr, "auki sulku 2 kertaa x, kiinni sulku toiseen"); } #[test] fn explicit_times_more_implied_times() { let expr = "tx"; test_ClearSpeak("fi", "ClearSpeak_ImpliedTimes", "MoreImpliedTimes",expr, "t kertaa x"); } #[test] fn explicit_times_none_simple_right() { let expr = "2[3 ]"; test_ClearSpeak("fi", "ClearSpeak_ImpliedTimes", "None", expr, "2, auki hakasulku 3 kiinni hakasulku"); } #[test] fn explicit_times_none_simple_left() { let expr = "(21)x"; test_ClearSpeak("fi", "ClearSpeak_ImpliedTimes", "None", expr, "auki sulku 2 miinus 1, kiinni sulku; x"); } #[test] fn explicit_times_none_superscript() { let expr = " f(x)= x 2 ( x+1 ) "; test_ClearSpeak_prefs("fi", vec![("ClearSpeak_ImpliedTimes", "None"), ("ClearSpeak_Functions", "None")], expr, "f, auki sulku x kiinni sulku; on yhtä suuri kuin; x toiseen, auki sulku x plus 1, kiinni sulku"); } /* * Tests for parens */ #[test] fn no_parens_number() { let expr = " ( 25 ) x "; test("fi", "ClearSpeak", expr, "25 kertaa x"); } #[test] fn no_parens_monomial() { let expr = " b ( xy ) "; test("fi", "ClearSpeak", expr, "b x y"); } #[test] fn no_parens_negative_number() { let expr = " 2+ ( 2 ) "; test("fi", "ClearSpeak", expr, "2 plus negatiivinen 2"); } #[test] fn no_parens_negative_number_with_var() { let expr = " ( 2x ) +1 "; test("fi", "ClearSpeak", expr, "negatiivinen 2 x, plus 1"); } #[test] fn parens_superscript() { let expr = " ( 2x ) 2 "; test("fi", "ClearSpeak", expr, "auki sulku 2 x kiinni sulku toiseen"); } #[test] fn no_parens_fraction() { let expr = " 2 + ( 12 ) "; test("fi", "ClearSpeak", expr, "2 plus 1 kahdesosa"); } // Tests for the ten types of intervals in ClearSpeak #[test] fn parens_interval_open_open() { let expr = " ( c,d ) "; test_ClearSpeak("fi", "ClearSpeak_Paren", "Interval",expr, "väli c d, ei sisältäen c tai d"); } #[test] fn parens_interval_closed_open() { let expr = " [ c,d ) "; test_ClearSpeak("fi", "ClearSpeak_Paren", "Interval ",expr, "väli c d, sisältäen c mutta ei sisältäen d"); } #[test] fn parens_interval_open_closed() { let expr = " ( c,d ] "; test_ClearSpeak("fi", "ClearSpeak_Paren", "Interval ",expr, "väli c d, ei sisältäen c mutta sisältäen d"); } #[test] fn parens_interval_closed_closed() { let expr = " [ c,d ] "; test_ClearSpeak("fi", "ClearSpeak_Paren", "Interval ",expr, "väli c d, sisältäen c ja d"); } #[test] fn parens_interval_neg_infinity_open_open() { let expr = " ( - ,d ) "; test_ClearSpeak("fi", "ClearSpeak_Paren", "Interval ",expr, "väli negatiivinen ääretön d, ei sisältäen d"); } #[test] fn parens_interval_neg_infinity_closed_open() { let expr = " ( - ,d ] "; test_ClearSpeak("fi", "ClearSpeak_Paren", "Interval ",expr, "väli negatiivinen ääretön d, sisältäen d"); } #[test] fn parens_interval_open_open_infinity() { let expr = " ( c, ) "; test_ClearSpeak("fi", "ClearSpeak_Paren", "Interval ",expr, "väli c ääretön, ei sisältäen c"); } #[test] fn parens_interval_closed_open_infinity() { let expr = " [ c, ) "; test_ClearSpeak("fi", "ClearSpeak_Paren", "Interval ",expr, "väli c ääretön, sisältäen c"); } #[test] fn parens_interval_neg_infinity_to_infinity() { let expr = " ( - , ) "; test_ClearSpeak("fi", "ClearSpeak_Paren", "Interval ",expr, "väli negatiivinen ääretön ääretön,"); } #[test] fn parens_interval_neg_infinity_to_pos_infinity() { let expr = " ( - ,+ ) "; test_ClearSpeak("fi", "ClearSpeak_Paren", "Interval ",expr, "väli negatiivinen ääretön positiivinen ääretön,"); }