js/src/tests/js1_3/inherit/proto_9.js

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/js/src/tests/js1_3/inherit/proto_9.js	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,71 @@
     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:          proto_9.js
    1.12 +   Section:
    1.13 +   Description:        Local versus Inherited Values
    1.14 +
    1.15 +   This tests Object Hierarchy and Inheritance, as described in the document
    1.16 +   Object Hierarchy and Inheritance in JavaScript, last modified on 12/18/97
    1.17 +   15:19:34 on http://devedge.netscape.com/.  Current URL:
    1.18 +   http://devedge.netscape.com/docs/manuals/communicator/jsobj/contents.htm
    1.19 +
    1.20 +   This tests the syntax ObjectName.prototype = new PrototypeObject using the
    1.21 +   Employee example in the document referenced above.
    1.22 +
    1.23 +   This tests
    1.24 +
    1.25 +   Author:             christine@netscape.com
    1.26 +   Date:               12 november 1997
    1.27 +*/
    1.28 +
    1.29 +var SECTION = "proto_9";
    1.30 +var VERSION = "JS1_3";
    1.31 +var TITLE   = "Local versus Inherited Values";
    1.32 +
    1.33 +startTest();
    1.34 +writeHeaderToLog( SECTION + " "+ TITLE);
    1.35 +
    1.36 +function Employee ( name, dept ) {
    1.37 +  this.name = name || "";
    1.38 +  this.dept = dept || "general";
    1.39 +}
    1.40 +function WorkerBee ( name, dept, projs ) {
    1.41 +  this.projects = new Array();
    1.42 +}
    1.43 +WorkerBee.prototype = new Employee();
    1.44 +
    1.45 +var pat = new WorkerBee()
    1.46 +
    1.47 +  Employee.prototype.specialty = "none";
    1.48 +Employee.prototype.name = "Unknown";
    1.49 +
    1.50 +Array.prototype.getClass = Object.prototype.toString;
    1.51 +
    1.52 +// Pat, the WorkerBee
    1.53 +
    1.54 +new TestCase( SECTION,
    1.55 +	      "pat.name",
    1.56 +	      "",
    1.57 +	      pat.name );
    1.58 +
    1.59 +new TestCase( SECTION,
    1.60 +	      "pat.dept",
    1.61 +	      "general",
    1.62 +	      pat.dept );
    1.63 +
    1.64 +new TestCase( SECTION,
    1.65 +	      "pat.projects.getClass",
    1.66 +	      "[object Array]",
    1.67 +	      pat.projects.getClass() );
    1.68 +
    1.69 +new TestCase( SECTION,
    1.70 +	      "pat.projects.length",
    1.71 +	      0,
    1.72 +	      pat.projects.length );
    1.73 +
    1.74 +test();

mercurial