js/src/tests/test262/intl402/ch11/11.3/11.3.2_FN_2.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/tests/test262/intl402/ch11/11.3/11.3.2_FN_2.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,59 @@
     1.4 +// Copyright 2012 Google Inc.  All rights reserved.
     1.5 +// This code is governed by the BSD license found in the LICENSE file.
     1.6 +
     1.7 +/**
     1.8 + * @description Tests that Intl.NumberFormat.prototype.format
     1.9 + * handles NaN, Infinity, and -Infinity properly.
    1.10 + * @author: Roozbeh Pournader
    1.11 + */
    1.12 +
    1.13 +// FIXME: We are only listing Numeric_Type=Decimal. May need to add more
    1.14 +// when the spec clarifies. Current as of Unicode 6.1.
    1.15 +var hasUnicodeDigits = new RegExp('.*([' +
    1.16 +    '0-9\u0660-\u0669\u06F0-\u06F9\u07C0-\u07C9\u0966-\u096F' +
    1.17 +    '\u09E6-\u09EF\u0A66-\u0A6F\u0AE6-\u0AEF\u0B66-\u0B6F\u0BE6-\u0BEF' +
    1.18 +    '\u0C66-\u0C6F\u0CE6-\u0CEF\u0D66-\u0D6F\u0E50-\u0E59\u0ED0-\u0ED9' +
    1.19 +    '\u0F20-\u0F29\u1040-\u1049\u1090-\u1099\u17E0-\u17E9\u1810-\u1819' +
    1.20 +    '\u1946-\u194F\u19D0-\u19D9\u1A80-\u1A89\u1A90-\u1A99\u1B50-\u1B59' +
    1.21 +    '\u1BB0-\u1BB9\u1C40-\u1C49\u1C50-\u1C59\uA620-\uA629\uA8D0-\uA8D9' +
    1.22 +    '\uA900-\uA909\uA9D0-\uA9D9\uAA50-\uAA59\uABF0-\uABF9\uFF10-\uFF19' +
    1.23 +    ']|' +
    1.24 +    '\uD801[\uDCA0-\uDCA9]|' +
    1.25 +    '\uD804[\uDC66-\uDC6F\uDCF0-\uDCF9\uDD36-\uDD3F\uDDD0-\uDDD9]|' +
    1.26 +    '\uD805[\uDEC0-\uDEC9]|' +
    1.27 +    '\uD835[\uDFCE-\uDFFF])');
    1.28 +
    1.29 +var formatter = new Intl.NumberFormat();
    1.30 +var formattedNaN = formatter.format(NaN);
    1.31 +var formattedInfinity = formatter.format(Infinity);
    1.32 +var formattedNegativeInfinity = formatter.format(-Infinity);
    1.33 +
    1.34 +if (formattedNaN === formattedInfinity) {
    1.35 +    $ERROR('Intl.NumberFormat formats NaN and Infinity the ' +
    1.36 +        'same way.');
    1.37 +}
    1.38 +
    1.39 +if (formattedNaN === formattedNegativeInfinity) {
    1.40 +    $ERROR('Intl.NumberFormat formats NaN and negative ' +
    1.41 +        'Infinity the same way.');
    1.42 +}
    1.43 +
    1.44 +if (formattedInfinity === formattedNegativeInfinity) {
    1.45 +    $ERROR('Intl.NumberFormat formats Infinity and ' +
    1.46 +        'negative Infinity the same way.');
    1.47 +}
    1.48 +
    1.49 +if (hasUnicodeDigits.test(formattedNaN)) {
    1.50 +    $ERROR('Intl.NumberFormat formats NaN using a digit.');
    1.51 +}
    1.52 +
    1.53 +if (hasUnicodeDigits.test(formattedInfinity)) {
    1.54 +    $ERROR('Intl.NumberFormat formats Infinity using a ' +
    1.55 +        'digit.');
    1.56 +}
    1.57 +
    1.58 +if (hasUnicodeDigits.test(formattedNegativeInfinity)) {
    1.59 +    $ERROR('Intl.NumberFormat formats negative Infinity ' + 
    1.60 +        'using a digit.');
    1.61 +}
    1.62 +

mercurial