michael@0: // Copyright 2012 Mozilla Corporation. All rights reserved. michael@0: // This code is governed by the BSD license found in the LICENSE file. michael@0: michael@0: /** michael@0: * @description Tests that Date.prototype.toLocaleString & Co. handle non-finite values correctly. michael@0: * @author Norbert Lindenberg michael@0: */ michael@0: michael@0: var functions = { michael@0: toLocaleString: Date.prototype.toLocaleString, michael@0: toLocaleDateString: Date.prototype.toLocaleDateString, michael@0: toLocaleTimeString: Date.prototype.toLocaleTimeString michael@0: }; michael@0: var invalidValues = [NaN, Infinity, -Infinity]; michael@0: michael@0: Object.getOwnPropertyNames(functions).forEach(function (p) { michael@0: var f = functions[p]; michael@0: invalidValues.forEach(function (value) { michael@0: var result = f.call(new Date(value)); michael@0: if (result !== "Invalid Date") { michael@0: $ERROR("Date.prototype." + p + " did not return \"Invalid Date\" for " + michael@0: value + " – got " + result + " instead."); michael@0: } michael@0: }); michael@0: }); michael@0: