js/src/tests/ecma_3/Exceptions/15.11.1.1.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/. */
     6 /*
     7  *
     8  * Date:    27 Nov 2002
     9  * SUMMARY: Ensuring normal function call of Error (ECMA-262 Ed.3 15.11.1.1).
    10  */
    11 //-----------------------------------------------------------------------------
    12 var UBound = 0;
    13 var BUGNUMBER = '';
    14 var summary = 'Ensuring normal function call of Error (ECMA-262 Ed.3 15.11.1.1)';
    15 var status = '';
    16 var statusitems = [];
    17 var actual = '';
    18 var actualvalues = [];
    19 var expect= '';
    20 var expectedvalues = [];
    21 var EMPTY_STRING = '';
    22 var EXPECTED_FORMAT = 0;
    25 function otherScope(msg)
    26 {
    27   return Error(msg);
    28 }
    31 status = inSection(1);
    32 var err1 = Error('msg1');
    33 actual = examineThis(err1, 'msg1');
    34 expect = EXPECTED_FORMAT;
    35 addThis();
    37 status = inSection(2);
    38 var err2 = otherScope('msg2');
    39 actual = examineThis(err2, 'msg2');
    40 expect = EXPECTED_FORMAT;
    41 addThis();
    43 status = inSection(3);
    44 var err3 = otherScope();
    45 actual = examineThis(err3, EMPTY_STRING);
    46 expect = EXPECTED_FORMAT;
    47 addThis();
    49 status = inSection(4);
    50 var err4 = eval("Error('msg4')");
    51 actual = examineThis(err4, 'msg4');
    52 expect = EXPECTED_FORMAT;
    53 addThis();
    57 //-----------------------------------------------------------------------------
    58 test();
    59 //-----------------------------------------------------------------------------
    63 /*
    64  * Searches err.toString() for err.name + ':' + err.message,
    65  * with possible whitespace on each side of the colon sign.
    66  *
    67  * We allow for no colon in case err.message was not provided by the user.
    68  * In such a case, SpiderMonkey and Rhino currently set err.message = '',
    69  * as allowed for by ECMA 15.11.4.3. This makes |pattern| work in this case.
    70  *
    71  * If this is ever changed to a non-empty string, e.g. 'undefined',
    72  * you may have to modify |pattern| to take that into account -
    73  *
    74  */
    75 function examineThis(err, msg)
    76 {
    77   var pattern = err.name + '\\s*:?\\s*' + msg;
    78   return err.toString().search(RegExp(pattern));
    79 }
    82 function addThis()
    83 {
    84   statusitems[UBound] = status;
    85   actualvalues[UBound] = actual;
    86   expectedvalues[UBound] = expect;
    87   UBound++;
    88 }
    91 function test()
    92 {
    93   enterFunc ('test');
    94   printBugNumber(BUGNUMBER);
    95   printStatus (summary);
    97   for (var i = 0; i < UBound; i++)
    98   {
    99     reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]);
   100   }
   102   exitFunc ('test');
   103 }

mercurial