js/src/tests/ecma_3/Object/class-003.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  * Date: 14 Mar 2001
     8  *
     9  * SUMMARY: Testing the [[Class]] property of native error types.
    10  * See ECMA-262 Edition 3, Section 8.6.2 for the [[Class]] property.
    11  *
    12  * Same as class-001.js - but testing only the native error types here.
    13  * See ECMA-262 Edition 3, Section 15.11.6 for a list of these types.
    14  *
    15  * ECMA expects the [[Class]] property to equal 'Error' in each case.
    16  * See ECMA-262 Edition 3, Sections 15.11.1.1 and 15.11.7.2 for this.
    17  * See http://bugzilla.mozilla.org/show_bug.cgi?id=56868
    18  *
    19  * The getJSClass() function we use is in a utility file, e.g. "shell.js"
    20  */
    21 //-----------------------------------------------------------------------------
    22 var i = 0;
    23 var UBound = 0;
    24 var BUGNUMBER = 56868;
    25 var summary = 'Testing the internal [[Class]] property of native error types';
    26 var statprefix = 'Current object is: ';
    27 var status = ''; var statusList = [ ];
    28 var actual = ''; var actualvalue = [ ];
    29 var expect= ''; var expectedvalue = [ ];
    31 /*
    32  * We set the expect variable each time only for readability.
    33  * We expect 'Error' every time; see discussion above -
    34  */
    35 status = 'new Error()';
    36 actual = getJSClass(new Error());
    37 expect = 'Error';
    38 addThis();
    40 status = 'new EvalError()';
    41 actual = getJSClass(new EvalError());
    42 expect = 'Error';
    43 addThis();
    45 status = 'new RangeError()';
    46 actual = getJSClass(new RangeError());
    47 expect = 'Error';
    48 addThis();
    50 status = 'new ReferenceError()';
    51 actual = getJSClass(new ReferenceError());
    52 expect = 'Error';
    53 addThis();
    55 status = 'new SyntaxError()';
    56 actual = getJSClass(new SyntaxError());
    57 expect = 'Error';
    58 addThis();
    60 status = 'new TypeError()';
    61 actual = getJSClass(new TypeError());
    62 expect = 'Error';
    63 addThis();
    65 status = 'new URIError()';
    66 actual = getJSClass(new URIError());
    67 expect = 'Error';
    68 addThis();
    72 //---------------------------------------------------------------------------------
    73 test();
    74 //---------------------------------------------------------------------------------
    78 function addThis()
    79 {
    80   statusList[UBound] = status;
    81   actualvalue[UBound] = actual;
    82   expectedvalue[UBound] = expect;
    83   UBound++;
    84 }
    87 function test()
    88 {
    89   enterFunc ('test');
    90   printBugNumber(BUGNUMBER);
    91   printStatus (summary);
    93   for (i = 0; i < UBound; i++)
    94   {
    95     reportCompare(expectedvalue[i], actualvalue[i], getStatus(i));
    96   }
    98   exitFunc ('test');
    99 }
   102 function getStatus(i)
   103 {
   104   return statprefix + statusList[i];
   105 }

mercurial