diff options
author | Lorry Tar Creator <lorry-tar-importer@baserock.org> | 2013-03-14 05:42:27 +0000 |
---|---|---|
committer | <> | 2013-04-03 16:25:08 +0000 |
commit | c4dd7a1a684490673e25aaf4fabec5df138854c4 (patch) | |
tree | 4d57c44caae4480efff02b90b9be86f44bf25409 /ext/calendar/tests | |
download | php2-master.tar.gz |
Imported from /home/lorry/working-area/delta_php2/php-5.4.13.tar.bz2.HEADphp-5.4.13master
Diffstat (limited to 'ext/calendar/tests')
25 files changed, 1246 insertions, 0 deletions
diff --git a/ext/calendar/tests/bug52744.phpt b/ext/calendar/tests/bug52744.phpt new file mode 100644 index 0000000..886086a --- /dev/null +++ b/ext/calendar/tests/bug52744.phpt @@ -0,0 +1,12 @@ +--TEST-- +Bug #52744 (cal_days_in_month incorrect for December 1 BCE) +--SKIPIF-- +<?php include 'skipif.inc'; ?> +--FILE-- +<?php +var_dump(cal_days_in_month(CAL_GREGORIAN, 12, -1)); +var_dump(cal_days_in_month(CAL_JULIAN, 12, -1)); +?> +--EXPECT-- +int(31) +int(31) diff --git a/ext/calendar/tests/bug53574_1.phpt b/ext/calendar/tests/bug53574_1.phpt new file mode 100644 index 0000000..51f9b42 --- /dev/null +++ b/ext/calendar/tests/bug53574_1.phpt @@ -0,0 +1,36 @@ +--TEST-- +Bug #53574 (Integer overflow in SdnToJulian; leads to segfault) +--SKIPIF-- +<?php +include 'skipif.inc'; +if (PHP_INT_SIZE != 4) { + die("skip this test is for 32bit platform only"); +} +?> +--FILE-- +<?php +$x = 882858043; + +var_dump(cal_from_jd($x, CAL_JULIAN)); +--EXPECT-- +array(9) { + ["date"]=> + string(5) "0/0/0" + ["month"]=> + int(0) + ["day"]=> + int(0) + ["year"]=> + int(0) + ["dow"]=> + int(5) + ["abbrevdayname"]=> + string(3) "Fri" + ["dayname"]=> + string(6) "Friday" + ["abbrevmonth"]=> + string(0) "" + ["monthname"]=> + string(0) "" +} + diff --git a/ext/calendar/tests/bug53574_2.phpt b/ext/calendar/tests/bug53574_2.phpt new file mode 100644 index 0000000..45e15cb --- /dev/null +++ b/ext/calendar/tests/bug53574_2.phpt @@ -0,0 +1,36 @@ +--TEST-- +Bug #53574 (Integer overflow in SdnToJulian; leads to segfault) +--SKIPIF-- +<?php +include 'skipif.inc'; +if (PHP_INT_SIZE == 4) { + die("skip this test is for 64bit platform only"); +} +?> +--FILE-- +<?php +$x = 3315881921229094912; + +var_dump(cal_from_jd($x, CAL_JULIAN)); +--EXPECT-- +array(9) { + ["date"]=> + string(5) "0/0/0" + ["month"]=> + int(0) + ["day"]=> + int(0) + ["year"]=> + int(0) + ["dow"]=> + int(3) + ["abbrevdayname"]=> + string(3) "Wed" + ["dayname"]=> + string(9) "Wednesday" + ["abbrevmonth"]=> + string(0) "" + ["monthname"]=> + string(0) "" +} + diff --git a/ext/calendar/tests/bug55797_1.phpt b/ext/calendar/tests/bug55797_1.phpt new file mode 100644 index 0000000..ffd617d --- /dev/null +++ b/ext/calendar/tests/bug55797_1.phpt @@ -0,0 +1,36 @@ +--TEST-- +Bug #55797: Integer overflow in SdnToGregorian leads to segfault (in optimized builds) +--SKIPIF-- +<?php +include 'skipif.inc'; +if (PHP_INT_SIZE != 4) { + die("skip this test is for 32bit platform only"); +} +?> +--FILE-- +<?php +$x = 882858030; + +var_dump(cal_from_jd($x, CAL_GREGORIAN)); +--EXPECTF-- +array(9) { + ["date"]=> + string(5) "0/0/0" + ["month"]=> + int(0) + ["day"]=> + int(0) + ["year"]=> + int(0) + ["dow"]=> + int(%d) + ["abbrevdayname"]=> + string(%d) "%s" + ["dayname"]=> + string(%d) "%s" + ["abbrevmonth"]=> + string(0) "" + ["monthname"]=> + string(0) "" +} + diff --git a/ext/calendar/tests/bug55797_2.phpt b/ext/calendar/tests/bug55797_2.phpt new file mode 100644 index 0000000..2a9183d --- /dev/null +++ b/ext/calendar/tests/bug55797_2.phpt @@ -0,0 +1,36 @@ +--TEST-- +Bug #55797: Integer overflow in SdnToGregorian leads to segfault (in optimized builds) +--SKIPIF-- +<?php +include 'skipif.inc'; +if (PHP_INT_SIZE == 4) { + die("skip this test is for 64bit platform only"); +} +?> +--FILE-- +<?php +$x = 9223372036854743639; + +var_dump(cal_from_jd($x, CAL_GREGORIAN)); +--EXPECTF-- +array(9) { + ["date"]=> + string(5) "0/0/0" + ["month"]=> + int(0) + ["day"]=> + int(0) + ["year"]=> + int(0) + ["dow"]=> + int(%d) + ["abbrevdayname"]=> + string(%d) "%s" + ["dayname"]=> + string(%d) "%s" + ["abbrevmonth"]=> + string(0) "" + ["monthname"]=> + string(0) "" +} + diff --git a/ext/calendar/tests/cal_days_in_month.phpt b/ext/calendar/tests/cal_days_in_month.phpt new file mode 100644 index 0000000..9aaf3ef --- /dev/null +++ b/ext/calendar/tests/cal_days_in_month.phpt @@ -0,0 +1,20 @@ +--TEST-- +cal_days_in_month() +--SKIPIF-- +<?php include 'skipif.inc'; ?> +--FILE-- +<?php +$num = cal_days_in_month(CAL_GREGORIAN, 8, 2003); +echo "There are $num days in August 2003\n"; +$num = cal_days_in_month(CAL_GREGORIAN, 2, 2003); +echo "There are $num days in February 2003\n"; +$num = cal_days_in_month(CAL_GREGORIAN, 2, 2004); +echo "There are $num days in February 2004\n"; +$num = cal_days_in_month(CAL_GREGORIAN, 12, 2034); +echo "There are $num days in December 2034\n"; +?> +--EXPECT-- +There are 31 days in August 2003 +There are 28 days in February 2003 +There are 29 days in February 2004 +There are 31 days in December 2034 diff --git a/ext/calendar/tests/cal_from_jd.phpt b/ext/calendar/tests/cal_from_jd.phpt new file mode 100644 index 0000000..9614522 --- /dev/null +++ b/ext/calendar/tests/cal_from_jd.phpt @@ -0,0 +1,60 @@ +--TEST-- +cal_from_jd() +--SKIPIF-- +<?php include 'skipif.inc'; ?> +--FILE-- +<?php +print_r(cal_from_jd(1748326, CAL_GREGORIAN)); +print_r(cal_from_jd(1748324, CAL_JULIAN)); +print_r(cal_from_jd( 374867, CAL_JEWISH)); +print_r(cal_from_jd( 0, CAL_FRENCH)); +?> +--EXPECT-- +Array +( + [date] => 8/26/74 + [month] => 8 + [day] => 26 + [year] => 74 + [dow] => 0 + [abbrevdayname] => Sun + [dayname] => Sunday + [abbrevmonth] => Aug + [monthname] => August +) +Array +( + [date] => 8/26/74 + [month] => 8 + [day] => 26 + [year] => 74 + [dow] => 5 + [abbrevdayname] => Fri + [dayname] => Friday + [abbrevmonth] => Aug + [monthname] => August +) +Array +( + [date] => 8/26/74 + [month] => 8 + [day] => 26 + [year] => 74 + [dow] => 4 + [abbrevdayname] => Thu + [dayname] => Thursday + [abbrevmonth] => Nisan + [monthname] => Nisan +) +Array +( + [date] => 0/0/0 + [month] => 0 + [day] => 0 + [year] => 0 + [dow] => 1 + [abbrevdayname] => Mon + [dayname] => Monday + [abbrevmonth] => + [monthname] => +) diff --git a/ext/calendar/tests/cal_info.phpt b/ext/calendar/tests/cal_info.phpt new file mode 100644 index 0000000..2e3e612 --- /dev/null +++ b/ext/calendar/tests/cal_info.phpt @@ -0,0 +1,216 @@ +--TEST-- +cal_info() +--INI-- +date.timezone=UTC +--SKIPIF-- +<?php include 'skipif.inc'; ?> +--FILE-- +<?php + print_r(cal_info()); + print_r(cal_info(1)); + print_r(cal_info(99999)); +?> +--EXPECTF-- +Array +( + [0] => Array + ( + [months] => Array + ( + [1] => January + [2] => February + [3] => March + [4] => April + [5] => May + [6] => June + [7] => July + [8] => August + [9] => September + [10] => October + [11] => November + [12] => December + ) + + [abbrevmonths] => Array + ( + [1] => Jan + [2] => Feb + [3] => Mar + [4] => Apr + [5] => May + [6] => Jun + [7] => Jul + [8] => Aug + [9] => Sep + [10] => Oct + [11] => Nov + [12] => Dec + ) + + [maxdaysinmonth] => 31 + [calname] => Gregorian + [calsymbol] => CAL_GREGORIAN + ) + + [1] => Array + ( + [months] => Array + ( + [1] => January + [2] => February + [3] => March + [4] => April + [5] => May + [6] => June + [7] => July + [8] => August + [9] => September + [10] => October + [11] => November + [12] => December + ) + + [abbrevmonths] => Array + ( + [1] => Jan + [2] => Feb + [3] => Mar + [4] => Apr + [5] => May + [6] => Jun + [7] => Jul + [8] => Aug + [9] => Sep + [10] => Oct + [11] => Nov + [12] => Dec + ) + + [maxdaysinmonth] => 31 + [calname] => Julian + [calsymbol] => CAL_JULIAN + ) + + [2] => Array + ( + [months] => Array + ( + [1] => Tishri + [2] => Heshvan + [3] => Kislev + [4] => Tevet + [5] => Shevat + [6] => AdarI + [7] => AdarII + [8] => Nisan + [9] => Iyyar + [10] => Sivan + [11] => Tammuz + [12] => Av + [13] => Elul + ) + + [abbrevmonths] => Array + ( + [1] => Tishri + [2] => Heshvan + [3] => Kislev + [4] => Tevet + [5] => Shevat + [6] => AdarI + [7] => AdarII + [8] => Nisan + [9] => Iyyar + [10] => Sivan + [11] => Tammuz + [12] => Av + [13] => Elul + ) + + [maxdaysinmonth] => 30 + [calname] => Jewish + [calsymbol] => CAL_JEWISH + ) + + [3] => Array + ( + [months] => Array + ( + [1] => Vendemiaire + [2] => Brumaire + [3] => Frimaire + [4] => Nivose + [5] => Pluviose + [6] => Ventose + [7] => Germinal + [8] => Floreal + [9] => Prairial + [10] => Messidor + [11] => Thermidor + [12] => Fructidor + [13] => Extra + ) + + [abbrevmonths] => Array + ( + [1] => Vendemiaire + [2] => Brumaire + [3] => Frimaire + [4] => Nivose + [5] => Pluviose + [6] => Ventose + [7] => Germinal + [8] => Floreal + [9] => Prairial + [10] => Messidor + [11] => Thermidor + [12] => Fructidor + [13] => Extra + ) + + [maxdaysinmonth] => 30 + [calname] => French + [calsymbol] => CAL_FRENCH + ) + +) +Array +( + [months] => Array + ( + [1] => January + [2] => February + [3] => March + [4] => April + [5] => May + [6] => June + [7] => July + [8] => August + [9] => September + [10] => October + [11] => November + [12] => December + ) + + [abbrevmonths] => Array + ( + [1] => Jan + [2] => Feb + [3] => Mar + [4] => Apr + [5] => May + [6] => Jun + [7] => Jul + [8] => Aug + [9] => Sep + [10] => Oct + [11] => Nov + [12] => Dec + ) + + [maxdaysinmonth] => 31 + [calname] => Julian + [calsymbol] => CAL_JULIAN +) + +Warning: cal_info(): invalid calendar ID 99999. in %s on line %d diff --git a/ext/calendar/tests/cal_to_jd.phpt b/ext/calendar/tests/cal_to_jd.phpt new file mode 100644 index 0000000..fde1e0b --- /dev/null +++ b/ext/calendar/tests/cal_to_jd.phpt @@ -0,0 +1,16 @@ +--TEST-- +cal_to_jd() +--SKIPIF-- +<?php include 'skipif.inc'; ?> +--FILE-- +<?php +echo cal_to_jd(CAL_GREGORIAN, 8, 26, 74), "\n"; +echo cal_to_jd(CAL_JULIAN, 8, 26, 74), "\n"; +echo cal_to_jd(CAL_JEWISH, 8, 26, 74), "\n"; +echo cal_to_jd(CAL_FRENCH, 8, 26, 74), "\n"; +?> +--EXPECT-- +1748326 +1748324 +374867 +0 diff --git a/ext/calendar/tests/easter_date.phpt b/ext/calendar/tests/easter_date.phpt new file mode 100644 index 0000000..9222d3c --- /dev/null +++ b/ext/calendar/tests/easter_date.phpt @@ -0,0 +1,21 @@ +--TEST-- +easter_date() +--INI-- +date.timezone=UTC +--SKIPIF-- +<?php include 'skipif.inc'; ?> +--FILE-- +<?php +putenv('TZ=UTC'); +echo date("Y-m-d", easter_date(2000))."\n"; +echo date("Y-m-d", easter_date(2001))."\n"; +echo date("Y-m-d", easter_date(2002))."\n"; +echo date("Y-m-d", easter_date(1492))."\n"; +?> +--EXPECTF-- +2000-04-23 +2001-04-15 +2002-03-31 + +Warning: easter_date(): This function is only valid for years between 1970 and 2037 inclusive in %s on line %d +1970-01-01 diff --git a/ext/calendar/tests/easter_days.phpt b/ext/calendar/tests/easter_days.phpt new file mode 100644 index 0000000..04aa7ae --- /dev/null +++ b/ext/calendar/tests/easter_days.phpt @@ -0,0 +1,14 @@ +--TEST-- +easter_days() +--SKIPIF-- +<?php include 'skipif.inc'; ?> +--FILE-- +<?php +echo easter_days(1999), "\n"; +echo easter_days(1492), "\n"; +echo easter_days(1913), "\n"; +?> +--EXPECT-- +14 +32 +2 diff --git a/ext/calendar/tests/frenchtojd.phpt b/ext/calendar/tests/frenchtojd.phpt new file mode 100644 index 0000000..73addb6 --- /dev/null +++ b/ext/calendar/tests/frenchtojd.phpt @@ -0,0 +1,16 @@ +--TEST-- +frenchtojd() +--SKIPIF-- +<?php include 'skipif.inc'; ?> +--FILE-- +<?php +echo frenchtojd(-1,-1,-1), "\n"; +echo frenchtojd(0,0,0), "\n"; +echo frenchtojd(1,1,1), "\n"; +echo frenchtojd(14,31,15), "\n"; +?> +--EXPECT-- +0 +0 +2375840 +0 diff --git a/ext/calendar/tests/gregoriantojd.phpt b/ext/calendar/tests/gregoriantojd.phpt new file mode 100644 index 0000000..ec3628e --- /dev/null +++ b/ext/calendar/tests/gregoriantojd.phpt @@ -0,0 +1,18 @@ +--TEST-- +gregoriantojd() +--SKIPIF-- +<?php include 'skipif.inc'; ?> +--FILE-- +<?php +echo gregoriantojd( 0, 0, 0). "\n"; +echo gregoriantojd( 1, 1, 1582). "\n"; +echo gregoriantojd(10, 5, 1582). "\n"; +echo gregoriantojd( 1, 1, 1970). "\n"; +echo gregoriantojd( 1, 1, 2999). "\n"; +?> +--EXPECT-- +0 +2298874 +2299151 +2440588 +2816423
\ No newline at end of file diff --git a/ext/calendar/tests/jddayofweek.phpt b/ext/calendar/tests/jddayofweek.phpt new file mode 100644 index 0000000..c33d598 --- /dev/null +++ b/ext/calendar/tests/jddayofweek.phpt @@ -0,0 +1,130 @@ +--TEST-- +jddayofweek() +--SKIPIF-- +<?php include 'skipif.inc'; ?> +--FILE-- +<?php +foreach (array(2440588, 2452162, 2453926, -1000) as $jd) { + echo "### JD $jd ###\n"; + for ($mode = 0; $mode <= 2; $mode++) { + echo "--- mode $mode ---\n"; + for ($offset = 0; $offset <= 7; $offset++) { + echo jddayofweek($jd + $offset, $mode). "\n"; + } + } +} +?> +--EXPECT-- +### JD 2440588 ### +--- mode 0 --- +4 +5 +6 +0 +1 +2 +3 +4 +--- mode 1 --- +Thursday +Friday +Saturday +Sunday +Monday +Tuesday +Wednesday +Thursday +--- mode 2 --- +Thu +Fri +Sat +Sun +Mon +Tue +Wed +Thu +### JD 2452162 ### +--- mode 0 --- +0 +1 +2 +3 +4 +5 +6 +0 +--- mode 1 --- +Sunday +Monday +Tuesday +Wednesday +Thursday +Friday +Saturday +Sunday +--- mode 2 --- +Sun +Mon +Tue +Wed +Thu +Fri +Sat +Sun +### JD 2453926 ### +--- mode 0 --- +0 +1 +2 +3 +4 +5 +6 +0 +--- mode 1 --- +Sunday +Monday +Tuesday +Wednesday +Thursday +Friday +Saturday +Sunday +--- mode 2 --- +Sun +Mon +Tue +Wed +Thu +Fri +Sat +Sun +### JD -1000 ### +--- mode 0 --- +2 +3 +4 +5 +6 +0 +1 +2 +--- mode 1 --- +Tuesday +Wednesday +Thursday +Friday +Saturday +Sunday +Monday +Tuesday +--- mode 2 --- +Tue +Wed +Thu +Fri +Sat +Sun +Mon +Tue + diff --git a/ext/calendar/tests/jdmonthname.phpt b/ext/calendar/tests/jdmonthname.phpt new file mode 100644 index 0000000..d05d3c5 --- /dev/null +++ b/ext/calendar/tests/jdmonthname.phpt @@ -0,0 +1,314 @@ +--TEST-- +jdmonthname() +--SKIPIF-- +<?php include 'skipif.inc'; ?> +--FILE-- +<?php +foreach (array(2440588, 2452162, 2453926) as $jd) { + echo "### JD $jd ###\n"; + for ($mode = 0; $mode <= 6; $mode++) { + echo "--- mode $mode ---\n"; + for ($offset = 0; $offset <= 12; $offset++) { + echo jdmonthname($jd + $offset * 30, $mode). "\n"; + } + } +} +?> +--EXPECT-- +### JD 2440588 ### +--- mode 0 --- +Jan +Jan +Mar +Apr +May +May +Jun +Jul +Aug +Sep +Oct +Nov +Dec +--- mode 1 --- +January +January +March +April +May +May +June +July +August +September +October +November +December +--- mode 2 --- +Dec +Jan +Feb +Mar +Apr +May +Jun +Jul +Aug +Sep +Oct +Nov +Dec +--- mode 3 --- +December +January +February +March +April +May +June +July +August +September +October +November +December +--- mode 4 --- +Tevet +Shevat +AdarI +AdarII +Nisan +Iyyar +Sivan +Tammuz +Av +Elul +Tishri +Heshvan +Kislev +--- mode 5 --- + + + + + + + + + + + + + +--- mode 6 --- +Jan +Jan +Mar +Apr +May +May +Jun +Jul +Aug +Sep +Oct +Nov +Dec +### JD 2452162 ### +--- mode 0 --- +Sep +Oct +Nov +Dec +Jan +Feb +Mar +Apr +May +Jun +Jul +Aug +Sep +--- mode 1 --- +September +October +November +December +January +February +March +April +May +June +July +August +September +--- mode 2 --- +Aug +Sep +Oct +Nov +Dec +Jan +Feb +Mar +Apr +May +Jun +Jul +Aug +--- mode 3 --- +August +September +October +November +December +January +February +March +April +May +June +July +August +--- mode 4 --- +Elul +Tishri +Heshvan +Kislev +Tevet +Shevat +AdarI +Nisan +Iyyar +Sivan +Tammuz +Av +Elul +--- mode 5 --- + + + + + + + + + + + + + +--- mode 6 --- +Sep +Oct +Nov +Dec +Jan +Feb +Mar +Apr +May +Jun +Jul +Aug +Sep +### JD 2453926 ### +--- mode 0 --- +Jul +Aug +Sep +Oct +Nov +Dec +Jan +Feb +Mar +Apr +May +Jun +Jul +--- mode 1 --- +July +August +September +October +November +December +January +February +March +April +May +June +July +--- mode 2 --- +Jun +Jul +Aug +Sep +Oct +Nov +Dec +Jan +Feb +Mar +Apr +May +Jun +--- mode 3 --- +June +July +August +September +October +November +December +January +February +March +April +May +June +--- mode 4 --- +Tammuz +Av +Elul +Tishri +Heshvan +Kislev +Tevet +Shevat +AdarI +Nisan +Iyyar +Sivan +Tammuz +--- mode 5 --- + + + + + + + + + + + + + +--- mode 6 --- +Jul +Aug +Sep +Oct +Nov +Dec +Jan +Feb +Mar +Apr +May +Jun +Jul diff --git a/ext/calendar/tests/jdtofrench.phpt b/ext/calendar/tests/jdtofrench.phpt new file mode 100644 index 0000000..2794409 --- /dev/null +++ b/ext/calendar/tests/jdtofrench.phpt @@ -0,0 +1,20 @@ +--TEST-- +jdtofrench() +--SKIPIF-- +<?php include 'skipif.inc'; ?> +--FILE-- +<?php +echo jdtofrench(0). "\n"; +echo jdtofrench(2375840). "\n"; +echo jdtofrench(2375850). "\n"; +echo jdtofrench(2375940). "\n"; +echo jdtofrench(2376345). "\n"; +echo jdtofrench(2385940). "\n"; +?> +--EXPECT-- +0/0/0 +1/1/1 +1/11/1 +4/11/1 +5/21/2 +0/0/0
\ No newline at end of file diff --git a/ext/calendar/tests/jdtogregorian.phpt b/ext/calendar/tests/jdtogregorian.phpt new file mode 100644 index 0000000..6b1956f --- /dev/null +++ b/ext/calendar/tests/jdtogregorian.phpt @@ -0,0 +1,18 @@ +--TEST-- +jdtogregorian() +--SKIPIF-- +<?php include 'skipif.inc'; ?> +--FILE-- +<?php +echo jdtogregorian(0). "\n"; +echo jdtogregorian(2298874). "\n"; +echo jdtogregorian(2299151). "\n"; +echo jdtogregorian(2440588). "\n"; +echo jdtogregorian(2816423). "\n"; +?> +--EXPECT-- +0/0/0 +1/1/1582 +10/5/1582 +1/1/1970 +1/1/2999
\ No newline at end of file diff --git a/ext/calendar/tests/jdtojewish.phpt b/ext/calendar/tests/jdtojewish.phpt new file mode 100644 index 0000000..484b957 --- /dev/null +++ b/ext/calendar/tests/jdtojewish.phpt @@ -0,0 +1,30 @@ +--TEST-- +jdtojewish() function +--SKIPIF-- +<?php include 'skipif.inc'; ?> +--FILE-- +<?php + +var_dump(jdtojewish(gregoriantojd(10,28,2002))."\r\n". + jdtojewish(gregoriantojd(10,28,2002),true)."\r\n". + jdtojewish(gregoriantojd(10,28,2002),true, CAL_JEWISH_ADD_ALAFIM_GERESH)."\r\n". + jdtojewish(gregoriantojd(10,28,2002),true, CAL_JEWISH_ADD_ALAFIM)."\r\n". + jdtojewish(gregoriantojd(10,28,2002),true, CAL_JEWISH_ADD_ALAFIM_GERESH+CAL_JEWISH_ADD_ALAFIM)."\r\n". + jdtojewish(gregoriantojd(10,28,2002),true, CAL_JEWISH_ADD_GERESHAYIM)."\r\n". + jdtojewish(gregoriantojd(10,8,2002),true, CAL_JEWISH_ADD_GERESHAYIM)."\r\n". + jdtojewish(gregoriantojd(10,8,2002),true, CAL_JEWISH_ADD_GERESHAYIM+CAL_JEWISH_ADD_ALAFIM_GERESH)."\r\n". + jdtojewish(gregoriantojd(10,8,2002),true, CAL_JEWISH_ADD_GERESHAYIM+CAL_JEWISH_ADD_ALAFIM)."\r\n". + jdtojewish(gregoriantojd(10,8,2002),true, CAL_JEWISH_ADD_GERESHAYIM+CAL_JEWISH_ADD_ALAFIM+CAL_JEWISH_ADD_ALAFIM_GERESH)."\r\n"); +?> +--EXPECT-- +string(184) "2/22/5763 +כב חשון התשסג +כב חשון ה'תשסג +כב חשון ה אלפים תשסג +כב חשון ה' אלפים תשסג +כ"ב חשון התשס"ג +ב' חשון התשס"ג +ב' חשון ה'תשס"ג +ב' חשון ה אלפים תשס"ג +ב' חשון ה' אלפים תשס"ג +" diff --git a/ext/calendar/tests/jdtojulian.phpt b/ext/calendar/tests/jdtojulian.phpt new file mode 100644 index 0000000..6c87aa7 --- /dev/null +++ b/ext/calendar/tests/jdtojulian.phpt @@ -0,0 +1,18 @@ +--TEST-- +jdtojulian() +--SKIPIF-- +<?php include 'skipif.inc'; ?> +--FILE-- +<?php +echo jdtojulian(0). "\n"; +echo jdtojulian(2298874). "\n"; +echo jdtojulian(2299151). "\n"; +echo jdtojulian(2440588). "\n"; +echo jdtojulian(2816423). "\n"; +?> +--EXPECT-- +0/0/0 +12/22/1581 +9/25/1582 +12/19/1969 +12/12/2998
\ No newline at end of file diff --git a/ext/calendar/tests/jdtomonthname.phpt b/ext/calendar/tests/jdtomonthname.phpt new file mode 100644 index 0000000..5c55247 --- /dev/null +++ b/ext/calendar/tests/jdtomonthname.phpt @@ -0,0 +1,85 @@ +--TEST-- +jdtomonthname() test +--SKIPIF-- +<?php if (!extension_loaded("calendar")) print "skip"; ?> +--FILE-- +<?php + +$jd_days = Array( + 2453396, + 2440588, + -1, + array(), + 10000000 + ); + +foreach ($jd_days as $jd_day) { + echo "=== ", $jd_day, "\n"; + var_dump(jdmonthname($jd_day,0)); + var_dump(jdmonthname($jd_day,1)); + var_dump(jdmonthname($jd_day,2)); + var_dump(jdmonthname($jd_day,3)); + var_dump(jdmonthname($jd_day,4)); + var_dump(jdmonthname($jd_day,5)); + echo "\n"; +} + +echo "Done\n"; + +?> +--EXPECTF-- +=== 2453396 +string(3) "Jan" +string(7) "January" +string(3) "Jan" +string(7) "January" +string(6) "Shevat" +string(0) "" + +=== 2440588 +string(3) "Jan" +string(7) "January" +string(3) "Dec" +string(8) "December" +string(5) "Tevet" +string(0) "" + +=== -1 +string(0) "" +string(0) "" +string(0) "" +string(0) "" +string(0) "" +string(0) "" + +=== +Notice: Array to string conversion in %sjdtomonthname.php on line %d +Array + +Warning: jdmonthname() expects parameter 1 to be long, array given in %s on line %d +bool(false) + +Warning: jdmonthname() expects parameter 1 to be long, array given in %s on line %d +bool(false) + +Warning: jdmonthname() expects parameter 1 to be long, array given in %s on line %d +bool(false) + +Warning: jdmonthname() expects parameter 1 to be long, array given in %s on line %d +bool(false) + +Warning: jdmonthname() expects parameter 1 to be long, array given in %s on line %d +bool(false) + +Warning: jdmonthname() expects parameter 1 to be long, array given in %s on line %d +bool(false) + +=== 10000000 +string(3) "Dec" +string(8) "December" +string(3) "Jul" +string(4) "July" +string(6) "Tishri" +string(0) "" + +Done diff --git a/ext/calendar/tests/jdtounix.phpt b/ext/calendar/tests/jdtounix.phpt new file mode 100644 index 0000000..8d85543 --- /dev/null +++ b/ext/calendar/tests/jdtounix.phpt @@ -0,0 +1,16 @@ +--TEST-- +jdtounix() +--INI-- +date.timezone=UTC +--SKIPIF-- +<?php include 'skipif.inc'; ?> +--FILE-- +<?php +echo date("Y-m-d",jdtounix(2440588)). "\n"; +echo date("Y-m-d",jdtounix(2452162)). "\n"; +echo date("Y-m-d",jdtounix(2453926)). "\n"; +?> +--EXPECT-- +1970-01-01 +2001-09-09 +2006-07-09 diff --git a/ext/calendar/tests/jewishtojd.phpt b/ext/calendar/tests/jewishtojd.phpt new file mode 100644 index 0000000..a9a2ff0 --- /dev/null +++ b/ext/calendar/tests/jewishtojd.phpt @@ -0,0 +1,16 @@ +--TEST-- +jewishtojd() +--SKIPIF-- +<?php include 'skipif.inc'; ?> +--FILE-- +<?php +echo jewishtojd(-1,-1,-1). "\n"; +echo jewishtojd(0,0,0). "\n"; +echo jewishtojd(1,1,1). "\n"; +echo jewishtojd(2,22,5763). "\n"; +?> +--EXPECT-- +0 +0 +347998 +2452576
\ No newline at end of file diff --git a/ext/calendar/tests/juliantojd.phpt b/ext/calendar/tests/juliantojd.phpt new file mode 100644 index 0000000..9563e04 --- /dev/null +++ b/ext/calendar/tests/juliantojd.phpt @@ -0,0 +1,18 @@ +--TEST-- +juliantojd() +--SKIPIF-- +<?php include 'skipif.inc'; ?> +--FILE-- +<?php +echo juliantojd( 0, 0, 0). "\n"; +echo juliantojd( 1, 1, 1582). "\n"; +echo juliantojd(10, 5, 1582). "\n"; +echo juliantojd( 1, 1, 1970). "\n"; +echo juliantojd( 1, 1, 2999). "\n"; +?> +--EXPECT-- +0 +2298884 +2299161 +2440601 +2816443
\ No newline at end of file diff --git a/ext/calendar/tests/skipif.inc b/ext/calendar/tests/skipif.inc new file mode 100644 index 0000000..de8e4ae --- /dev/null +++ b/ext/calendar/tests/skipif.inc @@ -0,0 +1,4 @@ +<?php +if(!extension_loaded("calendar")) + print "skip - CALENDAR extension not available"; +?> diff --git a/ext/calendar/tests/unixtojd.phpt b/ext/calendar/tests/unixtojd.phpt new file mode 100644 index 0000000..4eeb1ca --- /dev/null +++ b/ext/calendar/tests/unixtojd.phpt @@ -0,0 +1,40 @@ +--TEST-- +unixtojd() +--SKIPIF-- +<?php include 'skipif.inc'; ?> +--ENV-- +TZ=UTC +--FILE-- +<?php +// this line has no impact on test output on Windows +putenv('TZ=UTC'); +// getenv('TZ') returns 'UTC' here +// putenv (basic_functions.c) does call tzset() when the env var being put is 'TZ' +// -adding a call direct to GetEnvironmentVariableA just before tzset() is called to check the value of 'TZ' returns 'UTC' +// putting a call to date_default_timezone_set() here doesn't help +// +// on Windows, the only thing that gets this test to pass is to put TZ=UTC in --ENV-- section +// -since putenv() is written to call tzset() when env var is TZ, I assume that putenv("TZ=UTC") is intended to work +// and should work on all platforms(including Windows). +// easter_date.phpt passes +// -doesn't use --ENV-- section +// -uses --INI-- section with date.timezone=UTC +// -uses putenv('TZ=UTC') +// date.timezone=UTC +// -if ommitted from easter_date.phpt, outputs DATE_TZ_ERRMSG warning +// -easter_date() calls mktime() and localtime() +// -whereas unixtojd(1000000000) calls localtime(1000000000) +// -if ommitted from unixtojd.phpt, does NOT output DATE_TZ_ERRMSG +// +// unixtojd() calls php_localtime_r() which for Pacific timezone systems, returns a time -8 hours +// -this incorrect localtime is passed to the julian date conversion (GregorianToSDN) function which works (probably correctly) +// but returns -1 day from expected because its input is -1 from expected + +echo unixtojd(40000). "\n"; +echo unixtojd(1000000000). "\n"; +echo unixtojd(1152459009). "\n"; +?> +--EXPECT-- +2440588 +2452162 +2453926 |