//! Pins the mut/var/assign removal: the keyword no longer parses and
//! the canonical JSON tag is an unknown serde variant. RED until the
//! Task-2 atomic cut lands.
use ailang_surface::parse;

#[test]
fn mut_keyword_is_rejected_by_form_a_parse() {
    let src = "(module m (fn f (type (fn-type (params) (ret (own (con Int))))) (params) (body (mut (var x (con Int) 0) (assign x (app + x 1)) x))))";
    let r = parse(src);
    assert!(r.is_err(), "mut keyword must no longer parse, got Ok");
}

#[test]
fn assign_keyword_is_rejected_by_form_a_parse() {
    let src = "(module m (fn f (type (fn-type (params) (ret (own (con Int))))) (params) (body (assign x 1))))";
    assert!(parse(src).is_err(), "assign keyword must no longer parse, got Ok");
}

#[test]
fn json_tag_mut_is_unknown_serde_variant() {
    let j = r#"{"t":"mut","vars":[],"body":{"t":"lit","lit":{"kind":"int","value":0}}}"#;
    let r: Result<ailang_core::ast::Term, _> = serde_json::from_str(j);
    assert!(r.is_err(), "{{\"t\":\"mut\"}} must be an unknown variant, got Ok");
}

#[test]
fn json_tag_assign_is_unknown_serde_variant() {
    let j = r#"{"t":"assign","name":"x","value":{"t":"lit","lit":{"kind":"int","value":1}}}"#;
    let r: Result<ailang_core::ast::Term, _> = serde_json::from_str(j);
    assert!(r.is_err(), "{{\"t\":\"assign\"}} must be an unknown variant, got Ok");
}
