tgqe 0.0.2

The Great Qin Empire —— A centralized system for integrating and summarizing common compiler front-end library errors and span error output libraries, with optional Ariadne integration.
/**

 *  - Copyright (c) 星灿长风v(Starwindv) 2026/08/03
 *  - License: BSD-3
 *  - Author: 星灿长风v(StarWindv)
 *  - Location: tgqe/src/modules/tests/trans_chumsky.rs
 */
use chumsky::error::{Rich, Simple};
use chumsky::span::SimpleSpan;
use chumsky::util::MaybeRef;

use crate::base_types::{
    TgqeCtx, TgqeErrorInfo, TgqeSpan,
};

#[test]
fn simple_span_maps_start_and_end() {
    let span: TgqeSpan =
        SimpleSpan::from(2..5).into();

    assert_eq!(span.start.offset, 2);
    assert_eq!(span.end.offset, 5);
    assert_eq!(span.start.line, -2);
    assert_eq!(span.end.column, -2);
}

#[test]
fn simple_error_maps_found_token() {
    let err: TgqeErrorInfo = Simple::new(
        Some(MaybeRef::Val('x')),
        SimpleSpan::from(0..1),
    )
    .into();

    assert_eq!(err.got, "x");
    assert_eq!(
        err.err_type,
        "chumsky::error::Simple"
    );
}

#[test]
fn rich_custom_error_maps_got_and_publisher()
{
    let rich: Rich<'_, char> = Rich::custom(
        SimpleSpan::from(0..1),
        "boom",
    );
    let ctx: TgqeCtx = rich.into();

    assert_eq!(ctx.err_info.got, "boom");
    assert_eq!(ctx.publisher, "chumsky");
    assert_eq!(ctx.position.coord.offset, 0);
}