js/src/tests/ecma/GlobalObject/15.1.2.2-2.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     7 /**
     8    File Name:          15.1.2.2-1.js
     9    ECMA Section:       15.1.2.2 Function properties of the global object
    10    parseInt( string, radix )
    12    Description:        parseInt test cases written by waldemar, and documented in
    13    http://scopus.mcom.com/bugsplat/show_bug.cgi?id=123874.
    15    Author:             christine@netscape.com
    16    Date:               28 october 1997
    18 */
    19 var SECTION = "15.1.2.2-2";
    20 var VERSION = "ECMA_1";
    21 var TITLE   = "parseInt(string, radix)";
    22 var BUGNUMBER = "none";
    24 startTest();
    26 writeHeaderToLog( SECTION + " "+ TITLE);
    28 new TestCase( SECTION,
    29 	      'parseInt("000000100000000100100011010001010110011110001001101010111100",2)',
    30 	      9027215253084860,
    31 	      parseInt("000000100000000100100011010001010110011110001001101010111100",2) );
    33 new TestCase( SECTION,
    34 	      'parseInt("000000100000000100100011010001010110011110001001101010111101",2)',
    35 	      9027215253084860,
    36 	      parseInt("000000100000000100100011010001010110011110001001101010111101",2));
    38 new TestCase( SECTION,
    39 	      'parseInt("000000100000000100100011010001010110011110001001101010111111",2)',
    40 	      9027215253084864,
    41 	      parseInt("000000100000000100100011010001010110011110001001101010111111",2) );
    43 new TestCase( SECTION,
    44 	      'parseInt("0000001000000001001000110100010101100111100010011010101111010",2)',
    45 	      18054430506169720,
    46 	      parseInt("0000001000000001001000110100010101100111100010011010101111010",2) );
    48 new TestCase( SECTION,
    49 	      'parseInt("0000001000000001001000110100010101100111100010011010101111011",2)',
    50 	      18054430506169724,
    51 	      parseInt("0000001000000001001000110100010101100111100010011010101111011",2));
    53 new TestCase( SECTION,
    54 	      'parseInt("0000001000000001001000110100010101100111100010011010101111100",2)',
    55 	      18054430506169724,
    56 	      parseInt("0000001000000001001000110100010101100111100010011010101111100",2) );
    58 new TestCase( SECTION,
    59 	      'parseInt("0000001000000001001000110100010101100111100010011010101111110",2)',
    60 	      18054430506169728,
    61 	      parseInt("0000001000000001001000110100010101100111100010011010101111110",2) );
    63 new TestCase( SECTION,
    64 	      'parseInt("yz",35)',
    65 	      34,
    66 	      parseInt("yz",35) );
    68 new TestCase( SECTION,
    69 	      'parseInt("yz",36)',
    70 	      1259,
    71 	      parseInt("yz",36) );
    73 new TestCase( SECTION,
    74 	      'parseInt("yz",37)',
    75 	      NaN,
    76 	      parseInt("yz",37) );
    78 new TestCase( SECTION,
    79 	      'parseInt("+77")',
    80 	      77,
    81 	      parseInt("+77") );
    83 new TestCase( SECTION,
    84 	      'parseInt("-77",9)',
    85 	      -70,
    86 	      parseInt("-77",9) );
    88 new TestCase( SECTION,
    89 	      'parseInt("\u20001234\u2000")',
    90 	      1234,
    91 	      parseInt("\u20001234\u2000") );
    93 new TestCase( SECTION,
    94 	      'parseInt("123456789012345678")',
    95 	      123456789012345680,
    96 	      parseInt("123456789012345678") );
    98 new TestCase( SECTION,
    99 	      'parseInt("9",8)',
   100 	      NaN,
   101 	      parseInt("9",8) );
   103 new TestCase( SECTION,
   104 	      'parseInt("1e2")',
   105 	      1,
   106 	      parseInt("1e2") );
   108 new TestCase( SECTION,
   109 	      'parseInt("1.9999999999999999999")',
   110 	      1,
   111 	      parseInt("1.9999999999999999999") );
   113 new TestCase( SECTION,
   114 	      'parseInt("0x10")',
   115 	      16,
   116 	      parseInt("0x10") );
   118 new TestCase( SECTION,
   119 	      'parseInt("0x10",10)',
   120 	      0,
   121 	      parseInt("0x10",10));
   123 new TestCase( SECTION,
   124 	      'parseInt("0022")',
   125 	      22,
   126 	      parseInt("0022"));
   128 new TestCase( SECTION,
   129 	      'parseInt("0022", 8)',
   130 	      18,
   131 	      parseInt("0022", 8));
   133 new TestCase( SECTION,
   134 	      'parseInt("0022", 10)',
   135 	      22,
   136 	      parseInt("0022", 10) );
   138 new TestCase( SECTION,
   139 	      'parseInt("0x1000000000000080")',
   140 	      1152921504606847000,
   141 	      parseInt("0x1000000000000080") );
   143 new TestCase( SECTION,
   144 	      'parseInt("0x1000000000000081")',
   145 	      1152921504606847200,
   146 	      parseInt("0x1000000000000081") );
   148 s =
   149   "0xFFFFFFFFFFFFF80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
   151   s += "0000000000000000000000000000000000000";
   153 new TestCase( SECTION,
   154 	      "s = " + s +"; -s",
   155 	      -1.7976931348623157e+308,
   156 	      -s );
   158 s =
   159   "0xFFFFFFFFFFFFF80000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000";
   160 s += "0000000000000000000000000000000000001";
   162 new TestCase( SECTION,
   163 	      "s = " + s +"; -s",
   164 	      -1.7976931348623157e+308,
   165 	      -s );
   168 s = "0xFFFFFFFFFFFFFC0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000";
   170 s += "0000000000000000000000000000000000000"
   173 new TestCase( SECTION,
   174 	      "s = " + s + "; -s",
   175 	      -Infinity,
   176 	      -s );
   178 s = "0xFFFFFFFFFFFFFB0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000";
   179 s += "0000000000000000000000000000000000001";
   181 new TestCase( SECTION,
   182 	      "s = " + s + "; -s",
   183 	      -1.7976931348623157e+308,
   184 	      -s );
   186 s += "0"
   188 new TestCase( SECTION,
   189 	      "s = " + s + "; -s",
   190 	      -Infinity,
   191 	      -s );
   193 new TestCase( SECTION,
   194 	      'parseInt(s)',
   195 	      Infinity,
   196 	      parseInt(s) );
   198 new TestCase( SECTION,
   199 	      'parseInt(s,32)',
   200 	      0,
   201 	      parseInt(s,32) );
   203 new TestCase( SECTION,
   204 	      'parseInt(s,36)',
   205 	      Infinity,
   206 	      parseInt(s,36));
   208 test();

mercurial