Skip to content

Commit

Permalink
make table uniform
Browse files Browse the repository at this point in the history
  • Loading branch information
Manishearth committed Jan 5, 2024
1 parent 0325fb7 commit 6b63138
Showing 1 changed file with 54 additions and 51 deletions.
105 changes: 54 additions & 51 deletions components/calendar/src/hebrew.rs
Original file line number Diff line number Diff line change
Expand Up @@ -444,62 +444,65 @@ mod tests {
// specifically talk about Adar I in a leap year
const ADARI: u8 = 13;

// The leap years used in the tests below
/// The leap years used in the tests below
const LEAP_YEARS_IN_TESTS: [i32; 1] = [5782];
const ISO_HEBREW_DATE_PAIRS: [((i32, u8, u8), (u8, u8, i32)); 48] = [
((2021, 1, 10), (26, TEVET, 5781)),
((2021, 1, 25), (12, SHEVAT, 5781)),
((2021, 2, 10), (28, SHEVAT, 5781)),
((2021, 2, 25), (13, ADAR, 5781)),
((2021, 3, 10), (26, ADAR, 5781)),
((2021, 3, 25), (12, NISAN, 5781)),
((2021, 4, 10), (28, NISAN, 5781)),
((2021, 4, 25), (13, IYYAR, 5781)),
((2021, 5, 10), (28, IYYAR, 5781)),
((2021, 5, 25), (14, SIVAN, 5781)),
((2021, 6, 10), (30, SIVAN, 5781)),
((2021, 6, 25), (15, TAMMUZ, 5781)),
((2021, 7, 10), (1, AV, 5781)),
((2021, 7, 25), (16, AV, 5781)),
((2021, 8, 10), (2, ELUL, 5781)),
((2021, 8, 25), (17, ELUL, 5781)),
((2021, 9, 10), (4, TISHREI, 5782)),
((2021, 9, 25), (19, TISHREI, 5782)),
((2021, 10, 10), (4, ḤESHVAN, 5782)),
((2021, 10, 25), (19, ḤESHVAN, 5782)),
((2021, 11, 10), (6, KISLEV, 5782)),
((2021, 11, 25), (21, KISLEV, 5782)),
((2021, 12, 10), (6, TEVET, 5782)),
((2021, 12, 25), (21, TEVET, 5782)),
((2022, 1, 10), (8, SHEVAT, 5782)),
((2022, 1, 25), (23, SHEVAT, 5782)),
((2022, 2, 10), (9, ADARI, 5782)),
((2022, 2, 25), (24, ADARI, 5782)),
((2022, 3, 10), (7, ADAR, 5782)),
((2022, 3, 25), (22, ADAR, 5782)),
((2022, 4, 10), (9, NISAN, 5782)),
((2022, 4, 25), (24, NISAN, 5782)),
((2022, 5, 10), (9, IYYAR, 5782)),
((2022, 5, 25), (24, IYYAR, 5782)),
((2022, 6, 10), (11, SIVAN, 5782)),
((2022, 6, 25), (26, SIVAN, 5782)),
((2022, 7, 10), (11, TAMMUZ, 5782)),
((2022, 7, 25), (26, TAMMUZ, 5782)),
((2022, 8, 10), (13, AV, 5782)),
((2022, 8, 25), (28, AV, 5782)),
((2022, 9, 10), (14, ELUL, 5782)),
((2022, 9, 25), (29, ELUL, 5782)),
((2022, 10, 10), (15, TISHREI, 5783)),
((2022, 10, 25), (30, TISHREI, 5783)),
((2022, 11, 10), (16, ḤESHVAN, 5783)),
((2022, 11, 25), (1, KISLEV, 5783)),
((2022, 12, 10), (16, KISLEV, 5783)),
((2022, 12, 25), (1, TEVET, 5783)),
/// (iso, hebrew) pairs of testcases. If any of the years here
/// are leap years please add them to LEAP_YEARS_IN_TESTS (we have this manually
/// so we don't end up exercising potentially buggy codepaths to test this)
const ISO_HEBREW_DATE_PAIRS: [((i32, u8, u8), (i32, u8, u8)); 48] = [
((2021, 1, 10), (5781, TEVET, 26)),
((2021, 1, 25), (5781, SHEVAT, 12)),
((2021, 2, 10), (5781, SHEVAT, 28)),
((2021, 2, 25), (5781, ADAR, 13)),
((2021, 3, 10), (5781, ADAR, 26)),
((2021, 3, 25), (5781, NISAN, 12)),
((2021, 4, 10), (5781, NISAN, 28)),
((2021, 4, 25), (5781, IYYAR, 13)),
((2021, 5, 10), (5781, IYYAR, 28)),
((2021, 5, 25), (5781, SIVAN, 14)),
((2021, 6, 10), (5781, SIVAN, 30)),
((2021, 6, 25), (5781, TAMMUZ, 15)),
((2021, 7, 10), (5781, AV, 1)),
((2021, 7, 25), (5781, AV, 16)),
((2021, 8, 10), (5781, ELUL, 2)),
((2021, 8, 25), (5781, ELUL, 17)),
((2021, 9, 10), (5782, TISHREI, 4)),
((2021, 9, 25), (5782, TISHREI, 19)),
((2021, 10, 10), (5782, ḤESHVAN, 4)),
((2021, 10, 25), (5782, ḤESHVAN, 19)),
((2021, 11, 10), (5782, KISLEV, 6)),
((2021, 11, 25), (5782, KISLEV, 21)),
((2021, 12, 10), (5782, TEVET, 6)),
((2021, 12, 25), (5782, TEVET, 21)),
((2022, 1, 10), (5782, SHEVAT, 8)),
((2022, 1, 25), (5782, SHEVAT, 23)),
((2022, 2, 10), (5782, ADARI, 9)),
((2022, 2, 25), (5782, ADARI, 24)),
((2022, 3, 10), (5782, ADAR, 7)),
((2022, 3, 25), (5782, ADAR, 22)),
((2022, 4, 10), (5782, NISAN, 9)),
((2022, 4, 25), (5782, NISAN, 24)),
((2022, 5, 10), (5782, IYYAR, 9)),
((2022, 5, 25), (5782, IYYAR, 24)),
((2022, 6, 10), (5782, SIVAN, 11)),
((2022, 6, 25), (5782, SIVAN, 26)),
((2022, 7, 10), (5782, TAMMUZ, 11)),
((2022, 7, 25), (5782, TAMMUZ, 26)),
((2022, 8, 10), (5782, AV, 13)),
((2022, 8, 25), (5782, AV, 28)),
((2022, 9, 10), (5782, ELUL, 14)),
((2022, 9, 25), (5782, ELUL, 29)),
((2022, 10, 10), (5783, TISHREI, 15)),
((2022, 10, 25), (5783, TISHREI, 30)),
((2022, 11, 10), (5783, ḤESHVAN, 16)),
((2022, 11, 25), (5783, KISLEV, 1)),
((2022, 12, 10), (5783, KISLEV, 16)),
((2022, 12, 25), (5783, TEVET, 1)),
];

#[test]
fn test_conversions() {
for ((iso_y, iso_m, iso_d), (d, m, y)) in ISO_HEBREW_DATE_PAIRS.into_iter() {
for ((iso_y, iso_m, iso_d), (y, m, d)) in ISO_HEBREW_DATE_PAIRS.into_iter() {
let iso_date = Date::try_new_iso_date(iso_y, iso_m, iso_d).unwrap();
let month_code = if m == ADARI {
MonthCode(tinystr!(4, "M05L"))
Expand Down

0 comments on commit 6b63138

Please sign in to comment.