use tabnas_markdown::engine_inline::{make_inline_tn, INLINE_TOKENS};
use tabnas_markdown::Options;
#[test]
fn inline_rule_lookahead() {
let tn = make_inline_tn(&Options::default());
let inline = tn
.rule_specs()
.into_iter()
.find(|rs| rs.name == "inline")
.expect("inline rule not found");
for alt in &inline.open {
assert!(
alt.s.len() <= 1,
"inline open alt lookahead must be <= 1, got {}",
alt.s.len()
);
}
for alt in &inline.close {
assert!(
alt.s.len() <= 1,
"inline close alt lookahead must be <= 1, got {}",
alt.s.len()
);
}
}
#[test]
fn inline_token_alphabet() {
let want = [
"#IBK", "#IES", "#ICS", "#IDL", "#IOB", "#IBG", "#ICB", "#IAL", "#IHT", "#IEN", "#ITX",
"#ILI",
];
assert_eq!(INLINE_TOKENS, want, "inline token alphabet drifted");
}
#[test]
fn tilde_matcher_exists_only_with_gfm() {
let with = make_inline_tn(&Options::default());
assert!(with.options.lex.matchers.contains_key("inlTilde"));
let without = make_inline_tn(&Options::COMMONMARK);
assert!(!without.options.lex.matchers.contains_key("inlTilde"));
let orders: Vec<f64> = with
.options
.lex
.matchers
.values()
.map(|m| m.order)
.collect();
assert!(
orders.windows(2).all(|w| w[0] < w[1]),
"matchers are registered in ascending order: {orders:?}"
);
assert_eq!(with.options.lex.matchers.len(), 13);
assert_eq!(without.options.lex.matchers.len(), 12);
}