/// Tests for rules shared between various speech styles:
/// *  this has tests focused on the various alphabets
use crate::common::*;
use anyhow::Result;


// AI generated
#[test]
fn silent_intent() -> Result<()> {
    let expr = "<math> <mrow intent='teszteljük:silent($arg1, $arg2)'><mn arg='arg1'>2</mn> <mi arg='arg2'>x</mi></mrow> </math>";
    test("hu", "SimpleSpeak", expr, "2 x")?;
    test("hu", "LiteralSpeak", expr, "2 x")?;
    return Ok(());

}

#[test]
fn silent_intent_underscore() -> Result<()> {
    let expr = "<math>
        <msup intent='_($H,$n)'>
            <mi arg='H' mathvariant='normal'>H</mi>
            <mn arg='n'>2</mn>
        </msup></math>";
    test("hu", "SimpleSpeak", expr, "nagy h vessző, 2")?;
    test("hu", "ClearSpeak", expr, "nagy h vessző, 2")?;
    return Ok(());

}

#[test]
fn intent_prob_x() -> Result<()> {
    //init_logger();
    let expr = "<math>
    <msup intent='$op($arg)'>
        <mi arg='arg'>x</mi>
        <mi arg='op' intent='valószínűség' mathvariant='normal'>P</mi>
    </msup></math>";
    test("hu", "ClearSpeak", expr, "valószínűség x")?;
    return Ok(());

}

// AI generated
#[test]
fn prefix_intent() -> Result<()> {
    let expr = r#"<math><msup intent='tesztelés:prefix($x)'> <mi arg='x'>x</mi> <mi>T</mi> </msup> </math>"#;
    test("hu", "SimpleSpeak", expr, "tesztelés x")?;
    return Ok(());

}

// AI generated
#[test]
fn postfix_intent() -> Result<()> {
    let expr = r#"<math><msup intent='tesztelése:postfix($x)'> <mi arg='x'>x</mi> <mi>T</mi> </msup> </math>"#;
    test("hu", "SimpleSpeak", expr, "x tesztelése")?;
    return Ok(());

}

// AI generated
#[test]
fn infix_intent() -> Result<()> {
    let expr = r#"<math><mrow intent='tesztelés:infix($x, $y, $z, 2)'>
        <mi arg='x'>x</mi>
        <mi arg='y'>y</mi>
        <mi arg='z'>z</mi>
    </mrow> </math>"#;
    test("hu", "SimpleSpeak", expr, "x tesztelés y tesztelés z tesztelés 2")?;
    return Ok(());

}

// AI generated
#[test]
fn infix_intent_no_args() -> Result<()> {
    // this is illegal intent, so it is just an mrow with one child
    let expr = r#"<math><mrow intent='teszteljük:infix()'>
        <mi arg='x'>x</mi>
    </mrow> </math>"#;
    test("hu", "SimpleSpeak", expr, "x")?;
    return Ok(());

}

// AI generated
#[test]
fn infix_intent_one_arg() -> Result<()> {
    let expr = r#"<math><mrow intent='teszteljük:infix($x)'>
        <mi arg='x'>x</mi>
    </mrow> </math>"#;
    // Note: we say the intent name because there are infix plus/minus with a single arg due to continued rows or combined columns
    test("hu", "SimpleSpeak", expr, "teszteljük x")?;
    return Ok(());

}

// AI generated
#[test]
fn function_intent() -> Result<()> {
    let expr = r#"<math><mrow intent='teszteljük:function($x, $y, $z, 2)'>
        <mi arg='x'>x</mi>
        <mi arg='y'>y</mi>
        <mi arg='z'>z</mi>
    </mrow> </math>"#;
    test("hu", "SimpleSpeak", expr, "teszteljük x vessző, y vessző, z vessző, 2")?;
    return Ok(());

}

// AI generated
#[test]
fn function_no_args_intent() -> Result<()> {
    // this is illegal intent, so it is just an mrow with one child
    let expr = r#"<math><mrow intent='teszteljük:function()'>
        <mi arg='x'>x</mi>
    </mrow> </math>"#;
    test("hu", "SimpleSpeak", expr, "x")?;
    return Ok(());

}

// AI generated
#[test]
fn function_one_arg_intent() -> Result<()> {
    let expr = r#"<math><mrow intent='teszteljük:function($x)'>
        <mi arg='x'>x</mi>
    </mrow> </math>"#;
    test("hu", "SimpleSpeak", expr, "teszteljük x")?;
    return Ok(());

}

// AI generated
#[test]
fn silent_intent_mi() -> Result<()> {
    let expr = "<math> <mn>2</mn> <mi intent=':silent'>x</mi></math>";
    test("hu", "SimpleSpeak", expr, "2")?;
    test("hu", "ClearSpeak", expr, "2")?;
    return Ok(());

}

// AI generated
#[test]
fn silent_intent_msup() -> Result<()> {
    let expr = "<math>
        <msup intent='index:silent($H,$n)'>
            <mi arg='H' mathvariant='normal'>H</mi>
            <mn arg='n'>2</mn>
        </msup></math>";
    test("hu", "SimpleSpeak", expr, "nagy h 2")?;
    test("hu", "ClearSpeak", expr, "nagy h 2")?;
    return Ok(());

}
