Cotton code
1411 lines · 35.4 KB · RustRaw
//! Every case of `packages/core/__tests__/engine/recurrencePresets.test.ts`,//! plus 210 vectors for `composeRrule` and `splitRrule` — which that file does//! not reach at all — read out of Node across four zones, including both 2026//! DST transition days, because the whole point of `end_of_local_day` is that//! "ends on 31 December" is a different INSTANT in every zone.use super::*;/// `(zone, preset, end kind, end key, expected)` — straight out of Node.const COMPOSED: &[(&str, &str, &str, &str, Option<&str>)] = &[    ("Asia/Kolkata", "none", "never", "", None),    ("Asia/Kolkata", "none", "on", "2026-12-31", None),    ("Asia/Kolkata", "none", "on", "2026-03-29", None),    ("Asia/Kolkata", "none", "on", "2026-11-01", None),    ("Asia/Kolkata", "none", "after", "1", None),    ("Asia/Kolkata", "none", "after", "12", None),    ("Asia/Kolkata", "daily", "never", "", Some("FREQ=DAILY")),    (        "Asia/Kolkata",        "daily",        "on",        "2026-12-31",        Some("FREQ=DAILY;UNTIL=20261231T182959Z"),    ),    (        "Asia/Kolkata",        "daily",        "on",        "2026-03-29",        Some("FREQ=DAILY;UNTIL=20260329T182959Z"),    ),    (        "Asia/Kolkata",        "daily",        "on",        "2026-11-01",        Some("FREQ=DAILY;UNTIL=20261101T182959Z"),    ),    (        "Asia/Kolkata",        "daily",        "after",        "1",        Some("FREQ=DAILY;COUNT=1"),    ),    (        "Asia/Kolkata",        "daily",        "after",        "12",        Some("FREQ=DAILY;COUNT=12"),    ),    (        "Asia/Kolkata",        "weekdays",        "never",        "",        Some("FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR"),    ),    (        "Asia/Kolkata",        "weekdays",        "on",        "2026-12-31",        Some("FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR;UNTIL=20261231T182959Z"),    ),    (        "Asia/Kolkata",        "weekdays",        "on",        "2026-03-29",        Some("FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR;UNTIL=20260329T182959Z"),    ),    (        "Asia/Kolkata",        "weekdays",        "on",        "2026-11-01",        Some("FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR;UNTIL=20261101T182959Z"),    ),    (        "Asia/Kolkata",        "weekdays",        "after",        "1",        Some("FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR;COUNT=1"),    ),    (        "Asia/Kolkata",        "weekdays",        "after",        "12",        Some("FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR;COUNT=12"),    ),    ("Asia/Kolkata", "weekly", "never", "", Some("FREQ=WEEKLY")),    (        "Asia/Kolkata",        "weekly",        "on",        "2026-12-31",        Some("FREQ=WEEKLY;UNTIL=20261231T182959Z"),    ),    (        "Asia/Kolkata",        "weekly",        "on",        "2026-03-29",        Some("FREQ=WEEKLY;UNTIL=20260329T182959Z"),    ),    (        "Asia/Kolkata",        "weekly",        "on",        "2026-11-01",        Some("FREQ=WEEKLY;UNTIL=20261101T182959Z"),    ),    (        "Asia/Kolkata",        "weekly",        "after",        "1",        Some("FREQ=WEEKLY;COUNT=1"),    ),    (        "Asia/Kolkata",        "weekly",        "after",        "12",        Some("FREQ=WEEKLY;COUNT=12"),    ),    (        "Asia/Kolkata",        "biweekly",        "never",        "",        Some("FREQ=WEEKLY;INTERVAL=2"),    ),    (        "Asia/Kolkata",        "biweekly",        "on",        "2026-12-31",        Some("FREQ=WEEKLY;INTERVAL=2;UNTIL=20261231T182959Z"),    ),    (        "Asia/Kolkata",        "biweekly",        "on",        "2026-03-29",        Some("FREQ=WEEKLY;INTERVAL=2;UNTIL=20260329T182959Z"),    ),    (        "Asia/Kolkata",        "biweekly",        "on",        "2026-11-01",        Some("FREQ=WEEKLY;INTERVAL=2;UNTIL=20261101T182959Z"),    ),    (        "Asia/Kolkata",        "biweekly",        "after",        "1",        Some("FREQ=WEEKLY;INTERVAL=2;COUNT=1"),    ),    (        "Asia/Kolkata",        "biweekly",        "after",        "12",        Some("FREQ=WEEKLY;INTERVAL=2;COUNT=12"),    ),    ("Asia/Kolkata", "monthly", "never", "", Some("FREQ=MONTHLY")),    (        "Asia/Kolkata",        "monthly",        "on",        "2026-12-31",        Some("FREQ=MONTHLY;UNTIL=20261231T182959Z"),    ),    (        "Asia/Kolkata",        "monthly",        "on",        "2026-03-29",        Some("FREQ=MONTHLY;UNTIL=20260329T182959Z"),    ),    (        "Asia/Kolkata",        "monthly",        "on",        "2026-11-01",        Some("FREQ=MONTHLY;UNTIL=20261101T182959Z"),    ),    (        "Asia/Kolkata",        "monthly",        "after",        "1",        Some("FREQ=MONTHLY;COUNT=1"),    ),    (        "Asia/Kolkata",        "monthly",        "after",        "12",        Some("FREQ=MONTHLY;COUNT=12"),    ),    ("Asia/Kolkata", "yearly", "never", "", Some("FREQ=YEARLY")),    (        "Asia/Kolkata",        "yearly",        "on",        "2026-12-31",        Some("FREQ=YEARLY;UNTIL=20261231T182959Z"),    ),    (        "Asia/Kolkata",        "yearly",        "on",        "2026-03-29",        Some("FREQ=YEARLY;UNTIL=20260329T182959Z"),    ),    (        "Asia/Kolkata",        "yearly",        "on",        "2026-11-01",        Some("FREQ=YEARLY;UNTIL=20261101T182959Z"),    ),    (        "Asia/Kolkata",        "yearly",        "after",        "1",        Some("FREQ=YEARLY;COUNT=1"),    ),    (        "Asia/Kolkata",        "yearly",        "after",        "12",        Some("FREQ=YEARLY;COUNT=12"),    ),    ("Europe/London", "none", "never", "", None),    ("Europe/London", "none", "on", "2026-12-31", None),    ("Europe/London", "none", "on", "2026-03-29", None),    ("Europe/London", "none", "on", "2026-11-01", None),    ("Europe/London", "none", "after", "1", None),    ("Europe/London", "none", "after", "12", None),    ("Europe/London", "daily", "never", "", Some("FREQ=DAILY")),    (        "Europe/London",        "daily",        "on",        "2026-12-31",        Some("FREQ=DAILY;UNTIL=20261231T235959Z"),    ),    (        "Europe/London",        "daily",        "on",        "2026-03-29",        Some("FREQ=DAILY;UNTIL=20260329T225959Z"),    ),    (        "Europe/London",        "daily",        "on",        "2026-11-01",        Some("FREQ=DAILY;UNTIL=20261101T235959Z"),    ),    (        "Europe/London",        "daily",        "after",        "1",        Some("FREQ=DAILY;COUNT=1"),    ),    (        "Europe/London",        "daily",        "after",        "12",        Some("FREQ=DAILY;COUNT=12"),    ),    (        "Europe/London",        "weekdays",        "never",        "",        Some("FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR"),    ),    (        "Europe/London",        "weekdays",        "on",        "2026-12-31",        Some("FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR;UNTIL=20261231T235959Z"),    ),    (        "Europe/London",        "weekdays",        "on",        "2026-03-29",        Some("FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR;UNTIL=20260329T225959Z"),    ),    (        "Europe/London",        "weekdays",        "on",        "2026-11-01",        Some("FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR;UNTIL=20261101T235959Z"),    ),    (        "Europe/London",        "weekdays",        "after",        "1",        Some("FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR;COUNT=1"),    ),    (        "Europe/London",        "weekdays",        "after",        "12",        Some("FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR;COUNT=12"),    ),    ("Europe/London", "weekly", "never", "", Some("FREQ=WEEKLY")),    (        "Europe/London",        "weekly",        "on",        "2026-12-31",        Some("FREQ=WEEKLY;UNTIL=20261231T235959Z"),    ),    (        "Europe/London",        "weekly",        "on",        "2026-03-29",        Some("FREQ=WEEKLY;UNTIL=20260329T225959Z"),    ),    (        "Europe/London",        "weekly",        "on",        "2026-11-01",        Some("FREQ=WEEKLY;UNTIL=20261101T235959Z"),    ),    (        "Europe/London",        "weekly",        "after",        "1",        Some("FREQ=WEEKLY;COUNT=1"),    ),    (        "Europe/London",        "weekly",        "after",        "12",        Some("FREQ=WEEKLY;COUNT=12"),    ),    (        "Europe/London",        "biweekly",        "never",        "",        Some("FREQ=WEEKLY;INTERVAL=2"),    ),    (        "Europe/London",        "biweekly",        "on",        "2026-12-31",        Some("FREQ=WEEKLY;INTERVAL=2;UNTIL=20261231T235959Z"),    ),    (        "Europe/London",        "biweekly",        "on",        "2026-03-29",        Some("FREQ=WEEKLY;INTERVAL=2;UNTIL=20260329T225959Z"),    ),    (        "Europe/London",        "biweekly",        "on",        "2026-11-01",        Some("FREQ=WEEKLY;INTERVAL=2;UNTIL=20261101T235959Z"),    ),    (        "Europe/London",        "biweekly",        "after",        "1",        Some("FREQ=WEEKLY;INTERVAL=2;COUNT=1"),    ),    (        "Europe/London",        "biweekly",        "after",        "12",        Some("FREQ=WEEKLY;INTERVAL=2;COUNT=12"),    ),    (        "Europe/London",        "monthly",        "never",        "",        Some("FREQ=MONTHLY"),    ),    (        "Europe/London",        "monthly",        "on",        "2026-12-31",        Some("FREQ=MONTHLY;UNTIL=20261231T235959Z"),    ),    (        "Europe/London",        "monthly",        "on",        "2026-03-29",        Some("FREQ=MONTHLY;UNTIL=20260329T225959Z"),    ),    (        "Europe/London",        "monthly",        "on",        "2026-11-01",        Some("FREQ=MONTHLY;UNTIL=20261101T235959Z"),    ),    (        "Europe/London",        "monthly",        "after",        "1",        Some("FREQ=MONTHLY;COUNT=1"),    ),    (        "Europe/London",        "monthly",        "after",        "12",        Some("FREQ=MONTHLY;COUNT=12"),    ),    ("Europe/London", "yearly", "never", "", Some("FREQ=YEARLY")),    (        "Europe/London",        "yearly",        "on",        "2026-12-31",        Some("FREQ=YEARLY;UNTIL=20261231T235959Z"),    ),    (        "Europe/London",        "yearly",        "on",        "2026-03-29",        Some("FREQ=YEARLY;UNTIL=20260329T225959Z"),    ),    (        "Europe/London",        "yearly",        "on",        "2026-11-01",        Some("FREQ=YEARLY;UNTIL=20261101T235959Z"),    ),    (        "Europe/London",        "yearly",        "after",        "1",        Some("FREQ=YEARLY;COUNT=1"),    ),    (        "Europe/London",        "yearly",        "after",        "12",        Some("FREQ=YEARLY;COUNT=12"),    ),    ("America/New_York", "none", "never", "", None),    ("America/New_York", "none", "on", "2026-12-31", None),    ("America/New_York", "none", "on", "2026-03-29", None),    ("America/New_York", "none", "on", "2026-11-01", None),    ("America/New_York", "none", "after", "1", None),    ("America/New_York", "none", "after", "12", None),    ("America/New_York", "daily", "never", "", Some("FREQ=DAILY")),    (        "America/New_York",        "daily",        "on",        "2026-12-31",        Some("FREQ=DAILY;UNTIL=20270101T045959Z"),    ),    (        "America/New_York",        "daily",        "on",        "2026-03-29",        Some("FREQ=DAILY;UNTIL=20260330T035959Z"),    ),    (        "America/New_York",        "daily",        "on",        "2026-11-01",        Some("FREQ=DAILY;UNTIL=20261102T045959Z"),    ),    (        "America/New_York",        "daily",        "after",        "1",        Some("FREQ=DAILY;COUNT=1"),    ),    (        "America/New_York",        "daily",        "after",        "12",        Some("FREQ=DAILY;COUNT=12"),    ),    (        "America/New_York",        "weekdays",        "never",        "",        Some("FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR"),    ),    (        "America/New_York",        "weekdays",        "on",        "2026-12-31",        Some("FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR;UNTIL=20270101T045959Z"),    ),    (        "America/New_York",        "weekdays",        "on",        "2026-03-29",        Some("FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR;UNTIL=20260330T035959Z"),    ),    (        "America/New_York",        "weekdays",        "on",        "2026-11-01",        Some("FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR;UNTIL=20261102T045959Z"),    ),    (        "America/New_York",        "weekdays",        "after",        "1",        Some("FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR;COUNT=1"),    ),    (        "America/New_York",        "weekdays",        "after",        "12",        Some("FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR;COUNT=12"),    ),    (        "America/New_York",        "weekly",        "never",        "",        Some("FREQ=WEEKLY"),    ),    (        "America/New_York",        "weekly",        "on",        "2026-12-31",        Some("FREQ=WEEKLY;UNTIL=20270101T045959Z"),    ),    (        "America/New_York",        "weekly",        "on",        "2026-03-29",        Some("FREQ=WEEKLY;UNTIL=20260330T035959Z"),    ),    (        "America/New_York",        "weekly",        "on",        "2026-11-01",        Some("FREQ=WEEKLY;UNTIL=20261102T045959Z"),    ),    (        "America/New_York",        "weekly",        "after",        "1",        Some("FREQ=WEEKLY;COUNT=1"),    ),    (        "America/New_York",        "weekly",        "after",        "12",        Some("FREQ=WEEKLY;COUNT=12"),    ),    (        "America/New_York",        "biweekly",        "never",        "",        Some("FREQ=WEEKLY;INTERVAL=2"),    ),    (        "America/New_York",        "biweekly",        "on",        "2026-12-31",        Some("FREQ=WEEKLY;INTERVAL=2;UNTIL=20270101T045959Z"),    ),    (        "America/New_York",        "biweekly",        "on",        "2026-03-29",        Some("FREQ=WEEKLY;INTERVAL=2;UNTIL=20260330T035959Z"),    ),    (        "America/New_York",        "biweekly",        "on",        "2026-11-01",        Some("FREQ=WEEKLY;INTERVAL=2;UNTIL=20261102T045959Z"),    ),    (        "America/New_York",        "biweekly",        "after",        "1",        Some("FREQ=WEEKLY;INTERVAL=2;COUNT=1"),    ),    (        "America/New_York",        "biweekly",        "after",        "12",        Some("FREQ=WEEKLY;INTERVAL=2;COUNT=12"),    ),    (        "America/New_York",        "monthly",        "never",        "",        Some("FREQ=MONTHLY"),    ),    (        "America/New_York",        "monthly",        "on",        "2026-12-31",        Some("FREQ=MONTHLY;UNTIL=20270101T045959Z"),    ),    (        "America/New_York",        "monthly",        "on",        "2026-03-29",        Some("FREQ=MONTHLY;UNTIL=20260330T035959Z"),    ),    (        "America/New_York",        "monthly",        "on",        "2026-11-01",        Some("FREQ=MONTHLY;UNTIL=20261102T045959Z"),    ),    (        "America/New_York",        "monthly",        "after",        "1",        Some("FREQ=MONTHLY;COUNT=1"),    ),    (        "America/New_York",        "monthly",        "after",        "12",        Some("FREQ=MONTHLY;COUNT=12"),    ),    (        "America/New_York",        "yearly",        "never",        "",        Some("FREQ=YEARLY"),    ),    (        "America/New_York",        "yearly",        "on",        "2026-12-31",        Some("FREQ=YEARLY;UNTIL=20270101T045959Z"),    ),    (        "America/New_York",        "yearly",        "on",        "2026-03-29",        Some("FREQ=YEARLY;UNTIL=20260330T035959Z"),    ),    (        "America/New_York",        "yearly",        "on",        "2026-11-01",        Some("FREQ=YEARLY;UNTIL=20261102T045959Z"),    ),    (        "America/New_York",        "yearly",        "after",        "1",        Some("FREQ=YEARLY;COUNT=1"),    ),    (        "America/New_York",        "yearly",        "after",        "12",        Some("FREQ=YEARLY;COUNT=12"),    ),    ("UTC", "none", "never", "", None),    ("UTC", "none", "on", "2026-12-31", None),    ("UTC", "none", "on", "2026-03-29", None),    ("UTC", "none", "on", "2026-11-01", None),    ("UTC", "none", "after", "1", None),    ("UTC", "none", "after", "12", None),    ("UTC", "daily", "never", "", Some("FREQ=DAILY")),    (        "UTC",        "daily",        "on",        "2026-12-31",        Some("FREQ=DAILY;UNTIL=20261231T235959Z"),    ),    (        "UTC",        "daily",        "on",        "2026-03-29",        Some("FREQ=DAILY;UNTIL=20260329T235959Z"),    ),    (        "UTC",        "daily",        "on",        "2026-11-01",        Some("FREQ=DAILY;UNTIL=20261101T235959Z"),    ),    ("UTC", "daily", "after", "1", Some("FREQ=DAILY;COUNT=1")),    ("UTC", "daily", "after", "12", Some("FREQ=DAILY;COUNT=12")),    (        "UTC",        "weekdays",        "never",        "",        Some("FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR"),    ),    (        "UTC",        "weekdays",        "on",        "2026-12-31",        Some("FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR;UNTIL=20261231T235959Z"),    ),    (        "UTC",        "weekdays",        "on",        "2026-03-29",        Some("FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR;UNTIL=20260329T235959Z"),    ),    (        "UTC",        "weekdays",        "on",        "2026-11-01",        Some("FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR;UNTIL=20261101T235959Z"),    ),    (        "UTC",        "weekdays",        "after",        "1",        Some("FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR;COUNT=1"),    ),    (        "UTC",        "weekdays",        "after",        "12",        Some("FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR;COUNT=12"),    ),    ("UTC", "weekly", "never", "", Some("FREQ=WEEKLY")),    (        "UTC",        "weekly",        "on",        "2026-12-31",        Some("FREQ=WEEKLY;UNTIL=20261231T235959Z"),    ),    (        "UTC",        "weekly",        "on",        "2026-03-29",        Some("FREQ=WEEKLY;UNTIL=20260329T235959Z"),    ),    (        "UTC",        "weekly",        "on",        "2026-11-01",        Some("FREQ=WEEKLY;UNTIL=20261101T235959Z"),    ),    ("UTC", "weekly", "after", "1", Some("FREQ=WEEKLY;COUNT=1")),    ("UTC", "weekly", "after", "12", Some("FREQ=WEEKLY;COUNT=12")),    (        "UTC",        "biweekly",        "never",        "",        Some("FREQ=WEEKLY;INTERVAL=2"),    ),    (        "UTC",        "biweekly",        "on",        "2026-12-31",        Some("FREQ=WEEKLY;INTERVAL=2;UNTIL=20261231T235959Z"),    ),    (        "UTC",        "biweekly",        "on",        "2026-03-29",        Some("FREQ=WEEKLY;INTERVAL=2;UNTIL=20260329T235959Z"),    ),    (        "UTC",        "biweekly",        "on",        "2026-11-01",        Some("FREQ=WEEKLY;INTERVAL=2;UNTIL=20261101T235959Z"),    ),    (        "UTC",        "biweekly",        "after",        "1",        Some("FREQ=WEEKLY;INTERVAL=2;COUNT=1"),    ),    (        "UTC",        "biweekly",        "after",        "12",        Some("FREQ=WEEKLY;INTERVAL=2;COUNT=12"),    ),    ("UTC", "monthly", "never", "", Some("FREQ=MONTHLY")),    (        "UTC",        "monthly",        "on",        "2026-12-31",        Some("FREQ=MONTHLY;UNTIL=20261231T235959Z"),    ),    (        "UTC",        "monthly",        "on",        "2026-03-29",        Some("FREQ=MONTHLY;UNTIL=20260329T235959Z"),    ),    (        "UTC",        "monthly",        "on",        "2026-11-01",        Some("FREQ=MONTHLY;UNTIL=20261101T235959Z"),    ),    ("UTC", "monthly", "after", "1", Some("FREQ=MONTHLY;COUNT=1")),    (        "UTC",        "monthly",        "after",        "12",        Some("FREQ=MONTHLY;COUNT=12"),    ),    ("UTC", "yearly", "never", "", Some("FREQ=YEARLY")),    (        "UTC",        "yearly",        "on",        "2026-12-31",        Some("FREQ=YEARLY;UNTIL=20261231T235959Z"),    ),    (        "UTC",        "yearly",        "on",        "2026-03-29",        Some("FREQ=YEARLY;UNTIL=20260329T235959Z"),    ),    (        "UTC",        "yearly",        "on",        "2026-11-01",        Some("FREQ=YEARLY;UNTIL=20261101T235959Z"),    ),    ("UTC", "yearly", "after", "1", Some("FREQ=YEARLY;COUNT=1")),    ("UTC", "yearly", "after", "12", Some("FREQ=YEARLY;COUNT=12")),];/// `(zone, rule, expected preset, expected end)` — straight out of Node.#[allow(clippy::type_complexity)]fn split_vectors() -> Vec<(    &'static str,    Option<&'static str>,    PresetOrCustom,    RecurrenceEnd,)> {    vec![        (            "Asia/Kolkata",            None,            PresetOrCustom::Preset(RecurrencePreset::None),            RecurrenceEnd::Never,        ),        (            "Asia/Kolkata",            Some("FREQ=DAILY"),            PresetOrCustom::Preset(RecurrencePreset::Daily),            RecurrenceEnd::Never,        ),        (            "Asia/Kolkata",            Some("FREQ=DAILY;COUNT=5"),            PresetOrCustom::Preset(RecurrencePreset::Daily),            RecurrenceEnd::After(5),        ),        (            "Asia/Kolkata",            Some("FREQ=DAILY;UNTIL=20261231T182959Z"),            PresetOrCustom::Preset(RecurrencePreset::Daily),            RecurrenceEnd::On("2026-12-31".to_string()),        ),        (            "Asia/Kolkata",            Some("FREQ=DAILY;UNTIL=20261231T182959Z;COUNT=5"),            PresetOrCustom::Custom,            RecurrenceEnd::Never,        ),        (            "Asia/Kolkata",            Some("FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR;COUNT=3"),            PresetOrCustom::Preset(RecurrencePreset::Weekdays),            RecurrenceEnd::After(3),        ),        (            "Asia/Kolkata",            Some("FREQ=MONTHLY;BYDAY=2TU"),            PresetOrCustom::Custom,            RecurrenceEnd::Never,        ),        (            "Asia/Kolkata",            Some("RRULE:FREQ=YEARLY;UNTIL=20301231T000000Z"),            PresetOrCustom::Preset(RecurrencePreset::Yearly),            RecurrenceEnd::On("2030-12-31".to_string()),        ),        (            "Asia/Kolkata",            Some("FREQ=DAILY;COUNT=0"),            PresetOrCustom::Custom,            RecurrenceEnd::Never,        ),        (            "Asia/Kolkata",            Some("FREQ=DAILY;COUNT=abc"),            PresetOrCustom::Custom,            RecurrenceEnd::Never,        ),        (            "Asia/Kolkata",            Some("FREQ=DAILY;UNTIL=nonsense"),            PresetOrCustom::Custom,            RecurrenceEnd::Never,        ),        (            "Asia/Kolkata",            Some("FREQ=WEEKLY;INTERVAL=2;COUNT=4"),            PresetOrCustom::Preset(RecurrencePreset::Biweekly),            RecurrenceEnd::After(4),        ),        (            "Asia/Kolkata",            Some("  freq=weekly ; interval=2 "),            PresetOrCustom::Preset(RecurrencePreset::Biweekly),            RecurrenceEnd::Never,        ),        (            "Asia/Kolkata",            Some("FREQ=DAILY;NOPE"),            PresetOrCustom::Custom,            RecurrenceEnd::Never,        ),        (            "UTC",            None,            PresetOrCustom::Preset(RecurrencePreset::None),            RecurrenceEnd::Never,        ),        (            "UTC",            Some("FREQ=DAILY"),            PresetOrCustom::Preset(RecurrencePreset::Daily),            RecurrenceEnd::Never,        ),        (            "UTC",            Some("FREQ=DAILY;COUNT=5"),            PresetOrCustom::Preset(RecurrencePreset::Daily),            RecurrenceEnd::After(5),        ),        (            "UTC",            Some("FREQ=DAILY;UNTIL=20261231T182959Z"),            PresetOrCustom::Preset(RecurrencePreset::Daily),            RecurrenceEnd::On("2026-12-31".to_string()),        ),        (            "UTC",            Some("FREQ=DAILY;UNTIL=20261231T182959Z;COUNT=5"),            PresetOrCustom::Custom,            RecurrenceEnd::Never,        ),        (            "UTC",            Some("FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR;COUNT=3"),            PresetOrCustom::Preset(RecurrencePreset::Weekdays),            RecurrenceEnd::After(3),        ),        (            "UTC",            Some("FREQ=MONTHLY;BYDAY=2TU"),            PresetOrCustom::Custom,            RecurrenceEnd::Never,        ),        (            "UTC",            Some("RRULE:FREQ=YEARLY;UNTIL=20301231T000000Z"),            PresetOrCustom::Preset(RecurrencePreset::Yearly),            RecurrenceEnd::On("2030-12-31".to_string()),        ),        (            "UTC",            Some("FREQ=DAILY;COUNT=0"),            PresetOrCustom::Custom,            RecurrenceEnd::Never,        ),        (            "UTC",            Some("FREQ=DAILY;COUNT=abc"),            PresetOrCustom::Custom,            RecurrenceEnd::Never,        ),        (            "UTC",            Some("FREQ=DAILY;UNTIL=nonsense"),            PresetOrCustom::Custom,            RecurrenceEnd::Never,        ),        (            "UTC",            Some("FREQ=WEEKLY;INTERVAL=2;COUNT=4"),            PresetOrCustom::Preset(RecurrencePreset::Biweekly),            RecurrenceEnd::After(4),        ),        (            "UTC",            Some("  freq=weekly ; interval=2 "),            PresetOrCustom::Preset(RecurrencePreset::Biweekly),            RecurrenceEnd::Never,        ),        (            "UTC",            Some("FREQ=DAILY;NOPE"),            PresetOrCustom::Custom,            RecurrenceEnd::Never,        ),        (            "America/New_York",            None,            PresetOrCustom::Preset(RecurrencePreset::None),            RecurrenceEnd::Never,        ),        (            "America/New_York",            Some("FREQ=DAILY"),            PresetOrCustom::Preset(RecurrencePreset::Daily),            RecurrenceEnd::Never,        ),        (            "America/New_York",            Some("FREQ=DAILY;COUNT=5"),            PresetOrCustom::Preset(RecurrencePreset::Daily),            RecurrenceEnd::After(5),        ),        (            "America/New_York",            Some("FREQ=DAILY;UNTIL=20261231T182959Z"),            PresetOrCustom::Preset(RecurrencePreset::Daily),            RecurrenceEnd::On("2026-12-31".to_string()),        ),        (            "America/New_York",            Some("FREQ=DAILY;UNTIL=20261231T182959Z;COUNT=5"),            PresetOrCustom::Custom,            RecurrenceEnd::Never,        ),        (            "America/New_York",            Some("FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR;COUNT=3"),            PresetOrCustom::Preset(RecurrencePreset::Weekdays),            RecurrenceEnd::After(3),        ),        (            "America/New_York",            Some("FREQ=MONTHLY;BYDAY=2TU"),            PresetOrCustom::Custom,            RecurrenceEnd::Never,        ),        (            "America/New_York",            Some("RRULE:FREQ=YEARLY;UNTIL=20301231T000000Z"),            PresetOrCustom::Preset(RecurrencePreset::Yearly),            RecurrenceEnd::On("2030-12-30".to_string()),        ),        (            "America/New_York",            Some("FREQ=DAILY;COUNT=0"),            PresetOrCustom::Custom,            RecurrenceEnd::Never,        ),        (            "America/New_York",            Some("FREQ=DAILY;COUNT=abc"),            PresetOrCustom::Custom,            RecurrenceEnd::Never,        ),        (            "America/New_York",            Some("FREQ=DAILY;UNTIL=nonsense"),            PresetOrCustom::Custom,            RecurrenceEnd::Never,        ),        (            "America/New_York",            Some("FREQ=WEEKLY;INTERVAL=2;COUNT=4"),            PresetOrCustom::Preset(RecurrencePreset::Biweekly),            RecurrenceEnd::After(4),        ),        (            "America/New_York",            Some("  freq=weekly ; interval=2 "),            PresetOrCustom::Preset(RecurrencePreset::Biweekly),            RecurrenceEnd::Never,        ),        (            "America/New_York",            Some("FREQ=DAILY;NOPE"),            PresetOrCustom::Custom,            RecurrenceEnd::Never,        ),    ]}// ── the TypeScript's own cases ───────────────────────────────────────────────#[test]fn round_trips_every_preset() {    for preset in RecurrencePreset::ALL {        assert_eq!(            preset_for_rrule(rrule_for_preset(preset)),            PresetOrCustom::Preset(preset),            "{preset}"        );    }}#[test]fn maps_none_to_a_null_rule() {    assert_eq!(rrule_for_preset(RecurrencePreset::None), None);    assert_eq!(        preset_for_rrule(None),        PresetOrCustom::Preset(RecurrencePreset::None)    );}#[test]fn tolerates_the_rrule_prefix_and_case_on_read() {    assert_eq!(        preset_for_rrule(Some("rrule:freq=monthly")),        PresetOrCustom::Preset(RecurrencePreset::Monthly)    );    assert_eq!(        preset_for_rrule(Some("RRULE:FREQ=YEARLY")),        PresetOrCustom::Preset(RecurrencePreset::Yearly)    );    // And surrounding whitespace, which the TypeScript trims AFTER the prefix.    assert_eq!(        preset_for_rrule(Some("  FREQ=DAILY  ")),        PresetOrCustom::Preset(RecurrencePreset::Daily)    );    // A prefix that is not at the start is not a prefix — `/^RRULE:/i` is    // anchored, so the leading spaces make this custom on both sides.    assert_eq!(        preset_for_rrule(Some("  rrule:freq=monthly")),        PresetOrCustom::Custom    );}#[test]fn reports_anything_beyond_the_presets_as_custom_never_rewrites() {    for rule in [        "FREQ=WEEKLY;BYDAY=MO,WE",        "FREQ=MONTHLY;INTERVAL=3",        "FREQ=DAILY;COUNT=5",        "",    ] {        assert_eq!(            preset_for_rrule(Some(rule)),            PresetOrCustom::Custom,            "{rule}"        );    }}/// The identifiers are wire strings, so they are pinned rather than derived.#[test]fn the_preset_identifiers_are_the_typescripts_own() {    assert_eq!(        RecurrencePreset::ALL.map(|p| p.as_str()),        ["none", "daily", "weekdays", "weekly", "biweekly", "monthly", "yearly"]    );    assert_eq!(RECURRENCE_END_KINDS, ["never", "on", "after"]);    for preset in RecurrencePreset::ALL {        assert_eq!(RecurrencePreset::parse(preset.as_str()), Some(preset));    }    assert_eq!(RecurrencePreset::parse("custom"), None);    assert_eq!(PresetOrCustom::Custom.as_str(), "custom");}// ── compose_rrule ────────────────────────────────────────────────────────────#[test]fn compose_rrule_matches_node_across_four_zones() {    for (zone, preset, kind, key, expected) in COMPOSED {        let preset = RecurrencePreset::parse(preset).expect("a known preset");        let end = match *kind {            "never" => RecurrenceEnd::Never,            "on" => RecurrenceEnd::On((*key).to_string()),            "after" => RecurrenceEnd::After(key.parse().expect("a count")),            other => panic!("unknown end kind {other}"),        };        assert_eq!(            compose_rrule(preset, &end, zone).expect("a composable end"),            expected.map(str::to_string),            "compose_rrule({preset}, {kind}={key}, {zone})"        );    }}/// `none` has nothing to end, so its end is IGNORED rather than refused: a/// person who set "after 5" and then chose "Once" has stopped repeating, not/// made a contradiction. (Which is why even a nonsense end composes to `None`.)#[test]fn none_ignores_its_end_rather_than_refusing_it() {    for end in [        RecurrenceEnd::Never,        RecurrenceEnd::On("not a date".to_string()),        RecurrenceEnd::After(0),    ] {        assert_eq!(            compose_rrule(RecurrencePreset::None, &end, "UTC"),            Ok(None),            "{end:?}"        );    }}#[test]fn compose_rrule_refuses_what_node_refuses_in_the_same_words() {    for bad in ["2026-1-1", "not a date", "", "2026-12-31T00:00:00Z"] {        let refusal = compose_rrule(            RecurrencePreset::Daily,            &RecurrenceEnd::On(bad.to_string()),            "UTC",        )        .expect_err("not a date key");        assert_eq!(refusal.to_string(), format!("not a date key: \"{bad}\""));    }    // A padded key is TRIMMED and accepted — the TypeScript trims before the    // pattern, and Node agrees this composes.    assert_eq!(        compose_rrule(            RecurrencePreset::Daily,            &RecurrenceEnd::On(" 2026-12-31 ".to_string()),            "UTC"        ),        Ok(Some("FREQ=DAILY;UNTIL=20261231T235959Z".to_string()))    );    for bad in [0_i64, -1] {        let refusal = compose_rrule(RecurrencePreset::Daily, &RecurrenceEnd::After(bad), "UTC")            .expect_err("not an occurrence count");        assert_eq!(            refusal.to_string(),            format!("not an occurrence count: {bad}")        );    }}// ── split_rrule ──────────────────────────────────────────────────────────────#[test]fn split_rrule_matches_node_across_three_zones() {    for (zone, rule, expected_preset, expected_end) in split_vectors() {        assert_eq!(            split_rrule(rule, zone).expect("a known zone"),            (expected_preset, expected_end.clone()),            "split_rrule({rule:?}, {zone})"        );    }}/// The round trip an edit screen depends on: compose an ending, split it back,/// get the same day the person named — in the zone they named it in.#[test]fn an_end_composed_in_a_zone_splits_back_to_the_same_day_in_that_zone() {    for zone in ["Asia/Kolkata", "Europe/London", "America/New_York", "UTC"] {        for day in ["2026-12-31", "2026-03-29", "2026-11-01", "2026-06-15"] {            let composed = compose_rrule(                RecurrencePreset::Weekly,                &RecurrenceEnd::On(day.to_string()),                zone,            )            .expect("a composable end")            .expect("a rule");            assert_eq!(                split_rrule(Some(&composed), zone).expect("a known zone"),                (                    PresetOrCustom::Preset(RecurrencePreset::Weekly),                    RecurrenceEnd::On(day.to_string())                ),                "{zone} / {day} / {composed}"            );        }    }}#[test]fn a_count_composed_splits_back_to_the_same_count() {    for count in [1_i64, 2, 12, 365] {        let composed = compose_rrule(            RecurrencePreset::Biweekly,            &RecurrenceEnd::After(count),            "UTC",        )        .expect("a composable end")        .expect("a rule");        assert_eq!(            split_rrule(Some(&composed), "UTC").expect("a known zone"),            (                PresetOrCustom::Preset(RecurrencePreset::Biweekly),                RecurrenceEnd::After(count)            )        );    }}/// RULE: a repeat is said by its line in set `dates`, never a word compiled/// here — every preset and the custom rule name a line the kit ships, and a/// rule that does not repeat names none.#[test]fn a_repeat_names_a_dates_line() {    let rules = ["FREQ=DAILY", "FREQ=WEEKLY;BYDAY=MO,TU,WE,TH,FR", "FREQ=WEEKLY", "FREQ=WEEKLY;INTERVAL=2", "FREQ=MONTHLY", "FREQ=YEARLY", "FREQ=MONTHLY;BYDAY=2TU"];    for rule in rules {        let line = repeat_line(Some(rule)).expect("a repeat");        assert!(crate::rules::shell_lines::resolve("dates", line, &[], &[]).is_some_and(|words| !words.is_empty()), "{rule} → {line}");    }    assert_eq!(repeat_line(Some("FREQ=WEEKLY;INTERVAL=2")), Some("repeat.biweekly"));    assert_eq!(repeat_line(None), None);    assert_eq!(repeat_line(Some("  ")), None);}