default-minimum-singificant-digits.js (1080B)
1 // Copyright (C) 2017 the V8 project authors. All rights reserved. 2 // This code is governed by the BSD license found in the LICENSE file. 3 4 /*--- 5 description: Tests that the default value of minimumSignificantDigits is 1. 6 esid: sec-setnfdigitoptions 7 ---*/ 8 9 // maximumSignificantDigits needs to be in range from minimumSignificantDigits 10 // to 21 (both inclusive). Setting maximumSignificantDigits to 0 will throw a 11 // RangeError if the (default) minimumSignificantDigits is at least 1. 12 assert.throws(RangeError, function() { 13 Intl.NumberFormat(undefined, {maximumSignificantDigits: 0}); 14 }); 15 16 // If nothing is thrown, check that the options are resolved appropriately. 17 var res = Intl.NumberFormat(undefined, {maximumSignificantDigits: 1}) 18 19 assert.sameValue(Object.getPrototypeOf(res), Intl.NumberFormat.prototype, 'result is an instance of NumberFormat') 20 assert.sameValue(res.resolvedOptions().minimumSignificantDigits, 1, 'default minimumSignificantDigits') 21 assert.sameValue(res.resolvedOptions().maximumSignificantDigits, 1, 'sets maximumSignificantDigits') 22 23 reportCompare(0, 0);