js/src/tests/ecma_3/Object/class-001.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

michael@0 1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
michael@0 2 /* This Source Code Form is subject to the terms of the Mozilla Public
michael@0 3 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 5
michael@0 6 /*
michael@0 7 * Date: 14 Mar 2001
michael@0 8 *
michael@0 9 * SUMMARY: Testing the internal [[Class]] property of objects
michael@0 10 * See ECMA-262 Edition 3 13-Oct-1999, Section 8.6.2
michael@0 11 *
michael@0 12 * The getJSClass() function we use is in a utility file, e.g. "shell.js".
michael@0 13 */
michael@0 14 //-----------------------------------------------------------------------------
michael@0 15 var i = 0;
michael@0 16 var UBound = 0;
michael@0 17 var BUGNUMBER = '(none)';
michael@0 18 var summary = 'Testing the internal [[Class]] property of objects';
michael@0 19 var statprefix = 'Current object is: ';
michael@0 20 var status = ''; var statusList = [ ];
michael@0 21 var actual = ''; var actualvalue = [ ];
michael@0 22 var expect= ''; var expectedvalue = [ ];
michael@0 23
michael@0 24
michael@0 25 status = 'the global object';
michael@0 26 actual = getJSClass(this);
michael@0 27 expect = GLOBAL;
michael@0 28 if (expect == 'Window' && actual == 'XPCCrossOriginWrapper')
michael@0 29 {
michael@0 30 print('Skipping global object due to XPCCrossOriginWrapper. See bug 390946');
michael@0 31 }
michael@0 32 else
michael@0 33 {
michael@0 34 addThis();
michael@0 35 }
michael@0 36
michael@0 37 status = 'new Object()';
michael@0 38 actual = getJSClass(new Object());
michael@0 39 expect = 'Object';
michael@0 40 addThis();
michael@0 41
michael@0 42 status = 'new Function()';
michael@0 43 actual = getJSClass(new Function());
michael@0 44 expect = 'Function';
michael@0 45 addThis();
michael@0 46
michael@0 47 status = 'new Array()';
michael@0 48 actual = getJSClass(new Array());
michael@0 49 expect = 'Array';
michael@0 50 addThis();
michael@0 51
michael@0 52 status = 'new String()';
michael@0 53 actual = getJSClass(new String());
michael@0 54 expect = 'String';
michael@0 55 addThis();
michael@0 56
michael@0 57 status = 'new Boolean()';
michael@0 58 actual = getJSClass(new Boolean());
michael@0 59 expect = 'Boolean';
michael@0 60 addThis();
michael@0 61
michael@0 62 status = 'new Number()';
michael@0 63 actual = getJSClass(new Number());
michael@0 64 expect = 'Number';
michael@0 65 addThis();
michael@0 66
michael@0 67 status = 'Math';
michael@0 68 actual = getJSClass(Math); // can't use 'new' with the Math object (EMCA3, 15.8)
michael@0 69 expect = 'Math';
michael@0 70 addThis();
michael@0 71
michael@0 72 status = 'new Date()';
michael@0 73 actual = getJSClass(new Date());
michael@0 74 expect = 'Date';
michael@0 75 addThis();
michael@0 76
michael@0 77 status = 'new RegExp()';
michael@0 78 actual = getJSClass(new RegExp());
michael@0 79 expect = 'RegExp';
michael@0 80 addThis();
michael@0 81
michael@0 82 status = 'new Error()';
michael@0 83 actual = getJSClass(new Error());
michael@0 84 expect = 'Error';
michael@0 85 addThis();
michael@0 86
michael@0 87
michael@0 88
michael@0 89 //---------------------------------------------------------------------------------
michael@0 90 test();
michael@0 91 //---------------------------------------------------------------------------------
michael@0 92
michael@0 93
michael@0 94
michael@0 95 function addThis()
michael@0 96 {
michael@0 97 statusList[UBound] = status;
michael@0 98 actualvalue[UBound] = actual;
michael@0 99 expectedvalue[UBound] = expect;
michael@0 100 UBound++;
michael@0 101 }
michael@0 102
michael@0 103
michael@0 104 function test()
michael@0 105 {
michael@0 106 enterFunc ('test');
michael@0 107 printBugNumber(BUGNUMBER);
michael@0 108 printStatus (summary);
michael@0 109
michael@0 110 for (i = 0; i < UBound; i++)
michael@0 111 {
michael@0 112 reportCompare(expectedvalue[i], actualvalue[i], getStatus(i));
michael@0 113 }
michael@0 114
michael@0 115 exitFunc ('test');
michael@0 116 }
michael@0 117
michael@0 118
michael@0 119 function getStatus(i)
michael@0 120 {
michael@0 121 return statprefix + statusList[i];
michael@0 122 }

mercurial