//! Pin: `(app eq 1.5 1.5)` must fail typecheck with NoInstance
//! Eq Float AND the diagnostic must mention `float_eq` as the
//! explicit alternative. Today the NoInstance fires (per
//! eq_float_noinstance.rs) but `float_eq` is not in the message
//! — the milestone adds that hint.

use std::path::PathBuf;
use std::process::Command;

#[test]
fn eq_float_must_fail_diagnostic_names_float_eq() {
    let manifest_dir = env!("CARGO_MANIFEST_DIR");
    let repo_root = PathBuf::from(manifest_dir).join("../..");
    let fixture = repo_root.join("examples/eq_float_must_fail.ail");

    let out = Command::new(env!("CARGO_BIN_EXE_ail"))
        .arg("check")
        .arg(&fixture)
        .output()
        .expect("ail check failed to spawn");

    assert!(
        !out.status.success(),
        "expected typecheck failure, got success: stdout={}",
        String::from_utf8_lossy(&out.stdout)
    );

    let stderr = String::from_utf8_lossy(&out.stderr);
    assert!(
        stderr.contains("no-instance") && stderr.contains("Float"),
        "expected no-instance diagnostic + Float, got: {stderr}"
    );
    assert!(
        stderr.contains("float_eq"),
        "expected diagnostic to name `float_eq` as the explicit alternative; got: {stderr}"
    );
}
