use kyomu::{ReflectionRecursive, TyKindMapped};
use std::{fmt::Debug, net::Ipv4Addr};

pub trait InhertsDebug: Debug {}

impl InhertsDebug for u8 {}

#[test]
fn arrays() {
    let TyKindMapped::DynTraitReference(mutable, dt) =
        (&(&42i8 as &(dyn Debug + Send))).get_ty_recursive()
    else {
        panic!()
    };
    assert!(!mutable);
    let debug = dt.try_as::<dyn Debug>().unwrap();
    assert_eq!(format!("{debug:?}"), "42");

    let TyKindMapped::DynTraitReference(mutable, dt) =
        (&(&Ipv4Addr::LOCALHOST as &(dyn ToString + Send))).get_ty_recursive()
    else {
        panic!()
    };
    assert!(!mutable);
    assert_eq!(
        dt.try_as::<dyn ToString>().unwrap().to_string(),
        "127.0.0.1"
    );
}
