1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/ecma_2/extensions/instanceof-005-n.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,89 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 + 1.10 +/** 1.11 + * File Name: instanceof-001.js 1.12 + * ECMA Section: 11.8.6 1.13 + * Description: 1.14 + * 1.15 + * RelationalExpression instanceof Identifier 1.16 + * 1.17 + * Author: christine@netscape.com 1.18 + * Date: 2 September 1998 1.19 + */ 1.20 +var SECTION = "instanceof-005-n"; 1.21 +var VERSION = "ECMA_2"; 1.22 +var TITLE = "instanceof" 1.23 + 1.24 + startTest(); 1.25 +writeHeaderToLog( SECTION + " "+ TITLE); 1.26 + 1.27 +function InstanceOf( object_1, object_2, expect ) { 1.28 + result = object_1 instanceof object_2; 1.29 + 1.30 + new TestCase( 1.31 + SECTION, 1.32 + "(" + object_1 + ") instanceof " + object_2, 1.33 + expect, 1.34 + result ); 1.35 +} 1.36 + 1.37 +function Gen3(value) { 1.38 + this.value = value; 1.39 + this.generation = 3; 1.40 + this.toString = new Function ( "return \"(Gen\"+this.generation+\" instance)\"" ); 1.41 +} 1.42 +Gen3.name = 3; 1.43 +Gen3.__proto__.toString = new Function( "return \"(\"+this.name+\" object)\""); 1.44 + 1.45 +function Gen2(value) { 1.46 + this.value = value; 1.47 + this.generation = 2; 1.48 +} 1.49 +Gen2.name = 2; 1.50 +Gen2.prototype = new Gen3(); 1.51 + 1.52 +function Gen1(value) { 1.53 + this.value = value; 1.54 + this.generation = 1; 1.55 +} 1.56 +Gen1.name = 1; 1.57 +Gen1.prototype = new Gen2(); 1.58 + 1.59 +function Gen0(value) { 1.60 + this.value = value; 1.61 + this.generation = 0; 1.62 +} 1.63 +Gen0.name = 0; 1.64 +Gen0.prototype = new Gen1(); 1.65 + 1.66 + 1.67 +function GenA(value) { 1.68 + this.value = value; 1.69 + this.generation = "A"; 1.70 + this.toString = new Function ( "return \"(instance of Gen\"+this.generation+\")\"" ); 1.71 + 1.72 +} 1.73 +GenA.prototype = new Gen0(); 1.74 +GenA.name = "A"; 1.75 + 1.76 +function GenB(value) { 1.77 + this.value = value; 1.78 + this.generation = "B"; 1.79 + this.toString = new Function ( "return \"(instance of Gen\"+this.generation+\")\"" ); 1.80 +} 1.81 +GenB.name = "B" 1.82 + GenB.prototype = void 0; 1.83 + 1.84 + 1.85 +// Identifier is a function, prototype of Identifier is not an object 1.86 + 1.87 +DESCRIPTION = "Identifier is a function, prototype of Identifier is not an object"; 1.88 +EXPECTED = "error"; 1.89 + 1.90 +InstanceOf( new GenB(), GenB, "error" ); 1.91 + 1.92 +test();