//! Hard gate against re-introducing the per-type print effect-ops:
//! `io/print_int`, `io/print_bool`, `io/print_float` are retired
//! and must NOT appear in the builtin registry. The polymorphic
//! `print` helper (prelude, iter 24.3) is the canonical replacement;
//! `io/print_str` survives as the byte-channel primitive.

use ailang_check::build_check_env;
use ailang_surface::load_workspace;
use std::path::PathBuf;

fn fixture_dir() -> PathBuf {
    let mut d = PathBuf::from(env!("CARGO_MANIFEST_DIR"));
    d.pop();
    d.pop();
    d.join("examples")
}

#[test]
fn per_type_print_effect_ops_are_retired() {
    // Any workspace will do; we only inspect the post-install
    // builtin registry. `hello.ail` is the smallest surviving
    // fixture (uses `io/print_str` only).
    let ws_path = fixture_dir().join("hello.ail");
    let ws = load_workspace(&ws_path).expect("workspace loads");
    let env = build_check_env(&ws);

    for retired in ["io/print_int", "io/print_bool", "io/print_float"] {
        assert!(
            !env.effect_ops.contains_key(retired),
            "{retired} must not appear in builtin registry post-per-type-print-retirement; \
             use polymorphic `print` (Show-based) instead"
        );
    }

    // Survivor pin: io/print_str stays.
    assert!(
        env.effect_ops.contains_key("io/print_str"),
        "io/print_str must survive — it is the canonical byte-channel \
         primitive and used internally by `print`"
    );
}
