From bab7ac72ca22373cdf514a6454b55f376bd0c747 Mon Sep 17 00:00:00 2001 From: Stephen Waits Date: Mon, 9 Nov 2026 11:17:14 -0700 Subject: [PATCH] test(core): the adapter's line-ending answer needs every break to be CR LF contains(CR LF) answered cr-lf for a file mixing CR LF and bare LF. Now the count of LF must equal the count of CR LF for cr-lf, with none CR LF for lf, and a mix is mixed. The claims say the engine has no host notion, so host_line_ending is unused (BS-format-4). Co-Authored-By: Claude Sonnet 5.5 --- .../tests/bookspec/queries/formats.rs | 19 +++++++++++++------ docs/spec/claims/format.md | 2 +- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/crates/ledger-core/tests/bookspec/queries/formats.rs b/crates/ledger-core/tests/bookspec/queries/formats.rs index 53876950..b9a298a1 100644 --- a/crates/ledger-core/tests/bookspec/queries/formats.rs +++ b/crates/ledger-core/tests/bookspec/queries/formats.rs @@ -27,15 +27,22 @@ impl Books<'_> { )) } "iif_line_ending" => { - // The file's own bytes: CR LF (wanderbooks' pick, cr-lf) - // or the host's line ending. The engine writes CR LF on - // every platform, so the first line ending is the file's. - let ending = if iif.text.contains("\r\n") { + // The file's own bytes: every line break is CR LF + // (wanderbooks' pick, cr-lf), every one a bare LF, or a mix + // of the two, which is neither. The engine has no notion of + // a host, so the example's `setup.host_line_ending` is not + // read here. + let text = iif.text.as_str(); + let lf = text.matches('\n').count(); + let crlf = text.matches("\r\n").count(); + let ending = if lf == 0 { + "none" + } else if lf == crlf { "cr-lf" - } else if iif.text.contains('\n') { + } else if crlf == 0 { "lf" } else { - "cr-lf" + "mixed" }; Ok(json_figures([( "line_ending".to_string(), diff --git a/docs/spec/claims/format.md b/docs/spec/claims/format.md index 42b93c0a..f6a5a3ce 100644 --- a/docs/spec/claims/format.md +++ b/docs/spec/claims/format.md @@ -342,7 +342,7 @@ examples `format-cr-lf-on-an-lf-platform` and `format-no-customer-or-vendor-name` (BS-format-9), run by `every_bookspec_example_holds` and `the_runner_reports_every_claimed_rule_green`; the line ending is asked by -the iif_line_ending query (the adapter's answer_iif), the file's own CR LF. +the iif_line_ending query (the adapter's answer_iif), which reads the file's own bytes: cr-lf when every line break is CR LF, lf when every one is a bare LF, mixed when it is neither. The engine has no notion of a host, so the adapter does not use an example's host_line_ending setup. ### Product rules