Type: tests expect the Single-line Composer to break mixed-size overflow lines as the Every-line Composer does

This commit is contained in:
dotCooCoo
2026-11-14 05:55:44 -08:00
parent b0961a29af
commit 11225df118
2 changed files with 12 additions and 7 deletions
+8 -4
View File
@@ -501,8 +501,8 @@ fn composer_x_mixed_sizes_overflow_a_shaped_frame() {
// A stepped frame too short for the paragraph: the every-line composer still breaks the lines
// that fit as one paragraph, with the lines past the frame's end measured as wide as the last
// line the frame holds. Here that is the narrow part, so the lines that fit break as in a frame
// tall enough for the whole paragraph, and not as the single-line composer breaks them. They
// are set in order, each once and within its room, and the frame overflows.
// tall enough for the whole paragraph. They are set in order, each once and within its room,
// and the frame overflows.
let w = x_width();
let set = |bottom: f64, composer: Composer| {
let mut t = stepped(w, w * 0.5, 40.0, bottom);
@@ -520,8 +520,10 @@ fn composer_x_mixed_sizes_overflow_a_shaped_frame() {
assert_eq!(every, ["Destroy all creatures with toughness", "X or less. Then", "draw a card for each"]);
let (whole, ..) = set(300.0, Composer::EveryLine);
assert_eq!(every, whole[..every.len()]);
// The single-line composer measures each line across its height too, and breaks the lines
// that fit the same way.
let (greedy, ..) = set(75.0, Composer::SingleLine);
assert_ne!(every, greedy);
assert_eq!(every, greedy);
// A frame with no room for a line sets none.
for composer in [Composer::EveryLine, Composer::SingleLine] {
let mut t = stepped(w, w * 0.5, 4.0, 8.0);
@@ -562,8 +564,10 @@ fn composer_x_mixed_sizes_overflow_around_text_wrap() {
assert_eq!(hits.count(), 0, "{:?}", l.lines);
// The lines that fit break as in `composer_x_mixed_sizes_around_text_wrap`'s taller frame.
assert_eq!(every, ["Destroy all creatures with", "toughness\u{a0}X", "or less. Then", "draw a card for", "each creature"]);
// The single-line composer measures each line across its height too, and breaks the lines
// that fit the same way.
let (greedy, ..) = set(Composer::SingleLine);
assert_ne!(every, greedy);
assert_eq!(every, greedy);
}
#[test]
+4 -3
View File
@@ -415,8 +415,7 @@ fn stepped_frame(w: f64, narrow: f64, y: f64, bottom: f64) -> TextObject {
/// A paragraph of mixed type sizes that a stepped frame cannot hold goes on in the next frame. The
/// every-line composer breaks the lines the first frame holds as one paragraph, as in a frame tall
/// enough for all of it and not as the single-line composer breaks them, and the first frame
/// takes the text of those lines. The next frame sets the rest at its own width, without the
/// enough for all of it, and the first frame takes the text of those lines. The next frame sets the rest at its own width, without the
/// first-line indent, and no character is lost or repeated. The frames take the same shares as
/// when each is measured with the whole rest of the story.
#[test]
@@ -460,8 +459,10 @@ fn a_mixed_size_paragraph_continued_from_a_shaped_frame_is_composed_in_both() {
assert_eq!(every, whole[..every.len()], "indent {indent}");
if indent == 0.0 {
assert_eq!(every, ["Destroy all creatures with toughness", "X or less. Then", "draw a card for each"]);
// The single-line composer measures each line across its height too, and breaks the
// first frame's lines the same way.
let (greedy, ..) = shares(Composer::SingleLine, indent);
assert_eq!(greedy, ["Destroy all creatures with toughness X", "or less. Then draw a", "card for each", "creature destroyed"]);
assert_eq!(greedy, every);
}
// The next frame starts at its left edge, and its lines keep within it.
assert!((line_start(&lays[1], 0) - 200.0).abs() < 1e-6, "{}", line_start(&lays[1], 0));