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 [[Class]] property of native error constructors. michael@0: * See ECMA-262 Edition 3, Section 8.6.2 for the [[Class]] property. michael@0: * michael@0: * See ECMA-262 Edition 3, Section 15.11.6 for the native error types. michael@0: * See http://bugzilla.mozilla.org/show_bug.cgi?id=56868 michael@0: * michael@0: * Same as class-003.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 = 56868; michael@0: var summary = 'Testing the internal [[Class]] property of native error 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 = 'Error'; michael@0: actual = getJSClass(Error); michael@0: expect = 'Function'; michael@0: addThis(); michael@0: michael@0: status = 'EvalError'; michael@0: actual = getJSClass(EvalError); michael@0: expect = 'Function'; michael@0: addThis(); michael@0: michael@0: status = 'RangeError'; michael@0: actual = getJSClass(RangeError); michael@0: expect = 'Function'; michael@0: addThis(); michael@0: michael@0: status = 'ReferenceError'; michael@0: actual = getJSClass(ReferenceError); michael@0: expect = 'Function'; michael@0: addThis(); michael@0: michael@0: status = 'SyntaxError'; michael@0: actual = getJSClass(SyntaxError); michael@0: expect = 'Function'; michael@0: addThis(); michael@0: michael@0: status = 'TypeError'; michael@0: actual = getJSClass(TypeError); michael@0: expect = 'Function'; michael@0: addThis(); michael@0: michael@0: status = 'URIError'; michael@0: actual = getJSClass(URIError); 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: }