hare

[hare] The Hare programming language
git clone https://git.torresjrjr.com/hare.git
Log | Files | Refs | README | LICENSE

commit 575717749bee7c6a390d8d3917ceee7bb3195566
parent df3e31a41ac143c482fba791831a1097b34909e2
Author: Byron Torres <b@torresjrjr.com>
Date:   Sat, 11 Jun 2022 03:54:44 +0100

datetime: test calc_janfirstweekday()

Signed-off-by: Byron Torres <b@torresjrjr.com>

Diffstat:
Mdatetime/date.ha | 83+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 83 insertions(+), 0 deletions(-)

diff --git a/datetime/date.ha b/datetime/date.ha @@ -611,3 +611,86 @@ fn calc_date_from_yd(y: int, yd: int) (chrono::date | invalid) = { assert(expect == actual, "weekday miscalculation"); }; }; + +@test fn calc_janfirstweekday() void = { + const cases = [ + // year weekday + (1969, 3), + (1970, 4), + (1971, 5), + (1972, 6), + (1973, 1), + (1974, 2), + (1975, 3), + (1976, 4), + (1977, 6), + (1978, 7), + (1979, 1), + (1980, 2), + (1981, 4), + (1982, 5), + (1983, 6), + (1984, 7), + (1985, 2), + (1986, 3), + (1987, 4), + (1988, 5), + (1989, 7), + (1990, 1), + (1991, 2), + (1992, 3), + (1993, 5), + (1994, 6), + (1995, 7), + (1996, 1), + (1997, 3), + (1998, 4), + (1999, 5), + (2000, 6), + (2001, 1), + (2002, 2), + (2003, 3), + (2004, 4), + (2005, 6), + (2006, 7), + (2007, 1), + (2008, 2), + (2009, 4), + (2010, 5), + (2011, 6), + (2012, 7), + (2013, 2), + (2014, 3), + (2015, 4), + (2016, 5), + (2017, 7), + (2018, 1), + (2019, 2), + (2020, 3), + (2021, 5), + (2022, 6), + (2023, 7), + (2024, 1), + (2025, 3), + (2026, 4), + (2027, 5), + (2028, 6), + (2029, 1), + (2030, 2), + (2031, 3), + (2032, 4), + (2033, 6), + (2034, 7), + (2035, 1), + (2036, 2), + (2037, 4), + (2038, 5), + (2039, 6), + ]; + for (let i = 0z; i < len(cases); i += 1) { + const paramt = cases[i].0; + const expect = cases[i].1; + const actual = calc_janfirstweekday(paramt); + assert(expect == actual, "calc_janfirstweekday() miscalculation"); + }; +};