6ef13b2cc8a6
linear_empty_limits.rs
//! An n-ary operator's empty but shown limit survives linear text (#6076): half-typed `โ_` has an
//! empty lower limit that is shown, and `to_linear` writes it as `_()`. Left out, it reads back as a
//! hidden limit.
use wordcraft_doc::math::{MNode, MRun, parse_linear, to_linear};
#[test]
fn an_empty_shown_limit_prints_back_the_same() {
for s in ["โ_", "โ^", "โซ_0^โx", "โ_()^nโi"] {
let n = parse_linear(s);
assert_eq!(parse_linear(&to_linear(&n)), n, "{s} โ {}", to_linear(&n));
}
}
#[test]
fn hidden_and_filled_limits_print_as_before() {
let nary = |sub_hide, sup_hide, sub: &str, sup: &str| {
let arg = |t: &str| if t.is_empty() { Vec::new() } else { vec![MNode::Run(MRun::new(t))] };
vec![MNode::Nary { chr: 'โ', lim_loc: None, grow: false, sub_hide, sup_hide, sub: arg(sub), sup: arg(sup), e: arg("x") }]
};
assert_eq!(to_linear(&nary(true, true, "", "")), "โโx");
assert_eq!(to_linear(&nary(false, false, "i", "n")), "โ_i^nโx");
assert_eq!(to_linear(&nary(false, true, "", "")), "โ_()โx");
}
No file is open. Choose one in the tree, or press Ctrl+O (โO on a Mac) to find one by name.
Syntax highlighting could not load. The unmodified read-only text remains available above.