//! North-star E2E for the operator-routing-eq-ord milestone:
//! exercises Eq Unit (new instance), user-ADT Eq Point with a
//! hand-written instance, and nested-Int Eq dispatch — all
//! through the class-method path with no `==` callee anywhere.
//!
//! Today this test fires `NoInstance Eq Unit` at typecheck
//! (Unit lacks an Eq instance), proving RED-first before the
//! milestone lands.

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

#[test]
fn eq_user_adt_smoke_prints_unit_then_point_eq_then_neq() {
    let manifest_dir = env!("CARGO_MANIFEST_DIR");
    let repo_root = PathBuf::from(manifest_dir).join("../..");
    let fixture = repo_root.join("examples/eq_user_adt_smoke.ail");
    let bin = repo_root.join("target/debug/eq_user_adt_smoke_test_bin");

    let build = Command::new(env!("CARGO_BIN_EXE_ail"))
        .arg("build")
        .arg(&fixture)
        .arg("-o")
        .arg(&bin)
        .output()
        .expect("ail build failed to spawn");
    assert!(
        build.status.success(),
        "ail build failed: stderr={}",
        String::from_utf8_lossy(&build.stderr)
    );

    let run = Command::new(&bin)
        .output()
        .expect("binary failed to spawn");
    assert!(run.status.success(), "binary failed: stderr={}", String::from_utf8_lossy(&run.stderr));
    assert_eq!(
        String::from_utf8_lossy(&run.stdout).as_ref(),
        "true\ntrue\nfalse\n",
        "expected Unit-eq then Point-eq then Point-neq"
    );
}
