Repository navigation
test(layout): pin the boundaries the documentation states - #553
Merged
Merged
Conversation
the figures afterwards. Rounds re-derived partitions an earlier round had already settled, and three of the defects they found were sentences that had been true when written. A boundary a test asserts fails loudly instead. 45 cases, each from the probe that produced the sentence it pins: which null decides when two are null on DrawContext and RendererContext, and that the two methods of one type read them in opposite orders; that a save refuses the value it writes rather than the one passed, so a finite layoutY is refused when the page height is not finite; that a page from another document drops a link annotation while still writing the outline entry; that every Document.Add overload defers its refusals to the save; where a nested list's indent is refused and that a flat one never is; how a heading's level places its bookmark; and that Symbol and ZapfDingbats measure every BMP character as zero. Assertions are on exception type, ParamName or written bytes, never on a document coming back. The placement cases carry a control - a Helvetica line beside the Symbol one, a default indent beside the infinite one - so a change that stops drawing cannot pass them. The suite failed eight times while it was being written and every fix was to the test, not the library. Layout tests: 457 run, 0 failed, 31 skipped without the oracles on PATH.
Review rounds on PR #542 measured Layout's public surface, and nothing held the figures afterwards: rounds re-derived partitions an earlier round had already settled. A boundary a test asserts fails loudly instead. BoundaryContractTests holds 55 cases (4 facts and 51 theory rows), each from the probe that produced the sentence it pins: which null decides when two are null on DrawContext.UseEmbeddedFont and RendererContext.RegisterImageXObject, which read their arguments in opposite orders; that a save refuses the value it writes rather than the one passed; that a page from another document drops a link annotation while the outline entry is still written; that the five Document.Add overloads that carry a TextStyle defer that style's refusals to the save; where a nested list's indent is refused and that a flat list with unlinked text is never refused; how a heading's level places its bookmark; and that Symbol and ZapfDingbats measure every non-surrogate BMP character as zero. A refusal is asserted by exception type, ParamName or a message fragment, an acceptance by the save completing, and a placement by the bytes written. The placement cases carry a control, a Helvetica line beside the Symbol one and a default indent beside the infinite one, so a change that stops drawing cannot pass them. Layout tests, Release: 467 run, 0 failed, 31 skipped (oracle cases, no oracles on PATH).
Round 2 review of the boundary tests found two assertions a mutation survived and several sentences that overreached. Tests: Document.Add is now run at each non-finite font size (NaN, positive and negative infinity) for all five overloads, 15 rows, since a NaN-only row let an eager refusal of positive infinity in Add(Paragraph) pass. A wrapped paragraph now carries the mixed Symbol and Helvetica line, which is what backs the claim that the line, not the paragraph, is the unit: x 96.196, 235.282, 293.314, 293.314. Prose: 451.28, 451.2799, 297.64 and 523.28 are the values the probes measured for a stated rule, not figures the documentation quotes. The mixed-line comment is scoped to a Symbol run followed by a Helvetica run and says what round 20 changed. The test names that said more than they pinned are renamed, and the flat-list case is scoped to unlinked text. BoundaryContractTests: 66 cases (5 facts, 61 theory rows). Layout suite, Release: 478 total: 447 passed, 31 skipped (veraPDF not installed), 0 failed.
Round 3 review found sentences in the boundary tests that said more than the measurements support. Heading.Level: level 0 is always a top-level entry, so a level -1 entry before it does not become its parent. A [-1, 0] row pins that; it measures one distinct parent. Any other level hangs under the most recent earlier entry at exactly one level below it, or at the top level when there is none. Prose: the nested-list rows are the measured values either side of the edge, not figures the documentation quotes. Add(string, TextStyle) got its tags in round 7, not round 9. UseEmbeddedFont raises NullReferenceException for a null handle only when the context has a document. An acceptance is asserted by the save completing or the call returning. The controls pin no sentence, so only the other assertions are said to come from a probe. Run order changes the mixed-line result because the space between runs is measured in the earlier run's font. Em dashes in the test file's comments are replaced. BoundaryContractTests: 67 cases (5 facts, 62 theory rows). Layout suite, Release: 479 total: 448 passed, 31 skipped (veraPDF not installed), 0 failed.
Round 4 review found sentences in the boundary tests and their notes that generalised past the rows. The save-refusal rule is stated for AddOutlineEntry, the member the rows exercise. The Symbol, ZapfDingbats and mixed-line summaries now point at TextStyle.FontRef, which holds the sentences they pin. The mixed-line summary gives the mechanism for the run-order result: each run is placed after the measured width of the runs before it, a Symbol run measures zero, and the space between runs is measured in the earlier run's font. The UseEmbeddedFont null-document behaviour is marked as read from source, since no row nulls the document. The CHANGELOG entry carries the full Heading.Level rule. Documentation and comments only; no assertion changed. BoundaryContractTests still runs 67 cases, 0 failed.
Comments only, no wording change. Doc-comment paragraphs that ran past 100 columns are rewrapped, and two trailing comments that pushed a code line past it now sit on the line above. Code lines over 100 columns are left as they are, since dotnet format does not wrap them.
Tim81
force-pushed
the
test/layout-boundary-kats
branch
from
November 19, 2026 08:21
58e91eb to
fa24723
Compare
…kats # Conflicts: # CHANGELOG.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #542.
#542 documented Layout's public surface by measuring it over 21 review rounds. Nothing held the
figures afterwards, and later rounds re-derived partitions an earlier round had already settled.
Documentation goes stale in silence. A boundary a test asserts does not.
What is pinned
67 cases (5 facts and 62 theory rows) in
tests/VellumPdf.Layout.Tests/BoundaryContractTests.cs.Every assertion that pins a sentence is taken from the probe that produced that sentence; the
controls under "How they are written" pin none.
DrawContext.UseEmbeddedFontanswers a null handlewith
NullReferenceExceptionwhen itsRendererContexthas a document, unless the context wasbuilt without a page: the kernel looks the page up first and raises
ArgumentNullExceptionwithParamNamekeyinstead.RegisterImageXObjectreads its own argument first. The two truthtables diverge when the document is null:
UseEmbeddedFontraisesNullReferenceExceptionfora null handle (read from source; no row nulls the document), while
RegisterImageXObjectraises
ArgumentNullExceptionfor a null image.AddOutlineEntry's save refuses the Y it writes, not thelayoutYpassed. It flips the Ythrough
PageBounds, so a finitelayoutYis refused when that height is NaN, positive ornegative infinity, or when the subtraction overflows. The tags blamed the caller's argument until
round 21.
checked, while the outline entry is still written and points at a null destination.
Document.Addoverloads that carry aTextStyle(string, Paragraph, Heading,ListElement, TableElement) defer a non-finite font size to the save, at NaN, positive infinity and
negative infinity separately (15 rows), and defer an unnamed
Standard14value to the save too.Round 7 gave
Add(string, TextStyle)these tags, round 9's sweep of the style-taking members didnot reach the four sibling
Addoverloads, and round 21 found them still tagging only the nullcase.
ListElement.Indent: a nested list is refused at its own area width, inclusively (451.2799saves, 451.28 throws), and the boundary moves with the list's margins. A flat list with unlinked
text is never refused, at any indent, including positive and negative infinity and NaN (a linked run at
NaN throws
ArgumentException). At positive infinity the marker is drawn and the item text isdiscarded.
Heading.Level: level 0 is always a top-level entry. Any other level hangs under the mostrecent earlier entry at exactly
Level - 1, or at the top level when there is none, soconsecutive levels nest and a jump does not. A
[-1, 0]row pins that level 0 stays at the topeven after a level -1 entry.
zero at each size probed. A wholly-Symbol paragraph of 660 characters draws one line where
Helvetica wraps to nine. A centred Symbol line sits at the exact centre of the content area. In a
wrapped paragraph the mixed Symbol and Helvetica line is centred on its Helvetica text alone.
The figures 451.28, 451.2799, 297.64 and 523.28 are what the probes measured for the rules the
members state. The documentation does not quote them.
How they are written
A refusal is asserted by exception type,
ParamNameor a message fragment, an acceptance by thesave completing or the call returning, and a placement by the bytes written. Non-finite inputs are listed value by value,
since NaN, positive infinity and negative infinity can take three different branches, and during
#542's review a measurement of one of them was twice promoted to a claim about all three.
The placement cases carry controls: a Helvetica line beside the Symbol one (x 257.296 centred and
442.592 right-aligned, against 297.64 and 523.28 for Symbol), and a default indent beside the
infinite one. They catch a change that always places the line at the Symbol position or always
drops the item text.
Scope
Tests only; no
src/file changes. Main is merged in (75b0c70: #577, #578, #579), so the testsbuild for
net10.0andnet11.0. Layout tests, Release, withREQUIRE_ORACLES=1, veraPDF 1.30.4and qpdf 12.4.2: 479 per target framework, 0 failed, 0 skipped.
Some cases pin behaviour that later issues intend to change. #484 (validating at the property
instead of at the save) is expected to fail the non-finite font-size cases, #470 (v2.3.6) will fail every case that
depends on Symbol or ZapfDingbats measuring zero (the measurement theory, the Symbol rows of the
placement theory, both mixed-line facts and the Symbol paragraph fact), and #476 (v2.3.8) will fail the positive-infinity flat-list
row. That is the point: each of those cases pins a documented sentence, and the fix has to change that
sentence too.
#571 merges after this PR and updates, in its own diff, every pin here that it changes, so its
behaviour changes show up as test changes.