aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorOmair Majid <[email protected]>2012-04-03 12:13:24 -0400
committerOmair Majid <[email protected]>2012-04-03 12:13:24 -0400
commit92413ff87b5c65f627624d6600a6a3733433bd23 (patch)
treebd1282f5a0690fdb10f7a2bd049a0dd3b46e6713 /tests
parente73ab7ec0e381bfab6fce1e1b614d88791f2f326 (diff)
Fix pac tests
The testDateRange* tests were rewritten so date wrapping is handled correctly. Also fixes two bugs in pac-funcs.js (a missed return value and using getYear instead of getFullYear). 2012-04-03 Omair Majid <[email protected]> * netx/net/sourceforge/jnlp/runtime/pac-funcs.js: Replace incorrect use of getYear() with getFullYear(). (inYearMonthDateRange): Add missing conditional case. * tests/netx/pac/pac-funcs-test.js (runTest): New function. (runTests): Call runTest. (incDate): Deal with month/year wrapping around. (decDate): Removed. (testDateRange, testDateRange2, testDateRange3): Handle wrapping of month and days.
Diffstat (limited to 'tests')
-rw-r--r--tests/netx/pac/pac-funcs-test.js425
1 files changed, 257 insertions, 168 deletions
diff --git a/tests/netx/pac/pac-funcs-test.js b/tests/netx/pac/pac-funcs-test.js
index 451126d..bd50035 100644
--- a/tests/netx/pac/pac-funcs-test.js
+++ b/tests/netx/pac/pac-funcs-test.js
@@ -31,30 +31,32 @@ function main() {
}
function runTests(name, tests) {
-
var undefined_var;
-
for ( var i = 0; i < tests.length; i++) {
-
- var expectedVal = tests[i][0];
- var args = tests[i].slice(1);
- var returnVal;
- try {
- returnVal = name.apply(null, args);
- } catch (e) {
- returnVal = e;
- }
- if (returnVal === expectedVal) {
- java.lang.System.out.println("Passed: " + name.name + "(" + args.join(", ") + ")");
- testsPassed++;
- } else {
- java.lang.System.out.println("FAILED: " + name.name + "(" + args.join(", ") + ")");
- java.lang.System.out.println(" Expected '" + expectedVal + "' but got '" + returnVal + "'");
- testsFailed++;
- }
+ runTest(name, tests[i]);
}
}
+function runTest(name, test) {
+ var expectedVal = test[0];
+ var args = test.slice(1);
+ var returnVal;
+ try {
+ returnVal = name.apply(null, args);
+ } catch (e) {
+ returnVal = e;
+ }
+ if (returnVal === expectedVal) {
+ java.lang.System.out.println("Passed: " + name.name + "(" + args.join(", ") + ")");
+ testsPassed++;
+ } else {
+ java.lang.System.out.println("FAILED: " + name.name + "(" + args.join(", ") + ")");
+ java.lang.System.out.println(" Expected '" + expectedVal + "' but got '" + returnVal + "'");
+ testsFailed++;
+ }
+}
+
+
function testIsPlainHostName() {
var tests = [
[ false, "icedtea.classpath.org" ],
@@ -241,136 +243,227 @@ function testWeekdayRange() {
runTests(weekdayRange, tests);
}
- function incDate(date) {
- return (date + 1 - 1) % 31 +1 ;
+/** Returns an array: [day, month, year] */
+function incDate() {
+ if ((arguments.length >= 3) && (arguments.length % 2 === 1)) {
+ var date = arguments[0];
+ var result = date;
+ var index = 1;
+ while (index < arguments.length) {
+ var whichThing = arguments[index];
+ var by = arguments[index+1];
+ switch (whichThing) {
+ case 'year':
+ result = new Date(result.getFullYear()+by, result.getMonth(), result.getDate());
+ break;
+ case 'month':
+ result = new Date(result.getFullYear(), result.getMonth()+by, result.getDate());
+ break;
+ case 'day':
+ result = new Date(result.getFullYear(), result.getMonth(), result.getDate()+by);
+ break;
+ }
+ index += 2;
+ }
+ return [result.getDate(), result.getMonth(), result.getFullYear()];
+ }
+ throw "Please call incDate properly";
+}
+
+function monthToStr(month) {
+ switch (month) {
+ case -1: return "DEC";
+ case 0: return "JAN";
+ case 1: return "FEB";
+ case 2: return "MAR";
+ case 3: return "APR";
+ case 4: return "MAY";
+ case 5: return "JUN";
+ case 6: return "JUL";
+ case 7: return "AUG";
+ case 8: return "SEP";
+ case 9: return "OCT";
+ case 10: return "NOV";
+ case 11: return "DEC";
+ case 12: return "JAN";
+ default: throw "Invalid Month" + month;
}
+}
+
+function testDateRange() {
- function decDate(date) {
- return (date - 1 - 1 + 31) % 31 + 1;
+ {
+ var current = new Date();
+ var date = current.getDate();
+ var month = current.getMonth();
+ var year = current.getFullYear();
+
+ var today = incDate(current, 'day', 0);
+ var tomorrow = incDate(current, 'day', 1);
+ var yesterday = incDate(current, 'day', -1);
+
+ runTest(dateRange, [ true, date ]);
+ runTest(dateRange, [ false, tomorrow[0] ]);
+ runTest(dateRange, [ false, yesterday[0] ]);
+
+ runTest(dateRange, [ true, monthToStr(month) ]);
+ runTest(dateRange, [ false, monthToStr(month+1) ]);
+ runTest(dateRange, [ false, monthToStr(month-1) ]);
+
+ runTest(dateRange, [ true, year ]);
+ runTest(dateRange, [ false, year - 1]);
+ runTest(dateRange, [ false, year + 1]);
+
+ runTest(dateRange, [ true, date, date ]);
+ runTest(dateRange, [ true, today[0], tomorrow[0] ]);
+ runTest(dateRange, [ true, yesterday[0], today[0] ]);
+ runTest(dateRange, [ true, yesterday[0], tomorrow[0] ]);
+ runTest(dateRange, [ false, tomorrow[0], yesterday[0] ]);
+ runTest(dateRange, [ false, incDate(current,'day',-2)[0], yesterday[0] ]);
+ runTest(dateRange, [ false, tomorrow[0], incDate(current,'day',2)[0] ]);
+
+ runTest(dateRange, [ true, monthToStr(month), monthToStr(month) ]);
+ runTest(dateRange, [ true, monthToStr(month), monthToStr(month+1) ]);
+ runTest(dateRange, [ true, monthToStr(month-1), monthToStr(month) ]);
+ runTest(dateRange, [ true, monthToStr(month-1), monthToStr(month+1) ]);
+ runTest(dateRange, [ true, "JAN", "DEC" ]);
+ runTest(dateRange, [ true, "FEB", "JAN" ]);
+ runTest(dateRange, [ true, "DEC", "NOV" ]);
+ runTest(dateRange, [ true, "JUL", "JUN"]);
+ runTest(dateRange, [ false, monthToStr(month+1), monthToStr(month+1) ]);
+ runTest(dateRange, [ false, monthToStr(month-1), monthToStr(month-1) ]);
+ runTest(dateRange, [ false, monthToStr(month+1), monthToStr(month-1) ]);
+
+ runTest(dateRange, [ true, year, year ]);
+ runTest(dateRange, [ true, year, year+1 ]);
+ runTest(dateRange, [ true, year-1, year ]);
+ runTest(dateRange, [ true, year-1, year+1 ]);
+ runTest(dateRange, [ false, year-2, year-1 ]);
+ runTest(dateRange, [ false, year+1, year+1 ]);
+ runTest(dateRange, [ false, year+1, year+2 ]);
+ runTest(dateRange, [ false, year+1, year-1 ]);
+
+ runTest(dateRange, [ true, date, monthToStr(month) , date, monthToStr(month) ]);
+ runTest(dateRange, [ true, yesterday[0], monthToStr(yesterday[1]) , date, monthToStr(month) ]);
+ runTest(dateRange, [ false, yesterday[0], monthToStr(yesterday[1]) , yesterday[0], monthToStr(yesterday[1]) ]);
+ runTest(dateRange, [ true, date, monthToStr(month) , tomorrow[0], monthToStr(tomorrow[1]) ]);
+ runTest(dateRange, [ false, tomorrow[0], monthToStr(tomorrow[1]) , tomorrow[0], monthToStr(tomorrow[1]) ]);
+ runTest(dateRange, [ true, yesterday[0], monthToStr(yesterday[1]) , tomorrow[0], monthToStr(tomorrow[1]) ]);
+ runTest(dateRange, [ false, tomorrow[0], monthToStr(tomorrow[1]) , yesterday[0], monthToStr(yesterday[1]) ]);
}
- function monthToStr(month) {
- switch (month) {
- case -1: return "DEC";
- case 0: return "JAN";
- case 1: return "FEB";
- case 2: return "MAR";
- case 3: return "APR";
- case 4: return "MAY";
- case 5: return "JUN";
- case 6: return "JUL";
- case 7: return "AUG";
- case 8: return "SEP";
- case 9: return "OCT";
- case 10: return "NOV";
- case 11: return "DEC";
- case 12: return "JAN";
- default: throw "Invalid Month";
- }
+ {
+ var lastMonth = incDate(new Date(), 'month', -1);
+ var thisMonth = incDate(new Date(), 'month', 0);
+ var nextMonth = incDate(new Date(), 'month', +1);
+ runTest(dateRange, [ true, lastMonth[0], monthToStr(lastMonth[1]) , thisMonth[0], monthToStr(thisMonth[1]) ]);
+ runTest(dateRange, [ true, thisMonth[0], monthToStr(thisMonth[1]) , nextMonth[0], monthToStr(nextMonth[1]) ]);
+ runTest(dateRange, [ true, lastMonth[0], monthToStr(lastMonth[1]) , nextMonth[0], monthToStr(nextMonth[1]) ]);
+ var date1 = incDate(new Date(), 'day', +1, 'month', -1);
+ var date2 = incDate(new Date(), 'day', -1, 'month', +1);
+ runTest(dateRange, [ true, date1[0], monthToStr(date1[1]) , nextMonth[0], monthToStr(nextMonth[1]) ]);
+ runTest(dateRange, [ true, lastMonth[0], monthToStr(lastMonth[1]) , date2[0], monthToStr(date2[1]) ]);
+ runTest(dateRange, [ false, nextMonth[0], monthToStr(nextMonth[1]) , lastMonth[0], monthToStr(lastMonth[1]) ]);
+ var date3 = incDate(new Date(), 'day', +1, 'month', +1);
+ var date4 = incDate(new Date(), 'day', +1, 'month', -1);
+ runTest(dateRange, [ false, date3[0], monthToStr(date3[1]) , date4[0], monthToStr(date4[1]) ]);
+
+ var date5 = incDate(new Date(), 'day', -1, 'month', -1);
+ runTest(dateRange, [ false, date2[0], monthToStr(date2[1]) , date5[0], monthToStr(date5[1]) ]);
+
+ runTest(dateRange, [ true, 1, "JAN", 31, "DEC" ]);
+ runTest(dateRange, [ true, 2, "JAN", 1, "JAN" ]);
+
+ var month = new Date().getMonth();
+ runTest(dateRange, [ false, 1, monthToStr(month+1), 31, monthToStr(month+1) ]);
+ runTest(dateRange, [ false, 1, monthToStr(month-1), 31, monthToStr(month-1) ]);
}
-function testDateRange() {
-
- var today = new Date();
- var date = today.getDate();
- var month = today.getMonth();
- var year = today.getYear();
+ {
+ var lastMonth = incDate(new Date(), 'month', -1);
+ var thisMonth = incDate(new Date(), 'month', 0);
+ var nextMonth = incDate(new Date(), 'month', +1);
+ runTest(dateRange, [ true, monthToStr(thisMonth[1]), thisMonth[2], monthToStr(thisMonth[1]), thisMonth[2] ]);
+ runTest(dateRange, [ true, monthToStr(lastMonth[1]), lastMonth[2], monthToStr(thisMonth[1]), thisMonth[2] ]);
+ runTest(dateRange, [ true, monthToStr(thisMonth[1]), thisMonth[2], monthToStr(nextMonth[1]), nextMonth[2] ]);
+ runTest(dateRange, [ true, monthToStr(lastMonth[1]), lastMonth[2], monthToStr(nextMonth[1]), nextMonth[2] ]);
+ runTest(dateRange, [ true, monthToStr(0), year, monthToStr(11), year ]);
- var tests = [
- [ true, date ],
- [ false, incDate(date) ],
- [ false, decDate(date) ],
-
- [ true, monthToStr(month) ],
- [ false, monthToStr(month+1) ],
- [ false, monthToStr(month-1) ],
-
- [ true, year ],
- [ false, year - 1],
- [ false, year + 1],
-
- [ true, date, date ],
- [ true, date, incDate(date) ],
- [ true, decDate(date), date ],
- [ true, decDate(date), incDate(date) ],
- [ false, incDate(date), decDate(date) ],
- [ false, decDate(decDate(date)), decDate(date) ],
- [ false, incDate(date), incDate(incDate(date)) ],
-
- [ true, monthToStr(month), monthToStr(month) ],
- [ true, monthToStr(month), monthToStr(month+1) ],
- [ true, monthToStr(month-1), monthToStr(month) ],
- [ true, monthToStr(month-1), monthToStr(month+1) ],
- [ true, "JAN", "DEC" ],
- [ true, "DEC", "NOV" ],
- [ true, "JUL", "JUN"],
- [ false, monthToStr(month+1), monthToStr(month+1) ],
- [ false, monthToStr(month-1), monthToStr(month-1) ],
- [ false, monthToStr(month+1), monthToStr(month-1) ],
-
- [ true, year, year ],
- [ true, year, year+1 ],
- [ true, year-1, year ],
- [ true, year-1, year+1 ],
- [ false, year-2, year-1 ],
- [ false, year+1, year+1 ],
- [ false, year+1, year+2 ],
- [ false, year+1, year-1 ],
-
- [ true, date, monthToStr(month) , date, monthToStr(month) ],
- [ true, decDate(date), monthToStr(month) , date, monthToStr(month) ],
- [ false, decDate(date), monthToStr(month) , decDate(date), monthToStr(month) ],
- [ true, date, monthToStr(month) , incDate(date), monthToStr(month) ],
- [ false, incDate(date), monthToStr(month) , incDate(date), monthToStr(month) ],
- [ true, decDate(date), monthToStr(month) , incDate(date), monthToStr(month) ],
- [ false, incDate(date), monthToStr(month) , decDate(date), monthToStr(month) ],
- [ true, date, monthToStr(month-1) , date, monthToStr(month) ],
- [ true, date, monthToStr(month) , date, monthToStr(month+1) ],
- [ true, date, monthToStr(month-1) , date, monthToStr(month+1) ],
- [ true, incDate(date), monthToStr(month-1) , date, monthToStr(month+1) ],
- [ true, date, monthToStr(month-1) , decDate(date), monthToStr(month+1) ],
- [ false, date, monthToStr(month+1) , date, monthToStr(month-1) ],
- [ false, incDate(date), monthToStr(month+1) , incDate(date), monthToStr(month-1) ],
- [ false, decDate(date), monthToStr(month+1) , decDate(date), monthToStr(month-1) ],
- [ true, 1, "JAN", 31, "DEC" ],
- [ true, 2, "JAN", 1, "JAN" ],
- [ false, 1, monthToStr(month+1), 31, monthToStr(month+1) ],
- [ false, 1, monthToStr(month-1), 31, monthToStr(month-1) ],
-
- [ true, monthToStr(month), year, monthToStr(month), year ],
- [ true, monthToStr(month-1), year, monthToStr(month), year ],
- [ true, monthToStr(month), year, monthToStr(month+1), year ],
- [ true, monthToStr(month-1), year, monthToStr(month+1), year ],
- [ true, monthToStr(0), year, monthToStr(11), year ],
- [ false, monthToStr(month+1), year, monthToStr(month-1), year ],
- [ false, monthToStr(month+1), year, monthToStr(month+1), year ],
- [ false, monthToStr(month-1), year, monthToStr(month-1), year ],
- [ false, monthToStr(month), year-1, monthToStr(month-1), year ],
- [ true, monthToStr(month), year, monthToStr(month), year + 1 ],
- [ true, monthToStr(month), year-1, monthToStr(month), year ],
- [ true, monthToStr(month), year-1, monthToStr(month), year+1 ],
- [ true, monthToStr(0), year, monthToStr(0), year+1 ],
- [ true, monthToStr(0), year-1, monthToStr(0), year+1 ],
- [ false, monthToStr(0), year-1, monthToStr(11), year-1 ],
- [ false, monthToStr(0), year+1, monthToStr(11), year+1 ],
-
- [ true, date, monthToStr(month), year, date, monthToStr(month), year ],
- [ true, decDate(date), monthToStr(month), year, incDate(date), monthToStr(month), year ],
- [ true, decDate(date), monthToStr(month-1), year, incDate(date), monthToStr(month+1), year ],
- [ true, decDate(date), monthToStr(month-1), year-1, incDate(date), monthToStr(month+1), year+1 ],
- [ true, incDate(date), monthToStr(month-1), year-1, incDate(date), monthToStr(month+1), year+1 ],
- [ false, incDate(date), monthToStr(month), year, incDate(date), monthToStr(month+1), year+1 ],
- [ false, date, monthToStr(month+1), year, incDate(date), monthToStr(month+1), year+1 ],
- [ true, 1, monthToStr(0), 0, 31, monthToStr(11), 100000 ],
- [ true, 1, monthToStr(0), year, 31, monthToStr(11), year ],
- [ true, 1, monthToStr(0), year-1, 31, monthToStr(11), year+1 ],
- [ false, 1, monthToStr(0), year-1, 31, monthToStr(11), year-1 ],
- [ false, 1, monthToStr(0), year+1, 31, monthToStr(11), year+1 ],
+ runTest(dateRange, [ false, monthToStr(nextMonth[1]), nextMonth[2], monthToStr(lastMonth[1]), lastMonth[2] ]);
+ runTest(dateRange, [ false, monthToStr(nextMonth[1]), nextMonth[2], monthToStr(nextMonth[1]), nextMonth[2] ]);
+ runTest(dateRange, [ false, monthToStr(lastMonth[1]), lastMonth[2], monthToStr(lastMonth[1]), lastMonth[2] ]);
- ];
+ var lastYear = incDate(new Date(), 'year', -1);
+ var nextYear = incDate(new Date(), 'year', +1);
+
+ runTest(dateRange, [ false, monthToStr(lastYear[1]), lastYear[2], monthToStr(lastMonth[1]), lastMonth[2] ]);
+ runTest(dateRange, [ true, monthToStr(thisMonth[1]), thisMonth[2], monthToStr(nextYear[1]), nextYear[2] ]);
+
+ var year = new Date().getFullYear();
+ var month = new Date().getMonth();
+
+ runTest(dateRange, [ true, monthToStr(month), year-1, monthToStr(month), year ]);
+ runTest(dateRange, [ true, monthToStr(month), year-1, monthToStr(month), year+1 ]);
+ runTest(dateRange, [ true, monthToStr(0), year, monthToStr(0), year+1 ]);
+ runTest(dateRange, [ true, monthToStr(0), year-1, monthToStr(0), year+1 ]);
+ runTest(dateRange, [ false, monthToStr(0), year-1, monthToStr(11), year-1 ]);
+ runTest(dateRange, [ false, monthToStr(0), year+1, monthToStr(11), year+1 ]);
+ }
+
+ {
+ var today = incDate(new Date(), 'day', 0);
+ var yesterday = incDate(new Date(), 'day', -1);
+ var tomorrow = incDate(new Date(), 'day', +1);
+ runTest(dateRange, [ true,
+ today[0], monthToStr(today[1]), today[2], today[0], monthToStr(today[1]), today[2] ]);
+ runTest(dateRange, [ true,
+ yesterday[0], monthToStr(yesterday[1]), yesterday[2], tomorrow[0], monthToStr(tomorrow[1]), tomorrow[2] ]);
+ }
+
+ {
+ var dayLastMonth = incDate(new Date(), 'day', -1, 'month', -1);
+ var dayNextMonth = incDate(new Date(), 'day', +1, 'month', +1);
+ runTest(dateRange, [ true,
+ dayLastMonth[0], monthToStr(dayLastMonth[1]), dayLastMonth[2], dayNextMonth[0], monthToStr(dayNextMonth[1]), dayNextMonth[2] ]);
+ }
+
+ {
+ var dayLastYear = incDate(new Date(), 'day', -1, 'month', -1, 'year', -1);
+ var dayNextYear = incDate(new Date(), 'day', +1, 'month', +1, 'year', +1);
+ runTest(dateRange, [ true,
+ dayLastYear[0], monthToStr(dayLastYear[1]), dayLastYear[2], dayNextYear[0], monthToStr(dayNextYear[1]), dayNextYear[2] ]);
+ }
+
+ {
+ var dayLastYear = incDate(new Date(), 'day', +1, 'month', -1, 'year', -1);
+ var dayNextYear = incDate(new Date(), 'day', +1, 'month', +1, 'year', +1);
+ runTest(dateRange, [ true,
+ dayLastYear[0], monthToStr(dayLastYear[1]), dayLastYear[2], dayNextYear[0], monthToStr(dayNextYear[1]), dayNextYear[2] ]);
+ }
+
+ {
+ var tomorrow = incDate(new Date(), 'day', +1);
+ var dayNextYear = incDate(new Date(), 'day', +1, 'month', +1, 'year', +1);
+ runTest(dateRange, [ false,
+ tomorrow[0], monthToStr(tomorrow[1]), tomorrow[2], dayNextYear[0], monthToStr(dayNextYear[1]), dayNextYear[2] ]);
+
+ }
- runTests(dateRange, tests);
+ {
+ var nextMonth = incDate(new Date(), 'month', +1);
+ var nextYear = incDate(new Date(), 'day', +1, 'month', +1, 'year', +1);
+ runTest(dateRange, [ false,
+ nextMonth[0], monthToStr(nextMonth[1]), nextMonth[2], nextYear[0], monthToStr(nextYear[1]), nextYear[2] ]);
+ }
+
+ {
+ runTest(dateRange, [ true, 1, monthToStr(0), 0, 31, monthToStr(11), 100000 ]);
+ runTest(dateRange, [ true, 1, monthToStr(0), year, 31, monthToStr(11), year ]);
+ runTest(dateRange, [ true, 1, monthToStr(0), year-1, 31, monthToStr(11), year+1 ]);
+ runTest(dateRange, [ false, 1, monthToStr(0), year-1, 31, monthToStr(11), year-1 ]);
+ runTest(dateRange, [ false, 1, monthToStr(0), year+1, 31, monthToStr(11), year+1 ]);
+ }
}
@@ -390,24 +483,23 @@ function testDateRange2() {
new Date("October 31, 2011 3:33:33"),
new Date("November 30, 2011 3:33:33"),
new Date("December 31, 2011 3:33:33"),
-
]
for (var i = 0; i < dates.length; i++) {
- var today = dates[i];
- var date = today.getDate();
- var month = today.getMonth();
- var year = today.getYear();
-
- var tests = [
-
- [ true, today, date, monthToStr(month) , incDate(date), monthToStr(month) ],
- [ true, today, decDate(date), monthToStr(month) , incDate(date), monthToStr(month) ],
- [ true, today, decDate(date), monthToStr(month), year, incDate(date), monthToStr(month), year ],
- [ false, today, incDate(date), monthToStr(month), year, incDate(date), monthToStr(month+1), year+1 ],
-
- ];
-
- runTests(isDateInRange, tests);
+ var current = dates[i];
+ var today = incDate(current, 'day', 0);
+ var yesterday = incDate(current, 'day', -1);
+ var tomorrow = incDate(current, 'day', 1);
+ var aYearFromNow = new Date(current.getFullYear()+1, current.getMonth()+1, current.getDate()+1);
+ var later = [aYearFromNow.getDate(), aYearFromNow.getMonth(), aYearFromNow.getFullYear()];
+
+ runTest(isDateInRange, [ true, current,
+ today[0], monthToStr(today[1]) , tomorrow[0], monthToStr(tomorrow[1]) ]);
+ runTest(isDateInRange, [ true, current,
+ yesterday[0], monthToStr(yesterday[1]) , tomorrow[0], monthToStr(tomorrow[1]) ]);
+ runTest(isDateInRange, [ true, current,
+ yesterday[0], monthToStr(yesterday[1]), yesterday[2], tomorrow[0], monthToStr(tomorrow[1]), tomorrow[2] ]);
+ runTest(isDateInRange, [ false, current,
+ tomorrow[0], monthToStr(tomorrow[1]), tomorrow[2], later[0], monthToStr(later[1]), later[2] ]);
}
}
@@ -432,19 +524,16 @@ function testDateRange3() {
for (var i = 0; i < dates.length; i++) {
- var today = dates[i]
- var date = today.getDate();
- var month = today.getMonth();
- var year = today.getYear();
-
- var tests = [
- [ true, today, decDate(date), monthToStr(month) , date, monthToStr(month) ],
- [ true, today, decDate(date), monthToStr(month) , incDate(date), monthToStr(month) ],
- [ true, today, decDate(date), monthToStr(month), year, incDate(date), monthToStr(month), year ],
-
- ];
-
- runTests(isDateInRange, tests);
+ var current = dates[i];
+ var yesterday = incDate(current,'day',-1);
+ var today = incDate(current,'day',0);
+ var tomorrow = incDate(current,'day',1);
+ runTest(isDateInRange, [ true, current,
+ yesterday[0], monthToStr(yesterday[1]) , today[0], monthToStr(today[1]) ]);
+ runTest(isDateInRange, [ true, current,
+ yesterday[0], monthToStr(yesterday[1]) , tomorrow[0], monthToStr(tomorrow[1]) ]);
+ runTest(isDateInRange, [ true, current,
+ yesterday[0], monthToStr(yesterday[1]), yesterday[2], tomorrow[0], monthToStr(tomorrow[1]), tomorrow[2] ]);
}
}