// Tests based on the Finnish flavor of ASCIIMath located on the Finnish delegation for braille's "Matematiikan, fysiikan ja kemian merkinnät elektronisissa oppikirjoissa" (https://www.pistekirjoitus.fi/julkaisut/matematiikka-ja-tietotekniikka/). // Tests will be named according to the page and some identification. use crate::common::*; #[test] fn p12_equal () { let expr = r#"3+4=7"#; test_braille("ASCIIMath-fi", expr, r"3 +4 =7"); } #[test] fn p12_not_equal () { let expr = r#"522"#; test_braille("ASCIIMath-fi", expr, r"5 -2 !=2"); } #[test] fn p12_opposite () { let expr = r#"935"#; test_braille("ASCIIMath-fi", expr, r"9 -3 != 5"); } #[test] fn p12_multiplication_visible_op () { let expr = r#"27·3"#; test_braille("ASCIIMath-fi", expr, r"27 *3"); } #[test] fn p12_simple_frac () { let expr = r#"13"#; test_braille("ASCIIMath-fi", expr, r"1/3"); } #[test] fn p12_ratio () { let expr = r#"1:1000"#; test_braille_prefs("ASCIIMath-fi", expr, r"1 :1000"); } #[test] fn p12_fractional () { let expr = r#"6x+3x6x4x"#; test_braille("ASCIIMath-fi", expr, r"(6 x +3 x) /(6 x -4 x)"); } #[test] fn p12_absolute_value_eq () { let expr = r#"|(2+5)|=|−7|=7"#; test_braille("ASCIIMath-fi", expr, r"|-(2 +5)| =|-7| =7"); } #[test] fn p12_natural_numbers () { let expr = r#"={1,2,3}"#; test_braille("ASCIIMath-fi", expr, r"NN ={0, 1, 2, 3, ...}"); } #[test] fn p12_whole_numbers () { let expr = r#"={,2,1,0,1,2,}"#; test_braille("ASCIIMath-fi", expr, r"ZZ ={..., -2, 1, 0, 1, 2, ...}"); } #[test] fn p13_pi () { let expr = r#"π3,14"#; test_braille_prefs("ASCIIMath", vec![("DecimalSeparators", ","), ("BlockSeparators", ". ")], expr, r"~p ~~3,14"); } #[test] fn p13_less_than () { let expr = r#"x<18"#; test_braille("ASCIIMath-fi", expr, r"x < 18"); } #[test] fn p13_greater_or_equal () { let expr = r#"2x6"#; test_braille("ASCIIMath-fi", expr, r"2 x >= 6"); } #[test] fn p13_fraction_with_invisible_plus () { let expr = r#"356"#; test_braille("ASCIIMath-fi", expr, r"3#5/6"); } #[test] fn p13_fraction_without_invisible_plus () { let expr = r#"356"#; test_braille("ASCIIMath-fi", expr, r"3#5/6"); } #[test] fn p13_fractional_no_paren () { // The numerator doesn't require parentheses to be read correctly. let expr = r#"4x(1x)"#; test_braille("ASCIIMath-fi", expr, r"4 x /(1 -x)"); } #[test] fn p13_fractional () { let expr = r#"5+x5x"#; test_braille("ASCIIMath-fi", expr, r"(5 +x) /(5 x)"); } #[test] fn p13_fractional_simplifying_with_paren () { let expr = r#"5+72·3=126"#; test_braille("ASCIIMath-fi", expr, r"(5 +7) /(2 *3) =12 /6"); } #[test] fn p14_long_fractional () { let expr = r#"x27x+124x20x28x+154x16"#; test_braille("ASCIIMath-fi", expr, r"((x^2 -7 x +12) /(4 x -20)) /((x^2 -8 x +15) /(4 x -16))"); } #[test] fn p15_exponent_plus () { let expr = r#"32+42"#; test_braille("ASCIIMath-fi", expr, r"3^2 +4^2"); } #[test] fn p15_exponent_with_negative_base_in_paren () { let expr = r#"(2)2"#; test_braille("ASCIIMath-fi", expr, r"(-2)^2"); } #[test] fn p15_exponent_with_plus_equation () { let expr = r#"23+5"#; test_braille("ASCIIMath-fi", expr, r"2^(3 +5)"); } #[test] fn p16_sqrt () { let expr = r#"25"#; test_braille("ASCIIMath-fi", expr, r"sqrt(25)"); } #[test] fn p16_root3 () { let expr = r#"273"#; test_braille("ASCIIMath-fi", expr, r"root3(27)"); } #[test] fn p16_root_equation () { let expr = r#"325+16"#; test_braille("ASCIIMath-fi", expr, r"root5(32) +root6(1)"); } #[test] fn p18_tangent_90_degrees_infinity () { let expr = r#"tan⁡(90°)="#; test_braille("ASCIIMath-fi", expr, r"tan 90^@ =oo"); } #[test] fn p18_degrees () { let expr = r#"90°"#; test_braille("ASCIIMath-fi", expr, r"90 ^@"); } #[test] fn p18_cosines () { let expr = r#"cos2⁡⁡x2cos⁡⁡x+1=0 "#; test_braille("ASCIIMath-fi", expr, r"cos^2 x -2 cos x +1 =0"); } #[test] fn p19_vector_with_line () { let expr = r#"OB¯"#; test_braille("ASCIIMath-fi", expr, r"vec OB"); } #[test] fn p19_vector_with_arrow () { let expr = r#"OB"#; test_braille("ASCIIMath-fi", expr, r"vec OB"); } #[test] fn p19_vector_projection () { let expr = r#"a¯b"#; test_braille("ASCIIMath-fi", expr, r"vec a_b"); } #[test] fn p19_unit_vector () { let expr = r#"a¯0"#; test_braille("ASCIIMath-fi", expr, r"vec a^0"); } #[test] fn p19_vector_dot_product () { // Notice that dot product (middle dot) in vectors has space around the dot. let expr = r#"a¯·b¯"#; test_braille("ASCIIMath-fi", expr, r"vec a * vec b"); } #[test] fn p19_vector_cross_product () { let expr = r#"a¯×b¯"#; test_braille("ASCIIMath-fi", expr, r"vec a xx vec b"); } #[test] fn p20_pair_of_equations () { let expr = r#"a¯×b¯"#; test_braille("ASCIIMath-fi", expr, r"{2 x +y =0, x -y =5}"); } #[test] fn p22_belongs_to_a_set () { let expr = r#"xA"#; test_braille("ASCIIMath-fi", expr, r"x in A"); } #[test] fn p22_does_not_belong_to_a_set () { let expr = r#"3B"#; test_braille("ASCIIMath-fi", expr, r"3 !in B"); } #[test] fn p22_subset_right () { let expr = r#"AB"#; test_braille("ASCIIMath-fi", expr, r"A sub B"); } #[test] fn p22_subset_left () { let expr = r#"BA"#; test_braille("ASCIIMath-fi", expr, r"B sup A"); } #[test] fn p22_not_subset () { let expr = r#"AB"#; test_braille("ASCIIMath-fi", expr, r"B !sup A"); } #[test] fn p22_union () { let expr = r#"AB={a,b,c}"#; test_braille("ASCIIMath-fi", expr, r"A uu B ={a, b, c}"); } #[test] fn p22_intersection_empty_set () { let expr = r#"AB="#; test_braille("ASCIIMath-fi", expr, r"G nn H =O"); } #[test] fn p22_negation () { let expr = r#"¬p"#; test_braille("ASCIIMath-fi", expr, r"not p"); } #[test] fn p23_logical_and () { let expr = r#"pq"#; test_braille("ASCIIMath-fi", expr, r"p ^^ q"); } #[test] fn p23_logical_or () { let expr = r#"pq"#; test_braille("ASCIIMath-fi", expr, r"p vv q"); } #[test] fn p23_logical_implication () { let expr = r#"pq"#; test_braille("ASCIIMath-fi", expr, r"p --> q"); } #[test] fn p23_function_definition () { let expr = r#"f:xf(x)"#; test_braille("ASCIIMath-fi", expr, r"f: x -> f(x)"); } #[test] fn p23_4x4_matrix () { let expr = r#" ( 1 0 0 1 0 1 0 0 0 0 1 0 1 0 0 1 ) "#; test_braille("ASCIIMath-fi", expr, r"((1 0 0 1), (0 1 0 0), (0 0 1 0), (1 0 0 1))"); } #[test] fn p24_function_definition () { let expr = r#" | a + b a - b a - b a + b | "#; test_braille("ASCIIMath-fi", expr, r"|(a +b, a -b), (a -b, a +b)|"); } #[test] fn p25_binomial () { // original display code contains forced spaces not in the output -- they are cleaned up here let expr = r#" ( nk ) "#; test_braille("ASCIIMath-fi", expr, r"((n), (k))"); } #[test] fn p25_factorial () { let expr = r#"5!"#; test_braille("ASCIIMath-fi", expr, r"5!"); } #[test] fn p25_conditional_probability () { let expr = r#"P(A|B)"#; test_braille("ASCIIMath-fi", expr, r"P(A | B)"); } #[test] fn p25_x_average () { // This might prove to be wrong mark up, but this way there won't be mix up with vectors. let expr = r#"x¯"#; test_braille("ASCIIMath-fi", expr, r"bar x"); } #[test] fn p26_expected_value () { // This might prove to be wrong mark up, but this way there won't be mix up with vectors. let expr = r#"E(X)=μ=i(pixi)"#; test_braille("ASCIIMath-fi", expr, r"E(X) =~m =sum_i (p_i x_i)"); } #[test] fn p26_msubsup () { let expr = r#"Ckn"#; test_braille("ASCIIMath-fi", expr, r"(C_k)^n"); } #[test] fn p26_derivation_fraction () { // This might prove difficult, because of contradictory mark up in asciimath. If special case can't be coded, then this should regular rules for fractions and multiplication with variables. let expr = r#"df(x)dx"#; test_braille("ASCIIMath-fi", expr, r"df(x)/dx"); } #[test] fn p26_derivation_prime_regular () { // The ' doesn't have to be escaped, right? The r(aw string) does it already. let expr = r#"f'(x)"#; test_braille("ASCIIMath-fi", expr, r"f'(x)"); } #[test] fn p26_derivation_prime_alternative () { // The ' doesn't have to be escaped, right? The r(aw string) does it already. let expr = r#"f(x)"#; test_braille("ASCIIMath-fi", expr, r"f'(x)"); } #[test] fn p26_derivation_prime_2_alternative () { // The ' doesn't have to be escaped, right? The r(aw string) does it already. let expr = r#"f(x)"#; test_braille("ASCIIMath-fi", expr, r"f''(x)"); } #[test] fn p26_derivation_cap_d () { // Should there be an operator between D and f? Which one? Another question is that is D an operator or not? Here it is marked up as such. let expr = r#"Df(x)"#; test_braille("ASCIIMath-fi", expr, r"Df(x)"); } #[test] fn p26_derivation_cap_d_to_two () { // Notice whitespace after D^2, compared to p26_derication_cap_d let expr = r#"D2f(x)"#; test_braille("ASCIIMath-fi", expr, r"D^2 f(x)"); } #[test] fn p26_partial_derivatives () { let expr = r#"𝜕y𝜕x"#; test_braille("ASCIIMath-fi", expr, r"del y /(del x)"); } #[test] fn p26_gradient () { let expr = r#"f"#; test_braille("ASCIIMath-fi", expr, r"grad f"); } #[test] fn p26_gradients_with_space () { let expr = r#"fg"#; test_braille("ASCIIMath-fi", expr, r"grad f grad g"); } #[test] fn p26_inverse_function () { let expr = r#" f 1 = { ( y , x ) B × A | y = f ( x ) } "#; test_braille("ASCIIMath-fi", expr, r"f^-1 ={(y, x) in (B xx A) | y =f(x)}"); } #[test] fn p26_lg() { let expr = r#" lg ( 5 a ) = lg a + lg 5 "#; test_braille("ASCIIMath-fi", expr, r"lg (5 a) =lg a +lg 5"); } #[test] fn p26_log_additional() { let expr = r#" log ( 5 a ) = log a + log 5 "#; test_braille("ASCIIMath-fi", expr, r"log (5 a) =log a +log 5"); } #[test] fn p26_limit_from_positive_side() { let expr = r#" lim x 0 + = f ( x ) "#; test_braille("ASCIIMath-fi", expr, r"lim_(x -> 0 +) f(x)"); } #[test] fn p26_limit_of_fractional() { let expr = r#" lim x 1 x 4 x x 4 1 "#; test_braille("ASCIIMath-fi", expr, r"lim_(x -> 1) [(x^4 -x) /(x^4 -1)]"); } #[test] fn p26_simple_integral() { // Should the integrals 'dx' be in one or two? let expr = r#" x 2 dx "#; test_braille("ASCIIMath-fi", expr, r"int x^2 dx"); } #[test] fn p26_integral_with_bounds() { let expr = r#" π 2 π tan 2 x dx "#; test_braille("ASCIIMath-fi", expr, r"int x^2 dx"); } #[test] fn p26_sum() { let expr = r#" i = 0 n ( f i x i ) "#; test_braille("ASCIIMath-fi", expr, r"int x^2 dx"); } #[test] fn p26_sequence() { let expr = r#" ( x n ) n = 1 "#; test_braille("ASCIIMath-fi", expr, r"(x_n)_(n =1)^oo"); } #[test] fn p27_follows_normal_distribution() { let expr = r#" p ~ N ( 58 , 2 ) "#; test_braille("ASCIIMath-fi", expr, r"p ~ N(58, 2)"); } #[test] fn p27_quadratic_formula() { let expr = r#" x = - b ± b2-4ac 2a "#; test_braille("ASCIIMath-fi", expr, r"x =(-b +-sqrt(b^2 -4 a c)) /(2 a)"); } #[test] fn p35_atomic_numbers() { let expr = r#" 92 232 U "#; test_braille("ASCIIMath-fi", expr, r"_92^232U"); } #[test] fn p34_chem_single_bond_colon() { let expr = r#"C:C"#; test_braille("ASCIIMath-fi", expr, r"C;C"); } #[test] fn p34_chem_single_bond_dash() { let expr = r#"C-C"#; test_braille("ASCIIMath-fi", expr, r"C;C"); } #[test] fn p34_chem_double_bond_equal_sign() { let expr = r#"C=C"#; test_braille("ASCIIMath-fi", expr, r"C=C"); } #[test] fn p34_chem_double_bond_double_colon() { let expr = r#"C::C"#; test_braille("ASCIIMath-fi", expr, r"C=C"); } #[test] fn p34_chem_triple_bond() { let expr = r#"CC"#; test_braille("ASCIIMath-fi", expr, r"C;=C"); } #[test] fn p34_H2O() { let expr = r#"H2O"#; test_braille("ASCIIMath-fi", expr, r"H_2O"); } #[test] fn p34_2NH_3() { let expr = r#"2NH3"#; test_braille("ASCIIMath-fi", expr, r"2 NH_3"); } #[test] fn p34_K_2Cr_2O_7() { let expr = r#"K2Cr2O7"#; test_braille("ASCIIMath-fi", expr, r"K_2Cr_2O_7"); } #[test] fn p34_Na_2CO_3_times_10H_2O() { let expr = r#"Na2Co3·10H2O"#; test_braille("ASCIIMath-fi", expr, r"Na_2CO_3 *10 H_2O"); } #[test] fn p34_Na_plus() { let expr = r#"Na+"#; test_braille("ASCIIMath-fi", expr, r"Na^+"); } #[test] fn p34_Cu_to_2_plus() { let expr = r#"Cu2+"#; test_braille("ASCIIMath-fi", expr, r"Cu^(2 +)"); } #[test] fn p35_Mg_S_chemical_equation() { let expr = r#" Mg+S Mg 2+ + S 2+ "#; test_braille("ASCIIMath-fi", expr, r"Mg +S -> Mg^(2 +) +S^(2 -)"); } #[test] fn p34_Cu_to_2_plus() { let expr = r#"Ag+ S+ AgCl"#; test_braille("ASCIIMath-fi", expr, r"Ag^+ +Cl^- -> AgCl"); } #[test] fn chem_equations_with_states() { let expr = r#" 2 H Cl ( aq ) + 2 Na ( s ) 2 Na Cl ( aq ) + H A 2 ( g ) "#; test_braille("ASCIIMath-fi", expr, r"2 HCl (aq) +2 Na (s) -> 2 NaCl (aq) +H_2 (g)"); } #[test] fn p34_chem_text_over_arrow() { let expr = r#" CaCo3(s) kuumennus CaO(s)+CO2(g) "#; test_braille("ASCIIMath-fi", expr, r"CaCO_3 (s) -> kuumennus -> CaO (s) +CO_2 (g)"); } #[test] fn some_greek_letters () { let expr = r#"α,β,γ,δ,ε"#; test_braille("ASCIIMath-fi", expr, r"~a, ~b, ~g, ~d, ~e"); }