js/src/tests/ecma_3/Object/class-005.js

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

     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 user-defined types.
    10  * See ECMA-262 Edition 3 13-Oct-1999, Section 8.6.2 re [[Class]] property.
    11  *
    12  * Same as class-001.js - but testing user-defined types here, not
    13  * native types.  Therefore we expect the [[Class]] property to equal
    14  * 'Object' in each case -
    15  *
    16  * The getJSClass() function we use is in a utility file, e.g. "shell.js"
    17  */
    18 //-----------------------------------------------------------------------------
    19 var i = 0;
    20 var UBound = 0;
    21 var BUGNUMBER = '(none)';
    22 var summary = 'Testing the internal [[Class]] property of user-defined types';
    23 var statprefix = 'Current user-defined type is: ';
    24 var status = ''; var statusList = [ ];
    25 var actual = ''; var actualvalue = [ ];
    26 var expect= ''; var expectedvalue = [ ];
    29 Calf.prototype= new Cow();
    31 /*
    32  * We set the expect variable each time only for readability.
    33  * We expect 'Object' every time; see discussion above -
    34  */
    35 status = 'new Cow()';
    36 actual = getJSClass(new Cow());
    37 expect = 'Object';
    38 addThis();
    40 status = 'new Calf()';
    41 actual = getJSClass(new Calf());
    42 expect = 'Object';
    43 addThis();
    46 //---------------------------------------------------------------------------------
    47 test();
    48 //---------------------------------------------------------------------------------
    51 function addThis()
    52 {
    53   statusList[UBound] = status;
    54   actualvalue[UBound] = actual;
    55   expectedvalue[UBound] = expect;
    56   UBound++;
    57 }
    60 function test()
    61 {
    62   enterFunc ('test');
    63   printBugNumber(BUGNUMBER);
    64   printStatus (summary);
    66   for (i = 0; i < UBound; i++)
    67   {
    68     reportCompare(expectedvalue[i], actualvalue[i], getStatus(i));
    69   }
    71   exitFunc ('test');
    72 }
    75 function getStatus(i)
    76 {
    77   return statprefix + statusList[i];
    78 }
    81 function Cow(name)
    82 {
    83   this.name=name;
    84 }
    87 function Calf(name)
    88 {
    89   this.name=name;
    90 }

mercurial