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 error types. michael@0: * See ECMA-262 Edition 3, Section 8.6.2 for the [[Class]] property. michael@0: * michael@0: * Same as class-001.js - but testing only the native error types here. michael@0: * See ECMA-262 Edition 3, Section 15.11.6 for a list of these types. michael@0: * michael@0: * ECMA expects the [[Class]] property to equal 'Error' in each case. michael@0: * See ECMA-262 Edition 3, Sections 15.11.1.1 and 15.11.7.2 for this. michael@0: * See http://bugzilla.mozilla.org/show_bug.cgi?id=56868 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 types'; michael@0: var statprefix = 'Current object 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 'Error' every time; see discussion above - michael@0: */ michael@0: status = 'new Error()'; michael@0: actual = getJSClass(new Error()); michael@0: expect = 'Error'; michael@0: addThis(); michael@0: michael@0: status = 'new EvalError()'; michael@0: actual = getJSClass(new EvalError()); michael@0: expect = 'Error'; michael@0: addThis(); michael@0: michael@0: status = 'new RangeError()'; michael@0: actual = getJSClass(new RangeError()); michael@0: expect = 'Error'; michael@0: addThis(); michael@0: michael@0: status = 'new ReferenceError()'; michael@0: actual = getJSClass(new ReferenceError()); michael@0: expect = 'Error'; michael@0: addThis(); michael@0: michael@0: status = 'new SyntaxError()'; michael@0: actual = getJSClass(new SyntaxError()); michael@0: expect = 'Error'; michael@0: addThis(); michael@0: michael@0: status = 'new TypeError()'; michael@0: actual = getJSClass(new TypeError()); michael@0: expect = 'Error'; michael@0: addThis(); michael@0: michael@0: status = 'new URIError()'; michael@0: actual = getJSClass(new URIError()); michael@0: expect = 'Error'; 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: }