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: /** michael@0: * File Name: instanceof-001.js michael@0: * ECMA Section: 11.8.6 michael@0: * Description: michael@0: * michael@0: * RelationalExpression instanceof Identifier michael@0: * michael@0: * Author: christine@netscape.com michael@0: * Date: 2 September 1998 michael@0: */ michael@0: var SECTION = "instanceof-005-n"; michael@0: var VERSION = "ECMA_2"; michael@0: var TITLE = "instanceof" michael@0: michael@0: startTest(); michael@0: writeHeaderToLog( SECTION + " "+ TITLE); michael@0: michael@0: function InstanceOf( object_1, object_2, expect ) { michael@0: result = object_1 instanceof object_2; michael@0: michael@0: new TestCase( michael@0: SECTION, michael@0: "(" + object_1 + ") instanceof " + object_2, michael@0: expect, michael@0: result ); michael@0: } michael@0: michael@0: function Gen3(value) { michael@0: this.value = value; michael@0: this.generation = 3; michael@0: this.toString = new Function ( "return \"(Gen\"+this.generation+\" instance)\"" ); michael@0: } michael@0: Gen3.name = 3; michael@0: Gen3.__proto__.toString = new Function( "return \"(\"+this.name+\" object)\""); michael@0: michael@0: function Gen2(value) { michael@0: this.value = value; michael@0: this.generation = 2; michael@0: } michael@0: Gen2.name = 2; michael@0: Gen2.prototype = new Gen3(); michael@0: michael@0: function Gen1(value) { michael@0: this.value = value; michael@0: this.generation = 1; michael@0: } michael@0: Gen1.name = 1; michael@0: Gen1.prototype = new Gen2(); michael@0: michael@0: function Gen0(value) { michael@0: this.value = value; michael@0: this.generation = 0; michael@0: } michael@0: Gen0.name = 0; michael@0: Gen0.prototype = new Gen1(); michael@0: michael@0: michael@0: function GenA(value) { michael@0: this.value = value; michael@0: this.generation = "A"; michael@0: this.toString = new Function ( "return \"(instance of Gen\"+this.generation+\")\"" ); michael@0: michael@0: } michael@0: GenA.prototype = new Gen0(); michael@0: GenA.name = "A"; michael@0: michael@0: function GenB(value) { michael@0: this.value = value; michael@0: this.generation = "B"; michael@0: this.toString = new Function ( "return \"(instance of Gen\"+this.generation+\")\"" ); michael@0: } michael@0: GenB.name = "B" michael@0: GenB.prototype = void 0; michael@0: michael@0: michael@0: // Identifier is a function, prototype of Identifier is not an object michael@0: michael@0: DESCRIPTION = "Identifier is a function, prototype of Identifier is not an object"; michael@0: EXPECTED = "error"; michael@0: michael@0: InstanceOf( new GenB(), GenB, "error" ); michael@0: michael@0: test();