js/src/tests/ecma_3/Object/class-001.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 internal [[Class]] property of objects
    10  * See ECMA-262 Edition 3 13-Oct-1999, Section 8.6.2
    11  *
    12  * The getJSClass() function we use is in a utility file, e.g. "shell.js".
    13  */
    14 //-----------------------------------------------------------------------------
    15 var i = 0;
    16 var UBound = 0;
    17 var BUGNUMBER = '(none)';
    18 var summary = 'Testing the internal [[Class]] property of objects';
    19 var statprefix = 'Current object is: ';
    20 var status = ''; var statusList = [ ];
    21 var actual = ''; var actualvalue = [ ];
    22 var expect= ''; var expectedvalue = [ ];
    25 status = 'the global object';
    26 actual = getJSClass(this);
    27 expect = GLOBAL;
    28 if (expect == 'Window' && actual == 'XPCCrossOriginWrapper')
    29 {
    30   print('Skipping global object due to XPCCrossOriginWrapper. See bug 390946');
    31 }
    32 else
    33 {
    34   addThis();
    35 }
    37 status = 'new Object()';
    38 actual = getJSClass(new Object());
    39 expect = 'Object';
    40 addThis();
    42 status = 'new Function()';
    43 actual = getJSClass(new Function());
    44 expect = 'Function';
    45 addThis();
    47 status = 'new Array()';
    48 actual = getJSClass(new Array());
    49 expect = 'Array';
    50 addThis();
    52 status = 'new String()';
    53 actual = getJSClass(new String());
    54 expect = 'String';
    55 addThis();
    57 status = 'new Boolean()';
    58 actual = getJSClass(new Boolean());
    59 expect = 'Boolean';
    60 addThis();
    62 status = 'new Number()';
    63 actual = getJSClass(new Number());
    64 expect = 'Number';
    65 addThis();
    67 status = 'Math';
    68 actual = getJSClass(Math);  // can't use 'new' with the Math object (EMCA3, 15.8)
    69 expect = 'Math';
    70 addThis();
    72 status = 'new Date()';
    73 actual = getJSClass(new Date());
    74 expect = 'Date';
    75 addThis();
    77 status = 'new RegExp()';
    78 actual = getJSClass(new RegExp());
    79 expect = 'RegExp';
    80 addThis();
    82 status = 'new Error()';
    83 actual = getJSClass(new Error());
    84 expect = 'Error';
    85 addThis();
    89 //---------------------------------------------------------------------------------
    90 test();
    91 //---------------------------------------------------------------------------------
    95 function addThis()
    96 {
    97   statusList[UBound] = status;
    98   actualvalue[UBound] = actual;
    99   expectedvalue[UBound] = expect;
   100   UBound++;
   101 }
   104 function test()
   105 {
   106   enterFunc ('test');
   107   printBugNumber(BUGNUMBER);
   108   printStatus (summary);
   110   for (i = 0; i < UBound; i++)
   111   {
   112     reportCompare(expectedvalue[i], actualvalue[i], getStatus(i));
   113   }
   115   exitFunc ('test');
   116 }
   119 function getStatus(i)
   120 {
   121   return statprefix + statusList[i];
   122 }

mercurial