mirror of
https://git.pumpin.online/funkpower/typikon.git
synced 2026-10-22 18:57:13 +00:00
The screenshot was a picture of the Python CLI: it predated the formats, the tradition in the header and --typikon, and a picture cannot be diffed against the program anyway. Every example is now a console block of real output. tests/readme-examples.py runs each one and diffs it, which found four things wrong in the process of writing them: the hero example printed today rather than a fixed date, so it was wrong for any reader on any other day; the Ruthenian example depended on whatever the reader's config remembered; a tradition block held two commands and was checking neither; and the JSON had a hand-collapsed array that the program does not emit. It also found a real bug. --typikon could be turned on by the config file and there was no way to turn it off again from the command line, so on this machine showed the Typikon's discipline with no way to ask for the law. --no-typikon now does that. The Rust example is a test rather than prose, for the same reason.
31 lines
1.1 KiB
Rust
31 lines
1.1 KiB
Rust
//! The README's Rust example, compiled and asserted, so it cannot quietly
|
|
//! stop being true. The prose version elides the error handling; this is the
|
|
//! same calls with the results checked.
|
|
|
|
use typikon::calendars::Date;
|
|
use typikon::day::describe;
|
|
use typikon::fasting::Level;
|
|
use typikon::jurisdictions::resolve;
|
|
|
|
#[test]
|
|
fn the_readme_library_example_is_true() {
|
|
let rocor = resolve(Some("rocor")).unwrap();
|
|
let day = describe(Date::from_ymd(2026, 9, 18).unwrap(), rocor);
|
|
|
|
assert_eq!(day.church_date, "5 September");
|
|
assert_eq!(day.fast, Level::Xerophagy);
|
|
assert_eq!(day.title(), "The Holy Prophet Zachariah, father of the Forerunner");
|
|
assert!(!day.is_obligatory());
|
|
|
|
assert_eq!(typikon::paschalion::julian_pascha(2027).iso(), "2027-05-02");
|
|
assert_eq!(typikon::paschalion::gregorian_pascha(2027).iso(), "2027-03-28");
|
|
}
|
|
|
|
#[test]
|
|
fn the_readme_level_example_is_true() {
|
|
// No saint brings fish into Lent.
|
|
assert_eq!(Level::Xerophagy.relaxed_to(Level::Fish, Level::WineOil), Level::WineOil);
|
|
// And relaxing never tightens.
|
|
assert_eq!(Level::Fish.relaxed_to(Level::WineOil, Level::WineOil), Level::Fish);
|
|
}
|