michael@0: // Copyright 2013 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 the options minimumSignificantDigits and michael@0: * maximumSignificantDigits are read in the right sequence. michael@0: * @author Norbert Lindenberg michael@0: */ michael@0: michael@0: var read = 0; michael@0: michael@0: function readMinimumSignificantDigits() { michael@0: ++read; michael@0: if (read === 1) { michael@0: return 0; // invalid value, but on first read that's OK michael@0: } else if (read === 3) { michael@0: return 1; // valid value michael@0: } else { michael@0: $ERROR("minimumSignificantDigits read out of sequence: " + read + "."); michael@0: } michael@0: } michael@0: michael@0: function readMaximumSignificantDigits() { michael@0: ++read; michael@0: if (read === 2) { michael@0: return 0; // invalid value, but on first read that's OK michael@0: } else if (read === 4) { michael@0: return 1; // valid value michael@0: } else { michael@0: $ERROR("maximumSignificantDigits read out of sequence: " + read + "."); michael@0: } michael@0: } michael@0: michael@0: var options = {}; michael@0: Object.defineProperty(options, "minimumSignificantDigits", michael@0: { get: readMinimumSignificantDigits }); michael@0: Object.defineProperty(options, "maximumSignificantDigits", michael@0: { get: readMaximumSignificantDigits }); michael@0: michael@0: new Intl.NumberFormat("de", options); michael@0: michael@0: if (read !== 4) { michael@0: $ERROR("insuffient number of property reads: " + read + "."); michael@0: }