michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: /* michael@0: * Date: 14 Mar 2001 michael@0: * michael@0: * SUMMARY: Testing the [[Class]] property of native constructors. michael@0: * See ECMA-262 Edition 3 13-Oct-1999, Section 8.6.2 re [[Class]] property. michael@0: * michael@0: * Same as class-001.js - but testing the constructors here, not michael@0: * object instances. Therefore we expect the [[Class]] property to michael@0: * equal 'Function' in each case. michael@0: * michael@0: * The getJSClass() function we use is in a utility file, e.g. "shell.js" michael@0: */ michael@0: //----------------------------------------------------------------------------- michael@0: var i = 0; michael@0: var UBound = 0; michael@0: var BUGNUMBER = '(none)'; michael@0: var summary = 'Testing the internal [[Class]] property of native constructors'; michael@0: var statprefix = 'Current constructor is: '; michael@0: var status = ''; var statusList = [ ]; michael@0: var actual = ''; var actualvalue = [ ]; michael@0: var expect= ''; var expectedvalue = [ ]; michael@0: michael@0: /* michael@0: * We set the expect variable each time only for readability. michael@0: * We expect 'Function' every time; see discussion above - michael@0: */ michael@0: status = 'Object'; michael@0: actual = getJSClass(Object); michael@0: expect = 'Function'; michael@0: addThis(); michael@0: michael@0: status = 'Function'; michael@0: actual = getJSClass(Function); michael@0: expect = 'Function'; michael@0: addThis(); michael@0: michael@0: status = 'Array'; michael@0: actual = getJSClass(Array); michael@0: expect = 'Function'; michael@0: addThis(); michael@0: michael@0: status = 'String'; michael@0: actual = getJSClass(String); michael@0: expect = 'Function'; michael@0: addThis(); michael@0: michael@0: status = 'Boolean'; michael@0: actual = getJSClass(Boolean); michael@0: expect = 'Function'; michael@0: addThis(); michael@0: michael@0: status = 'Number'; michael@0: actual = getJSClass(Number); michael@0: expect = 'Function'; michael@0: addThis(); michael@0: michael@0: status = 'Date'; michael@0: actual = getJSClass(Date); michael@0: expect = 'Function'; michael@0: addThis(); michael@0: michael@0: status = 'RegExp'; michael@0: actual = getJSClass(RegExp); michael@0: expect = 'Function'; michael@0: addThis(); michael@0: michael@0: status = 'Error'; michael@0: actual = getJSClass(Error); michael@0: expect = 'Function'; michael@0: addThis(); michael@0: michael@0: michael@0: michael@0: //--------------------------------------------------------------------------------- michael@0: test(); michael@0: //--------------------------------------------------------------------------------- michael@0: michael@0: michael@0: michael@0: function addThis() michael@0: { michael@0: statusList[UBound] = status; michael@0: actualvalue[UBound] = actual; michael@0: expectedvalue[UBound] = expect; michael@0: UBound++; michael@0: } michael@0: michael@0: michael@0: function test() michael@0: { michael@0: enterFunc ('test'); michael@0: printBugNumber(BUGNUMBER); michael@0: printStatus (summary); michael@0: michael@0: for (i = 0; i < UBound; i++) michael@0: { michael@0: reportCompare(expectedvalue[i], actualvalue[i], getStatus(i)); michael@0: } michael@0: michael@0: exitFunc ('test'); michael@0: } michael@0: michael@0: michael@0: function getStatus(i) michael@0: { michael@0: return statprefix + statusList[i]; michael@0: }