pike.git / lib / modules / Calendar.pmod / testsuite.in

version» Context lines:

pike.git/lib/modules/Calendar.pmod/testsuite.in:1: - dnl $Id: testsuite.in,v 1.11 2004/01/10 22:52:29 nilsson Exp $ + dnl $Id: testsuite.in,v 1.12 2008/01/28 20:50:03 mast Exp $      dnl NOTE:   dnl *every* time the Calendar tests have failed, it's not the   dnl Calendar module that had any errors. Please don't commit   dnl your Pike until you've got Calendar to compile again. /Mirar      test_true(Calendar.Day())      test_eq([[Calendar.Austrian.Day(2500000)->month_day()]],31)   test_eq([[Calendar.Coptic.Day(2500000)->month_day()]],25);
pike.git/lib/modules/Calendar.pmod/testsuite.in:111:   test_day("2003-12-31 Wed 2004w01")   test_day("2004-01-01 Thu 2004w01")      test_eq([[ Calendar.ISO.Week(2001, 1)->format_ymd() ]], "2001-01-01")   test_eq([[ Calendar.ISO.Week(2002, 1)->format_ymd() ]], "2001-12-31")   test_eq([[ Calendar.ISO.Week(2003, 1)->format_ymd() ]], "2002-12-30")   test_eq([[ Calendar.ISO.Week(2004, 1)->format_ymd() ]], "2003-12-29")   test_eq([[ Calendar.ISO.Week(2005, 1)->format_ymd() ]], "2005-01-03")      test_eq([[Calendar.Language["swe"]->week_day_name_from_number(1)]], "mÃ¥ndag") +  + test_eq([[Calendar.ISO.Day (2007, 12, 31)->week()->month_day()]], 31); + test_any([[ +  object d = Calendar.ISO.Day (2007, 12, 01); +  d->week_day(); +  return d->range (d)->week()->year_no(); + ]], 2007) +  + test_eq([[(Calendar.ISO.Week (2007, 52) + 1)->year_no()]], 2008) +  + test_eq([[Calendar.ISO.Week (2007, 1)->distance (Calendar.ISO.Week (2008, 1))->number_of_weeks()]], 52) +  + dnl Note: YMD.year and YMD.years are zero based, as opposed to the others. + dnl It's uncertain whether that is due to design or mistake, but we'll have + dnl to leave it at that anyway for compatibility. + test_eq([[Calendar.ISO.Year(2007)->year()->year_no()]], 2007) + test_eq([[Calendar.ISO.Year(2007)->year(0)->year_no()]], 2007) + test_eq([[Calendar.ISO.Year(2007)->year(-1)->year_no()]], 2007) + test_eq([[Calendar.ISO.Year(2007)->set_size(2)->year()->year_no()]], 2007) + test_eq([[Calendar.ISO.Year(2007)->set_size(2)->year(0)->year_no()]], 2007) + test_eq([[Calendar.ISO.Year(2007)->set_size(2)->year(1)->year_no()]], 2008) + test_eq([[Calendar.ISO.Year(2007)->set_size(2)->year(-2)->year_no()]], 2007) + test_eq([[Calendar.ISO.Year(2007)->set_size(2)->year(-1)->year_no()]], 2008) + test_equal([[Calendar.ISO.Year(2007)->set_size(2)->years()->year_no()]], ({2007, 2008})) + test_equal([[Calendar.ISO.Year(2007)->set_size(2)->years(0,0)->year_no()]], ({2007})) + test_equal([[Calendar.ISO.Year(2007)->set_size(2)->years(1,1)->year_no()]], ({2008})) + test_equal([[Calendar.ISO.Year(2007)->set_size(2)->years(0,1)->year_no()]], ({2007, 2008})) + test_equal([[Calendar.ISO.Year(2007)->set_size(2)->years(-1,1)->year_no()]], ({2007, 2008})) + test_equal([[Calendar.ISO.Year(2007)->set_size(2)->years(0,2)->year_no()]], ({2007, 2008})) +  + test_eq([[Calendar.ISO.Month(2007,7)->month()->month_no()]], 7) + test_eq([[Calendar.ISO.Month(2007,7)->month(1)->month_no()]], 7) + test_eq([[Calendar.ISO.Month(2007,7)->month(-1)->month_no()]], 7) + test_eq([[Calendar.ISO.Month(2007,7)->set_size(2)->month()->month_no()]], 7) + test_eq([[Calendar.ISO.Month(2007,7)->set_size(2)->month(1)->month_no()]], 7) + test_eq([[Calendar.ISO.Month(2007,7)->set_size(2)->month(2)->month_no()]], 8) + test_eq([[Calendar.ISO.Month(2007,7)->set_size(2)->month(-2)->month_no()]], 7) + test_eq([[Calendar.ISO.Month(2007,7)->set_size(2)->month(-1)->month_no()]], 8) + test_equal([[Calendar.ISO.Month(2007,7)->set_size(2)->months()->month_no()]], ({7, 8})) + test_equal([[Calendar.ISO.Month(2007,7)->set_size(2)->months(1,1)->month_no()]], ({7})) + test_equal([[Calendar.ISO.Month(2007,7)->set_size(2)->months(2,2)->month_no()]], ({8})) + test_equal([[Calendar.ISO.Month(2007,7)->set_size(2)->months(1,2)->month_no()]], ({7, 8})) + test_equal([[Calendar.ISO.Month(2007,7)->set_size(2)->months(0,2)->month_no()]], ({7, 8})) + test_equal([[Calendar.ISO.Month(2007,7)->set_size(2)->months(1,3)->month_no()]], ({7, 8})) +  + test_eq([[Calendar.ISO.Week(2007,7)->week()->week_no()]], 7) + test_eq([[Calendar.ISO.Week(2007,7)->week(1)->week_no()]], 7) + test_eq([[Calendar.ISO.Week(2007,7)->week(-1)->week_no()]], 7) + test_eq([[Calendar.ISO.Week(2007,7)->set_size(2)->week()->week_no()]], 7) + test_eq([[Calendar.ISO.Week(2007,7)->set_size(2)->week(1)->week_no()]], 7) + test_eq([[Calendar.ISO.Week(2007,7)->set_size(2)->week(2)->week_no()]], 8) + test_eq([[Calendar.ISO.Week(2007,7)->set_size(2)->week(-2)->week_no()]], 7) + test_eq([[Calendar.ISO.Week(2007,7)->set_size(2)->week(-1)->week_no()]], 8) + test_equal([[Calendar.ISO.Week(2007,7)->set_size(2)->weeks()->week_no()]], ({7, 8})) + test_equal([[Calendar.ISO.Week(2007,7)->set_size(2)->weeks(1,1)->week_no()]], ({7})) + test_equal([[Calendar.ISO.Week(2007,7)->set_size(2)->weeks(2,2)->week_no()]], ({8})) + test_equal([[Calendar.ISO.Week(2007,7)->set_size(2)->weeks(1,2)->week_no()]], ({7, 8})) + test_equal([[Calendar.ISO.Week(2007,7)->set_size(2)->weeks(0,2)->week_no()]], ({7, 8})) + test_equal([[Calendar.ISO.Week(2007,7)->set_size(2)->weeks(1,3)->week_no()]], ({7, 8})) +  + test_eq([[Calendar.ISO.Day(2007,7,7)->day()->month_day()]], 7) + test_eq([[Calendar.ISO.Day(2007,7,7)->day(1)->month_day()]], 7) + test_eq([[Calendar.ISO.Day(2007,7,7)->day(-1)->month_day()]], 7) + test_eq([[Calendar.ISO.Day(2007,7,7)->set_size(2)->day()->month_day()]], 7) + test_eq([[Calendar.ISO.Day(2007,7,7)->set_size(2)->day(1)->month_day()]], 7) + test_eq([[Calendar.ISO.Day(2007,7,7)->set_size(2)->day(2)->month_day()]], 8) + test_eq([[Calendar.ISO.Day(2007,7,7)->set_size(2)->day(-2)->month_day()]], 7) + test_eq([[Calendar.ISO.Day(2007,7,7)->set_size(2)->day(-1)->month_day()]], 8) + test_equal([[Calendar.ISO.Day(2007,7,7)->set_size(2)->days()->month_day()]], ({7, 8})) + test_equal([[Calendar.ISO.Day(2007,7,7)->set_size(2)->days(1,1)->month_day()]], ({7})) + test_equal([[Calendar.ISO.Day(2007,7,7)->set_size(2)->days(2,2)->month_day()]], ({8})) + test_equal([[Calendar.ISO.Day(2007,7,7)->set_size(2)->days(1,2)->month_day()]], ({7, 8})) + test_equal([[Calendar.ISO.Day(2007,7,7)->set_size(2)->days(0,2)->month_day()]], ({7, 8})) + test_equal([[Calendar.ISO.Day(2007,7,7)->set_size(2)->days(1,3)->month_day()]], ({7, 8})) +  + test_eq([[Calendar.ISO.Week (2008, 1)->year_no()]], 2008) + test_eq([[Calendar.ISO.Week (2008, 1)->year_day()]], 0) + test_equal([[Calendar.ISO.Week ("julian", 2454466)->format_iso_week()]], "2008-W01") + test_eq([[Calendar.ISO.Week (2008, 1)->set_size (Calendar.ISO.Day())->format_ymd()]], "2007-12-31") + test_eq([[Calendar.ISO.Day (2007, 12, 31)->format_iso_week()]], "2008-W01") + test_eq([[Calendar.ISO.Day (2007, 12, 31)->format_iso_week_short()]], "200801") +  + dnl NOTE: The following tests just documents how the code behaves, NOT + dnl how it should behave. Some of these are questionable, others are + dnl clearly wrong. But trying to fix them is like opening a can of + dnl worms and imho not possible to do without rethinking things a bit + dnl and introducing some incompatibilities. That has been done in pike + dnl >= 7.7. /mast + test_eq([[Calendar.ISO.Day (2007, 12, 31)->set_size (Calendar.ISO.Week())->format_iso_week()]], "2007-W01") + test_eq([[Calendar.ISO.Day (2007, 12, 31)->set_size (Calendar.ISO.Week())->year_no()]], 2007) + test_eq([[Calendar.ISO.Week (2008, 1)->set_size (Calendar.ISO.Day())->year_no()]], 2008) + test_equal([[ +  Calendar.ISO.Week (2008, 1)->datetime() - (["timezone": 1, "unix": 1]) + ]], [[ +  ([ +  "day": 31, +  "fraction": 0.0, +  "hour": 0, +  "julian": 2454466, +  "minute": 0, +  "month": 12, +  "second": 0, +  "week": 1, +  "week_day": 1, +  "year": 2008, +  "yearday": -1 +  ]) + ]]) + test_equal([[Calendar.ISO.Day (Calendar.ISO.Week(2008,1))->years()->year_no()]], ({2007, 2008})) + test_equal([[Calendar.ISO.Month (Calendar.ISO.Week(2008,1))->years()->year_no()]], ({2007, 2008})) + test_equal([[Calendar.ISO.Year (Calendar.ISO.Week(2008,1))->years()->year_no()]], ({2007})) + test_equal([[Calendar.ISO.Week(2008,1)->years()->year_no()]], ({2008})) + test_equal([[Calendar.ISO.Week(2008,1)->number_of_years()]], 1) + test_eq([[Calendar.ISO.Year (Calendar.ISO.Week (2008, 1))->year_no()]], 2007) + test_eq([[Calendar.ISO.Year (Calendar.ISO.Week (2008, 1))->number_of_years()]], 1) + test_equal([[Calendar.ISO.Year (Calendar.ISO.Week (2008, 1))->years()->year_no()]], ({2007}))