//! Pin: the operator names `==` / `!=` / `<` / `<=` / `>` / `>=`
//! are NOT part of the language. Surface use of any of them must
//! resolve as `unknown variable: ==` (et al.). Today they all
//! typecheck (== polymorphic, the others monomorphic-Int) —
//! RED-first.

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

#[test]
fn comparator_operator_name_is_unbound() {
    let manifest_dir = env!("CARGO_MANIFEST_DIR");
    let repo_root = PathBuf::from(manifest_dir).join("../..");
    let fixture = repo_root.join("examples/operator_unbound_check.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 for `(app == 5 5)`; got success: stdout={}",
        String::from_utf8_lossy(&out.stdout)
    );

    let stderr = String::from_utf8_lossy(&out.stderr);
    assert!(
        stderr.contains("unbound-var") && stderr.contains("=="),
        "expected `[unbound-var] ... ==` diagnostic, got: {stderr}"
    );
}
