2 * File Name: instanceof-001.js
6 * RelationalExpression instanceof Identifier
8 * Author: christine@netscape.com
9 * Date: 2 September 1998
11 var SECTION = "instanceof-001";
12 var VERSION = "ECMA_2";
13 var TITLE = "instanceof"
16 writeHeaderToLog( SECTION + " "+ TITLE);
19 var testcases = new Array();
21 function InstanceOf( object_1, object_2, expect ) {
22 result = object_1 instanceof object_2;
24 testcases[tc++] = new TestCase(
26 "(" + object_1 + ") instanceof " + object_2,
31 function Gen3(value) {
34 this.toString = new Function ( "return \"(Gen\"+this.generation+\" instance)\"" );
37 Gen3.__proto__.toString = new Function( "return \"(\"+this.name+\" object)\"");
39 function Gen2(value) {
44 Gen2.prototype = new Gen3();
46 function Gen1(value) {
51 Gen1.prototype = new Gen2();
53 function Gen0(value) {
58 Gen0.prototype = new Gen1();
61 function GenA(value) {
63 this.generation = "A";
64 this.toString = new Function ( "return \"(instance of Gen\"+this.generation+\")\"" );
67 GenA.prototype = new Gen0();
70 function GenB(value) {
72 this.generation = "B";
73 this.toString = new Function ( "return \"(instance of Gen\"+this.generation+\")\"" );
76 GenB.prototype = void 0;
78 // RelationalExpression is not an object.
80 InstanceOf( true, Boolean, false );
81 InstanceOf( new Boolean(false), Boolean, true );
83 // Identifier is not a function
85 InstanceOf( new Boolean(true), false, false );
87 // Identifier is a function, prototype of Identifier is not an object
89 // InstanceOf( new GenB(), GenB, false );