diff options
| author | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-08-20 16:19:25 +0200 |
|---|---|---|
| committer | Lukasz Kasprzak <lukas@labunix.xyz> | 2026-08-20 16:19:25 +0200 |
| commit | 87b155b913cea7f5c55b5a2391aff7819ba541a6 (patch) | |
| tree | 616df0de0f9fa8a08f6fd4156fa5fdac8fb9a1c3 /test/test_config.ml | |
| parent | 263d0d889073d214229aef9655d3db29540c0d12 (diff) | |
| download | colitur-87b155b913cea7f5c55b5a2391aff7819ba541a6.tar.gz colitur-87b155b913cea7f5c55b5a2391aff7819ba541a6.zip | |
feat(config): sigla_style, sigla_book and sigla_tradition
Same flag > config > default precedence as --lang, and each reported by
config --show with its source, so an override is visible rather than
mysterious.
A language file's [sigla] section IS a style; a config key SELECTS one and
may override settings within it -- the two are not a duplicate setting.
Diffstat (limited to 'test/test_config.ml')
| -rw-r--r-- | test/test_config.ml | 35 |
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 ] ) |
