//! Sanity tests for lite mode — same data tree as full, no comments,
//! no original_forms.

use dms::{decode_document, decode_lite_document, ParseMode, decode_document_with_mode};

#[test]
fn lite_drops_comments_and_forms() {
    let src = "\
# leading
key: 0xFF      # trailing
secret: /* inner */ 'x'
+++
+++
";
    // (Documents must have either FM or no FM — strip the empty FM)
    let src = "\
# leading
key: 0xFF      # trailing
secret: /* inner */ 'x'
";
    let full = decode_document(src).unwrap();
    let lite = decode_lite_document(src).unwrap();

    // Body values are identical.
    assert_eq!(full.body, lite.body);
    assert_eq!(full.meta, lite.meta);

    // Full keeps comments + at least one original_form (the 0xFF lit).
    assert!(!full.comments.is_empty(), "full should have comments");
    assert!(!full.original_forms.is_empty(), "full should record 0xFF lit");

    // Lite drops both.
    assert!(lite.comments.is_empty(), "lite should drop comments");
    assert!(lite.original_forms.is_empty(), "lite should drop original_forms");
}

#[test]
fn lite_validates_grammar_same_as_full() {
    // Unterminated /* ... must error in both modes.
    let bad = "key: /* unterminated\n";
    let full_err = decode_document(bad).unwrap_err();
    let lite_err = decode_lite_document(bad).unwrap_err();
    assert_eq!(full_err.line, lite_err.line);
    assert_eq!(full_err.column, lite_err.column);
}

#[test]
fn decode_document_with_mode_dispatches() {
    let src = "k: 1\n";
    let f = decode_document_with_mode(src, ParseMode::Full).unwrap();
    let l = decode_document_with_mode(src, ParseMode::Lite).unwrap();
    assert_eq!(f.body, l.body);
}
