use chumsky::Parser;

use crate::{__internal__parse_include_str, __internal__span_macro_include_str, ast::Type};

use super::ty;

use pretty_assertions::assert_eq;

#[test]
fn test_ty() {
    __internal__span_macro_include_str!(
        crate::Span,
        "../../../../../testdata/partial/complex_type.cctmpl"
    );

    assert_eq!(
        __internal__parse_include_str!(
            ty().padded(),
            "../../../../../testdata/partial/complex_type.cctmpl"
        )
        .into_result()
        .unwrap(),
        Type::Array((
            Some(Box::new(Type::Struct(vec![
                (("number", s!(2..8)), (Some(Type::Base("int")), s!(10..13))),
                (("name", s!(15..19)), (None, s!(19..19))),
                (
                    ("recent", s!(21..27)),
                    (Some(Type::Base("bool")), s!(29..33))
                ),
                (
                    ("coordinates", s!(35..46)),
                    (
                        Some(Type::Tuple(vec![
                            (Type::Base("float"), s!(49..54)),
                            (Type::Base("float"), s!(56..61))
                        ])),
                        s!(48..62)
                    )
                )
            ]))),
            s!(1..63)
        ))
    );
}
