/// Tests for fractions /// includes simple fractions and more complex fractions /// also tests mixed fractions (implicit and explicit) use crate::common::*; #[test] fn common_fraction_half() { let expr = " 1 2 "; test("en", "SimpleSpeak", expr, "1 half"); } #[test] fn common_fraction_thirds() { let expr = " 2 3 "; test("en", "SimpleSpeak", expr, "2 thirds"); } #[test] fn common_fraction_tenths() { let expr = " 17 10 "; test("en", "SimpleSpeak", expr, "17 tenths"); } #[test] #[allow(non_snake_case)] fn not_SimpleSpeak_common_fraction_tenths() { let expr = " 89 10 "; test("en", "SimpleSpeak", expr, "89 over 10,"); } #[test] fn non_simple_fraction() { let expr = " x+y x-y "; test("en", "SimpleSpeak", expr, "fraction, x plus y, over, x minus y, end fraction;"); } #[test] fn nested_fraction() { let expr = " x+ 1y x-y "; test("en", "SimpleSpeak", expr, "fraction, x plus, fraction, 1 over y, end fraction; over, x minus y, end fraction;"); } #[test] fn deeply_nested_fraction_msqrt() { let expr = " x+ 1y x-y "; test("en", "SimpleSpeak", expr, "fraction, x plus, the square root of 1 over y, end root; over, x minus y, end fraction;"); } #[test] fn deeply_nested_fraction_mrow_msqrt() { let expr = " x+ 2+1y x-y "; test("en", "SimpleSpeak", expr, "fraction, x plus, the square root of 2 plus 1 over y, end root; over, x minus y, end fraction;"); } #[test] fn numerator_simple_fraction() { let expr = " x x-y "; test("en", "SimpleSpeak", expr, "fraction, x over, x minus y, end fraction;"); } #[test] fn denominator_simple_fraction() { let expr = " x-y x "; test("en", "SimpleSpeak", expr, "fraction, x minus y, over x, end fraction;"); } #[test] fn mixed_number() { let expr = " 3 1 2 "; test("en", "SimpleSpeak", expr, "3 and 1 half"); } #[test] fn explicit_mixed_number() { let expr = " 3 1 8 "; test("en", "SimpleSpeak", expr, "3 and 1 eighth"); } #[test] fn mixed_number_big() { let expr = " 3 7 83 "; test("en", "SimpleSpeak", expr, "3 and 7 eighty thirds"); } #[test] fn simple_text() { let expr = " rise run "; test("en", "SimpleSpeak", expr, "rise over run,"); } #[test] fn number_and_text() { let expr = " 2miles 3gallons "; test("en", "SimpleSpeak", expr, "fraction, 2 miles, over, 3 gallons, end fraction;"); } #[test] fn nested_simple_fractions() { let expr = " 1 2 2 3 "; test("en", "SimpleSpeak", expr, "fraction, 1 half, over, 2 thirds, end fraction;"); } #[test] fn binomial() { let expr = " 2 ( 7 3 ) "; test("en", "SimpleSpeak", expr, "2 times 7 choose 3"); }