/// 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("sv", "ClearSpeak", expr, "sinus av x plus cosinus av y plus tangens av z plus sekans av alfa, plus cosekans av fi, plus cotangens av fi"); } #[test] fn hyperbolic_trig_names() { let expr = " sinhx+ coshy+ tanhz+ sechα+ cschϕ+ cothφ "; test("sv", "ClearSpeak", expr, "sinus hyperbolicus av x, plus cosinus hyperbolicus av y, plus tangens hyperbolicus av z, plus sekans hyperbolicus av alfa, plus cosekans hyperbolicus av fi, plus cotangens hyperbolicus av fi"); } #[test] fn inverse_trig() { let expr = "sin-1x"; test("sv", "ClearSpeak", expr, "invers sinus av x"); } #[test] fn inverse_trig_trig_inverse() { let expr = "tan-1x"; test_ClearSpeak("sv", "ClearSpeak_Trig", "TrigInverse",expr, "tangens invers av x"); } #[test] fn inverse_trig_arc() { let expr = "cosh-1x"; test_ClearSpeak("sv", "ClearSpeak_Trig", "ArcTrig",expr, "arc cosinus hyperbolicus av x"); } #[test] fn trig_squared() { let expr = "sin2x"; test("sv", "ClearSpeak", expr, "sinus kvadrat av x"); } #[test] fn trig_cubed() { let expr = "tan3x"; test("sv", "ClearSpeak", expr, "tangens kubik av x"); } #[test] fn trig_fourth() { let expr = "sec4x"; test("sv", "ClearSpeak", expr, "sekans upphöjt till 4, av x"); } #[test] fn trig_power_other() { let expr = "sinh>n-1x"; test("sv", "ClearSpeak", expr, "sinus hyperbolicus upphöjt till n minus 1, av x"); } #[test] fn simple_log() { let expr = " logx "; test("sv", "ClearSpeak", expr, "logg x"); } #[test] fn normal_log() { let expr = "log(x+y)"; test("sv", "ClearSpeak", expr, "logg, vänster-parentes; x plus y; höger-parentes"); } #[test] fn simple_log_with_base() { let expr = " logbx "; test("sv", "ClearSpeak", expr, "logaritmen med bas b av x"); } #[test] fn normal_log_with_base() { let expr = "logb(x+y)"; test("sv", "ClearSpeak", expr, "logaritmen med bas b av, vänster-parentes; x plus y; höger-parentes"); } #[test] fn simple_ln() { let expr = " lnx "; test("sv", "ClearSpeak", expr, "l n x"); } #[test] fn normal_ln() { let expr = "ln(x+y)"; test("sv", "ClearSpeak", expr, "l n, vänster-parentes; x plus y; höger-parentes"); } #[test] fn simple_natural_log() { let expr = " lnx "; test_ClearSpeak("sv", "ClearSpeak_Log", "LnAsNaturalLog",expr, "naturliga logaritmen x"); } #[test] fn natural_log() { let expr = "ln(x+y)"; test_ClearSpeak("sv", "ClearSpeak_Log", "LnAsNaturalLog",expr, "naturliga logaritmen, vänster-parentes; x plus y; höger-parentes"); } #[test] fn explicit_function_call_with_parens() { let expr = "t(x)"; test("sv", "ClearSpeak", expr, "t av x"); } #[test] fn explicit_times_with_parens() { let expr = "t(x)"; test("sv", "ClearSpeak", expr, "t gånger x"); } #[test] fn explicit_function_call() { let expr = "tx"; test("sv", "ClearSpeak", expr, "t av x"); } #[test] fn explicit_times() { let expr = "tx"; test("sv", "ClearSpeak", expr, "t x"); } #[test] fn test_functions_none_pref() { let expr = " log(x+y) + f(x+y) "; test_ClearSpeak("sv", "ClearSpeak_Functions", "None",expr, "logg, vänster-parentes; x plus y; höger-parentes; plus; f gånger, vänster-parentes; x plus y; höger-parentes"); } #[test] fn test_functions_none_pref_multiple_args() { let expr = " B ( 2,6 ) "; test_ClearSpeak("sv", "ClearSpeak_Functions", "None",expr, "versal b gånger, vänster-parentes; 2 komma 6; höger-parentes"); } /* * Tests for times */ #[test] fn no_times_binomial() { let expr = "x y"; test("sv", "ClearSpeak", expr, "x y"); } #[test] fn times_following_paren() { let expr = " 2 ( 3 ) "; test("sv", "ClearSpeak", expr, "2 gånger 3"); } #[test] fn times_preceding_paren() { let expr = " ( 2 ) 3 "; test("sv", "ClearSpeak", expr, "2 gånger 3"); } #[test] fn no_times_sqrt() { let expr = " a b = ab "; test("sv", "ClearSpeak", expr, "kvadratroten ur a; kvadratroten ur b; lika med, kvadratroten ur a b,"); } #[test] fn more_implied_times() { let expr = " ( 2x ) 2 "; test_ClearSpeak("sv", "ClearSpeak_ImpliedTimes", "MoreImpliedTimes",expr, "vänster-parentes; 2 gånger x; höger-parentes kvadrat"); } #[test] fn explicit_times_more_implied_times() { let expr = "tx"; test_ClearSpeak("sv", "ClearSpeak_ImpliedTimes", "MoreImpliedTimes",expr, "t gånger x"); } #[test] fn explicit_times_none_simple_right() { let expr = "2[3 ]"; test_ClearSpeak("sv", "ClearSpeak_ImpliedTimes", "None", expr, "2, start hak-parentes, 3, slut hak-parentes"); } #[test] fn explicit_times_none_simple_left() { let expr = "(21)x"; test_ClearSpeak("sv", "ClearSpeak_ImpliedTimes", "None", expr, "vänster-parentes; 2 minus 1; höger-parentes; x"); } #[test] fn explicit_times_none_superscript() { let expr = " f(x)= x 2 ( x+1 ) "; test_ClearSpeak_prefs("sv", vec![("ClearSpeak_ImpliedTimes", "None"), ("ClearSpeak_Functions", "None")], expr, "f, vänster-parentes, x, höger-parentes; lika med; x kvadrat, vänster-parentes; x plus 1; höger-parentes"); } /* * Tests for parens */ #[test] fn no_parens_number() { let expr = " ( 25 ) x "; test("sv", "ClearSpeak", expr, "25 gånger x"); } #[test] fn no_parens_monomial() { let expr = " b ( xy ) "; test("sv", "ClearSpeak", expr, "b x y"); } #[test] fn no_parens_negative_number() { let expr = " 2+ ( 2 ) "; test("sv", "ClearSpeak", expr, "2 plus minus 2"); } #[test] fn no_parens_negative_number_with_var() { let expr = " ( 2x ) +1 "; test("sv", "ClearSpeak", expr, "minus 2 x plus 1"); } #[test] fn parens_superscript() { let expr = " ( 2x ) 2 "; test("sv", "ClearSpeak", expr, "vänster-parentes; 2 x; höger-parentes kvadrat"); } #[test] fn no_parens_fraction() { let expr = " 2 + ( 12 ) "; test("sv", "ClearSpeak", expr, "2 plus, en halv"); } // Tests for the ten types of intervals in ClearSpeak #[test] fn parens_interval_open_open() { let expr = " ( c,d ) "; test_ClearSpeak("sv", "ClearSpeak_Paren", "Interval",expr, "det öppna intervallet från c till d"); } #[test] fn parens_interval_closed_open() { let expr = " [ c,d ) "; test_ClearSpeak("sv", "ClearSpeak_Paren", "Interval ",expr, "det halvöppna intervallet från och med c till d"); } #[test] fn parens_interval_open_closed() { let expr = " ( c,d ] "; test_ClearSpeak("sv", "ClearSpeak_Paren", "Interval ",expr, "det halvöppna intervallet från c till och med d"); } #[test] fn parens_interval_closed_closed() { let expr = " [ c,d ] "; test_ClearSpeak("sv", "ClearSpeak_Paren", "Interval ",expr, "det slutna intervallet från c till d"); } #[test] fn parens_interval_neg_infinity_open_open() { let expr = " ( - ,d ) "; test_ClearSpeak("sv", "ClearSpeak_Paren", "Interval ",expr, "det öppna intervallet från minus oändligheten till d"); } #[test] fn parens_interval_neg_infinity_closed_open() { let expr = " ( - ,d ] "; test_ClearSpeak("sv", "ClearSpeak_Paren", "Interval ",expr, "det halvöppna intervallet från minus oändligheten till och med d"); } #[test] fn parens_interval_open_open_infinity() { let expr = " ( c, ) "; test_ClearSpeak("sv", "ClearSpeak_Paren", "Interval ",expr, "det öppna intervallet från c till oändligheten"); } #[test] fn parens_interval_closed_open_infinity() { let expr = " [ c, ) "; test_ClearSpeak("sv", "ClearSpeak_Paren", "Interval ",expr, "det halvöppna intervallet från och med c till oändligheten"); } #[test] fn parens_interval_neg_infinity_to_infinity() { let expr = " ( - , ) "; test_ClearSpeak("sv", "ClearSpeak_Paren", "Interval ",expr, "det öppna intervallet från minus oändligheten till oändligheten"); } #[test] fn parens_interval_neg_infinity_to_pos_infinity() { let expr = " ( - ,+ ) "; test_ClearSpeak("sv", "ClearSpeak_Paren", "Interval ",expr, "det öppna intervallet från minus oändligheten till plus oändligheten"); }