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 internal [[Class]] property of user-defined types. 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 user-defined types here, not michael@0: * native types. Therefore we expect the [[Class]] property to equal michael@0: * 'Object' 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 user-defined types'; michael@0: var statprefix = 'Current user-defined type 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: Calf.prototype= new Cow(); michael@0: michael@0: /* michael@0: * We set the expect variable each time only for readability. michael@0: * We expect 'Object' every time; see discussion above - michael@0: */ michael@0: status = 'new Cow()'; michael@0: actual = getJSClass(new Cow()); michael@0: expect = 'Object'; michael@0: addThis(); michael@0: michael@0: status = 'new Calf()'; michael@0: actual = getJSClass(new Calf()); michael@0: expect = 'Object'; michael@0: addThis(); michael@0: michael@0: michael@0: //--------------------------------------------------------------------------------- michael@0: test(); 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: } michael@0: michael@0: michael@0: function Cow(name) michael@0: { michael@0: this.name=name; michael@0: } michael@0: michael@0: michael@0: function Calf(name) michael@0: { michael@0: this.name=name; michael@0: }