0bb2072003-02-11Johan Sundström dnl $Id: testsuite.in,v 1.6 2003/02/11 15:59:58 jhs Exp $
a2eeac2002-11-28Martin Nilsson  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.Gregorian.Day(2500000)->month_day()]],31) test_eq([[Calendar.ISO.Day(2500000)->month_day()]],31) test_eq([[Calendar.Julian.Day(2500000)->month_day()]],17) test_eq([[(int)(Calendar.Stardate.Tick("julian",2500000)->tic())]],-190335) test_eq(Calendar.ISO.Week(2002,1)->day()->format_ymd(),"2001-12-31")
c7f6a22002-11-21Johan Sundström  test_eval_error(Calendar.ISO.set_timezone("Europe/Stockholm") ->dwim_time("2000-03-26 23:01:17")) test_eq(Calendar.ISO_UTC.dwim_time("2000-03-26 23:01:17")->unix_time(), 954111677) test_do(Calendar.TimeRange t = Calendar.now()) dnl Some more or less odd timezones encountered by Xenofarm: test_do(Calendar.dwim_time("Tue Nov 19 07:04:03 MET 2002")) test_do(Calendar.dwim_time("Tue Nov 19 07:04:03 CST 2002")) test_do(Calendar.dwim_time("Tue Nov 19 07:04:03 CET 2002")) test_do(Calendar.dwim_time("Tue Nov 19 07:04:03 2002")) test_do(Calendar.dwim_time("Tue Nov 19 07:04:03 NFT 2002")) test_do(Calendar.dwim_time("Tue Nov 19 07:04:03 DFT 2002"))
9d27802002-11-23Johan Sundström  test_eq(arrayp(Calendar.TZnames.zonenames()), 1)
a2eeac2002-11-28Martin Nilsson  dnl FAQ tests test_eq( Calendar.dwim_day("1/2/3"), Calendar.Day(2003,1,2) ) test_eq( Calendar.dwim_day("1 aug 2001"), Calendar.Day(2001,8,1) ) test_false( Calendar.dwim_day("1 aug 2001")==Calendar.Day(2001,8,2) ) dnl Missing two dwim_time tests test_eq( Calendar.parse("%Y-%M-%D %h:%m","2040-11-08 2:46"), Calendar.Minute(2040,11,8,2,46) ) test_false( Calendar.parse("%Y w%W %e %h:%m %p %z","1913 w4 monday 2:14 pm CET")
8168ec2002-12-05Martin Nilsson  < Calendar.set_timezone("CET")->Minute(1913,1,20,14,14) )
a2eeac2002-11-28Martin Nilsson test_false( Calendar.parse("%Y w%W %e %h:%m %p %z","1913 w4 monday 2:14 pm CET")
8168ec2002-12-05Martin Nilsson  > Calendar.set_timezone("CET")->Minute(1913,1,20,14,14) )
a2eeac2002-11-28Martin Nilsson dnl The two objects above is not equal, which really is a bug.
c0e63f2002-12-11Martin Nilsson  dnl From verify.pike define(test_WDIFF,[[ test_true( $1->week_no() == $2->week_no() ) test_true( $1->week() == $2->week() ) test_true( $1->week()->year() == $2->week()->year() ) ]]) define(test_day,[[ test_do([[ sscanf($1,"%d-%d-%d %s %dw%d", int y,int m,int d,string wd,int wy,int w); add_constant("d1", Calendar.ISO.Day(y,m,d)); add_constant("d2", Calendar.ISO.dwim_day(y+"-"+m+"-"+d)); add_constant("d3", Calendar.ISO.Week(wy,w)->day(wd)); ]]) test_true( objectp(d1) ) test_true( objectp(d2) ) test_true( objectp(d3) ) test_true( d1==d2 ) test_true( d2==d3 ) test_true( d3==d1 ) test_WDIFF(d1,d2) test_WDIFF(d2,d3) test_WDIFF(d3,d1) test_any([[ sscanf($1,"%d-%d-%d %s %dw%d", int y,int m,int d,string wd,int wy,int w); return w; ]], d1->week_no()) test_any([[ sscanf($1,"%d-%d-%d %s %dw%d", int y,int m,int d,string wd,int wy,int w); return wy; ]], d1->week()->year_no()) test_do([[ add_constant("d1"); ]]) test_do([[ add_constant("d2"); ]]) test_do([[ add_constant("d3"); ]]) ]]) test_day("1993-12-31 Fri 1993w52") test_day("1994-01-01 Sat 1993w52") test_day("1994-12-31 Sat 1994w52") test_day("1995-01-01 Sun 1994w52") test_day("1995-12-31 Sun 1995w52") test_day("1996-01-01 Mon 1996w01") test_day("1996-12-31 Tue 1997w01") test_day("1997-01-01 Wed 1997w01") test_day("1997-12-31 Wed 1998w01") test_day("1998-01-01 Thu 1998w01") test_day("1998-12-31 Thu 1998w53") test_day("1999-01-01 Fri 1998w53") test_day("1999-12-31 Fri 1999w52") test_day("2000-01-01 Sat 1999w52") test_day("2000-12-31 Sun 2000w52") test_day("2001-01-01 Mon 2001w01") test_day("2003-12-31 Wed 2004w01") test_day("2004-01-01 Thu 2004w01")
0bb2072003-02-11Johan Sundström  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")