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 format handles non-finite values correctly. michael@0: * @author Norbert Lindenberg michael@0: */ michael@0: michael@0: var invalidValues = [NaN, Infinity, -Infinity]; michael@0: michael@0: var format = new Intl.DateTimeFormat(); michael@0: michael@0: invalidValues.forEach(function (value) { michael@0: var error; michael@0: try { michael@0: var result = format.format(value); michael@0: } catch (e) { michael@0: error = e; michael@0: } michael@0: if (error === undefined) { michael@0: $ERROR("Invalid value " + value + " was not rejected."); michael@0: } else if (error.name !== "RangeError") { michael@0: $ERROR("Invalid value " + value + " was rejected with wrong error " + error.name + "."); michael@0: } michael@0: }); michael@0: