/// 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", "SimpleSpeak", 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", "SimpleSpeak", 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", "SimpleSpeak", expr, "invers sinus av x"); } #[test] fn trig_squared() { let expr = "sin2x"; test("sv", "SimpleSpeak", expr, "sinus kvadrat av x"); } #[test] fn trig_cubed() { let expr = "tan3x"; test("sv", "SimpleSpeak", expr, "tangens kubik av x"); } #[test] fn trig_fourth() { let expr = "sec4x"; test("sv", "SimpleSpeak", expr, "sekans upphöjt till 4, av x"); } #[test] fn trig_power_other() { let expr = "sinh>n-1x"; test("sv", "SimpleSpeak", expr, "sinus hyperbolicus upphöjt till n minus 1, av x"); } #[test] fn simple_log() { let expr = " logx "; test("sv", "SimpleSpeak", expr, "logg x"); } #[test] fn normal_log() { let expr = "log(x+y)"; test("sv", "SimpleSpeak", expr, "logg av, vänster-parentes; x plus y; höger-parentes"); } #[test] fn simple_log_with_base() { let expr = " logbx "; test("sv", "SimpleSpeak", expr, "logaritmen med bas b av x"); } #[test] fn normal_log_with_base() { let expr = "logb(x+y)"; test("sv", "SimpleSpeak", expr, "logaritmen med bas b av, vänster-parentes; x plus y; höger-parentes"); } #[test] fn simple_ln() { let expr = " lnx "; test("sv", "SimpleSpeak", expr, "l n x"); } #[test] fn normal_ln() { let expr = "ln(x+y)"; test("sv", "SimpleSpeak", expr, "naturliga logaritmen av, vänster-parentes; x plus y; höger-parentes"); } #[test] fn normal_ln_terse() { let expr = "ln(x+y)"; test_prefs("sv", "SimpleSpeak", vec![("Verbosity", "Terse")], expr, "l n av, start-parentes; x plus y; slut-parentes"); } #[test] fn simple_ln_terse() { let expr = " lnx "; test_prefs("sv", "SimpleSpeak", vec![("Verbosity", "Terse")], expr, "l n x"); } #[test] fn explicit_function_call_with_parens() { let expr = "t(x)"; test("sv", "SimpleSpeak", expr, "t av x"); } #[test] fn explicit_times_with_parens() { let expr = "t(x)"; test("sv", "SimpleSpeak", expr, "t gånger x"); } #[test] fn explicit_function_call() { let expr = "tx"; test("sv", "SimpleSpeak", expr, "t av x"); } #[test] fn explicit_times() { let expr = "tx"; test("sv", "SimpleSpeak", expr, "t x"); } /* * Tests for times */ #[test] fn no_times_binomial() { let expr = "x y"; test("sv", "SimpleSpeak", expr, "x y"); } #[test] fn times_following_paren() { let expr = " 2 ( 3 ) "; test("sv", "SimpleSpeak", expr, "2 gånger 3"); } #[test] fn times_preceding_paren() { let expr = " ( 2 ) 3 "; test("sv", "SimpleSpeak", expr, "2 gånger 3"); } #[test] fn no_times_sqrt() { let expr = " a b = ab "; test("sv", "SimpleSpeak", expr, "kvadratroten ur a; kvadratroten ur b; lika med, kvadratroten ur a b slut rot,"); } /* * Tests for parens */ #[test] fn no_parens_number() { let expr = " ( 25 ) x "; test("sv", "SimpleSpeak", expr, "25 gånger x"); } #[test] fn no_parens_monomial() { let expr = " b ( xy ) "; test("sv", "SimpleSpeak", expr, "b x y"); } #[test] fn no_parens_negative_number() { let expr = " 2+ ( 2 ) "; test("sv", "SimpleSpeak", expr, "2 plus minus 2"); } #[test] fn no_parens_negative_number_with_var() { let expr = " ( 2x ) +1 "; test("sv", "SimpleSpeak", expr, "minus 2 x plus 1"); } #[test] fn parens_superscript() { let expr = " ( 2x ) 2 "; test("sv", "SimpleSpeak", expr, "vänster-parentes; 2 x; höger-parentes kvadrat"); } #[test] fn no_parens_fraction() { let expr = " 2 + ( 12 ) "; test("sv", "SimpleSpeak", expr, "2 plus en halv"); } // Tests for the four types of intervals in SimpleSpeak #[test] fn parens_interval_open_open() { let expr = " ( (c,d) ) "; test("sv", "SimpleSpeak",expr, "det öppna intervallet från c till d"); } #[test] fn parens_interval_closed_open() { let expr = " [ [(]c,d) ) "; test("sv", "SimpleSpeak",expr, "det halvöppna intervallet från och med c till d"); } #[test] fn parens_interval_open_closed() { let expr = " ( (c,d] ] "; test("sv", "SimpleSpeak",expr, "det halvöppna intervallet från c till och med d"); } #[test] fn parens_interval_closed_closed() { let expr = " [ [(]c,d] ] "; test("sv", "SimpleSpeak",expr, "det slutna intervallet från c till d"); } #[test] fn parens_interval_neg_infinity_open_open() { let expr = " ( - ,d) ) "; test("sv", "SimpleSpeak",expr, "det öppna intervallet från minus oändligheten till d"); } #[test] fn parens_interval_neg_infinity_open_closed() { let expr = " ( - ,d] ] "; test("sv", "SimpleSpeak",expr, "det halvöppna intervallet från minus oändligheten till och med d"); }