js/src/tests/ecma_2/extensions/instanceof-003-n.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/tests/ecma_2/extensions/instanceof-003-n.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,88 @@
     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-003-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 +
    1.29 +  result = object_1 instanceof object_2;
    1.30 +
    1.31 +  new TestCase(
    1.32 +    SECTION,
    1.33 +    "(" + object_1 + ") instanceof " + object_2,
    1.34 +    expect,
    1.35 +    result );
    1.36 +}
    1.37 +
    1.38 +function Gen3(value) {
    1.39 +  this.value = value;
    1.40 +  this.generation = 3;
    1.41 +  this.toString = new Function ( "return \"(Gen\"+this.generation+\" instance)\"" );
    1.42 +}
    1.43 +Gen3.name = 3;
    1.44 +Gen3.__proto__.toString = new Function( "return \"(\"+this.name+\" object)\"");
    1.45 +
    1.46 +function Gen2(value) {
    1.47 +  this.value = value;
    1.48 +  this.generation = 2;
    1.49 +}
    1.50 +Gen2.name = 2;
    1.51 +Gen2.prototype = new Gen3();
    1.52 +
    1.53 +function Gen1(value) {
    1.54 +  this.value = value;
    1.55 +  this.generation = 1;
    1.56 +}
    1.57 +Gen1.name = 1;
    1.58 +Gen1.prototype = new Gen2();
    1.59 +
    1.60 +function Gen0(value) {
    1.61 +  this.value = value;
    1.62 +  this.generation = 0;
    1.63 +}
    1.64 +Gen0.name = 0;
    1.65 +Gen0.prototype = new Gen1();
    1.66 +
    1.67 +
    1.68 +function GenA(value) {
    1.69 +  this.value = value;
    1.70 +  this.generation = "A";
    1.71 +  this.toString = new Function ( "return \"(instance of Gen\"+this.generation+\")\"" );
    1.72 +
    1.73 +}
    1.74 +GenA.prototype = new Gen0();
    1.75 +GenA.name = "A";
    1.76 +
    1.77 +function GenB(value) {
    1.78 +  this.value = value;
    1.79 +  this.generation = "B";
    1.80 +  this.toString = new Function ( "return \"(instance of Gen\"+this.generation+\")\"" );
    1.81 +}
    1.82 +GenB.name = "B"
    1.83 +  GenB.prototype = void 0;
    1.84 +
    1.85 +// Identifier is not a function
    1.86 +DESCRIPTION = "Identifier is not a function";
    1.87 +EXPECTED = "error";
    1.88 +
    1.89 +InstanceOf( true, true, "error" );
    1.90 +
    1.91 +test();

mercurial