aboutsummaryrefslogtreecommitdiff
path: root/test/test_config.ml
diff options
context:
space:
mode:
authorLukasz Kasprzak <lukas@labunix.xyz>2026-08-20 19:05:13 +0200
committerLukasz Kasprzak <lukas@labunix.xyz>2026-08-20 19:05:13 +0200
commit7dbd16cdf5880c0006dffacd09214ee607050b64 (patch)
tree01e1ee37a2be97a0b06fad70de975d8007beb702 /test/test_config.ml
parent1aeca948c2a2a82bffaaec65077140aa05f7b3f4 (diff)
parent1da70dc7ac03fe33fb92b172a0e26932764170d6 (diff)
downloadcolitur-7dbd16cdf5880c0006dffacd09214ee607050b64.tar.gz
colitur-7dbd16cdf5880c0006dffacd09214ee607050b64.zip
Merge branch 'citations-and-sigla'
Citations are parsed into structure and re-rendered, so book names, abbreviations, punctuation style and numbering tradition become files a user edits rather than strings frozen in the data. New lib/citation (Book, Parse, Render, Sigla); [bible] and [sigla] sections in language files; lang/traditions.ini for numbering; three config keys and CLI flags. --raw emits every citation byte-for-byte as stored, bypassing the whole pipeline, so output stays diffable against lectio and the raw view does not depend on the parser being correct.
Diffstat (limited to 'test/test_config.ml')
-rw-r--r--test/test_config.ml35
1 files changed, 34 insertions, 1 deletions
diff --git a/test/test_config.ml b/test/test_config.ml
index 83da015..d348d9b 100644
--- a/test/test_config.ml
+++ b/test/test_config.ml
@@ -102,6 +102,35 @@ let test_two_defaults_blocks_report_no_unknown_sections () =
let c = ok (C.of_string text) in
Alcotest.(check (list string)) "no unknown sections" [] (C.unknown_sections c)
+(* Task 8: sigla_style/sigla_book/sigla_tradition read the same way
+ lang/template/format do, in the same [\[defaults\]] section -- no new
+ section, and every key recognised (so [unknown_keys] stays empty). *)
+let test_sigla_keys_are_read () =
+ let text =
+ "[defaults]\nsigla_style = la\nsigla_book = full\nsigla_tradition = modern\n"
+ in
+ match C.of_string text with
+ | Error e -> Alcotest.failf "parse: %s" e
+ | Ok c ->
+ Alcotest.(check (option string)) "style" (Some "la") (C.sigla_style c);
+ Alcotest.(check (option string)) "book" (Some "full") (C.sigla_book c);
+ Alcotest.(check (option string)) "tradition" (Some "modern") (C.sigla_tradition c);
+ Alcotest.(check (list string)) "nothing unknown" [] (C.unknown_keys c)
+
+(* The empty config carries no sigla settings either -- same "all None"
+ contract [test_empty_config_is_all_none] already asserts for lang. *)
+let test_empty_config_sigla_keys_are_none () =
+ Alcotest.(check (option string)) "sigla_style" None (C.sigla_style C.empty);
+ Alcotest.(check (option string)) "sigla_book" None (C.sigla_book C.empty);
+ Alcotest.(check (option string)) "sigla_tradition" None (C.sigla_tradition C.empty)
+
+(* Same last-wins duplicate policy as lang/template/format: a key repeated
+ across two [\[defaults\]] blocks resolves to the LATER block's value. *)
+let test_sigla_key_repeated_across_blocks_last_wins () =
+ let text = "[defaults]\nsigla_book = full\n\n[defaults]\nsigla_book = abbr\n" in
+ let c = ok (C.of_string text) in
+ Alcotest.(check (option string)) "later block's sigla_book wins" (Some "abbr") (C.sigla_book c)
+
let suite =
( "Config",
[ Alcotest.test_case "reads defaults" `Quick test_reads_defaults;
@@ -119,4 +148,8 @@ let suite =
Alcotest.test_case "overlays accumulate across blocks"
`Quick test_overlays_accumulate_across_blocks;
Alcotest.test_case "two defaults blocks report no unknown sections"
- `Quick test_two_defaults_blocks_report_no_unknown_sections ] )
+ `Quick test_two_defaults_blocks_report_no_unknown_sections;
+ Alcotest.test_case "sigla keys are read" `Quick test_sigla_keys_are_read;
+ Alcotest.test_case "empty config sigla keys are none" `Quick test_empty_config_sigla_keys_are_none;
+ Alcotest.test_case "sigla key repeated across blocks last wins"
+ `Quick test_sigla_key_repeated_across_blocks_last_wins ] )