diff options
| author | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-08-20 22:40:13 +0200 |
|---|---|---|
| committer | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-08-20 22:40:13 +0200 |
| commit | f73bd5d0e33146c24af1e98bf9ea26bd8cbf004b (patch) | |
| tree | 790100dcc0077532d9446478e51d4cd40209c1c6 /test/test_citation.ml | |
| parent | 2d8942e08edcbe5430f97270bdb1233e287600ee (diff) | |
| parent | 671c4264707ec8c81845059746632b00f2481d88 (diff) | |
| download | colitur-f73bd5d0e33146c24af1e98bf9ea26bd8cbf004b.tar.gz colitur-f73bd5d0e33146c24af1e98bf9ea26bd8cbf004b.zip | |
Merge branch 'robustness-and-hackability'
An audit of the shipped program, plus the fixes it found.
The citation parser accepted OCaml integer-literal syntax, so a typo like
'Luke 1_1:5' silently became a different chapter. Four pairs of different
books shared a full title -- 1 and 2 Corinthians both rendered 'Epistola
ad Corinthios' -- leaving 108 citations in 2027 alone that a reader could
not resolve to a book. Spec section 8.5 is now delivered rather than
recorded: shipped styles re-parse their own output. Overlay errors no
longer name OCaml source files at the reader.
Also: the new-overlay scaffold shows citations at the right nesting
level, config --show validates before printing, error messages no longer
echo whole file lines, and a month answers to both spellings of its own
name.
Diffstat (limited to 'test/test_citation.ml')
| -rw-r--r-- | test/test_citation.ml | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/test/test_citation.ml b/test/test_citation.ml index 133553b..dae4610 100644 --- a/test/test_citation.ml +++ b/test/test_citation.ml @@ -283,6 +283,11 @@ let parses input expected () = | Error e -> Alcotest.failf "%s did not parse: %s" input e | Ok t -> Alcotest.(check s) input expected (show t) +let rejects input () = + match P.parse input with + | Ok t -> Alcotest.failf "%s should not parse, got %s" input (show t) + | Error _ -> () + let test_rejects_unknown_book () = Alcotest.(check bool) "error" true (Result.is_error (P.parse "Nonesuch 1:1")) @@ -321,6 +326,20 @@ let parse_suite = ("ordinal 3 parses", `Quick, parses "3 Kings 17:8-16" "kings_3|17:8-16"); ("ordinal 3 dotted", `Quick, parses "3 Kgs. 19:3-8" "kings_3|19:3-8"); ("ordinal 4 parses", `Quick, parses "4 Kings 5:1-15" "kings_4|5:1-15"); + (* A citation number must be plain digits and positive. OCaml's + [int_of_string] also accepts its own literal syntax, so "1_1" parsed + as chapter ELEVEN and "+5" as 5 -- a typo silently becoming a + DIFFERENT chapter, which no amount of downstream care can catch. + Reachable through a user overlay, which supplies arbitrary strings. *) + ("rejects underscore in chapter", `Quick, rejects "Luke 1_1:5"); + ("rejects underscore in verse", `Quick, rejects "Luke 1:5_0"); + ("rejects plus in chapter", `Quick, rejects "Luke +1:5"); + ("rejects plus in verse", `Quick, rejects "Luke 1:+5"); + ("rejects chapter zero", `Quick, rejects "Luke 0:5"); + ("rejects verse zero", `Quick, rejects "Luke 1:0"); + (* A descending range is always a transcription error. *) + ("rejects descending range", `Quick, rejects "Luke 1:20-10"); + ("allows a single-verse range", `Quick, parses "Luke 1:5-5" "luke|1:5-5"); ("unknown book", `Quick, test_rejects_unknown_book); ("garbage", `Quick, test_rejects_garbage) ] |
