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

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
     2 /* This Source Code Form is subject to the terms of the Mozilla Public
     3  * License, v. 2.0. If a copy of the MPL was not distributed with this
     4  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
     7 /**
     8    File Name:          proto_9.js
     9    Section:
    10    Description:        Local versus Inherited Values
    12    This tests Object Hierarchy and Inheritance, as described in the document
    13    Object Hierarchy and Inheritance in JavaScript, last modified on 12/18/97
    14    15:19:34 on http://devedge.netscape.com/.  Current URL:
    15    http://devedge.netscape.com/docs/manuals/communicator/jsobj/contents.htm
    17    This tests the syntax ObjectName.prototype = new PrototypeObject using the
    18    Employee example in the document referenced above.
    20    This tests
    22    Author:             christine@netscape.com
    23    Date:               12 november 1997
    24 */
    26 var SECTION = "proto_9";
    27 var VERSION = "JS1_3";
    28 var TITLE   = "Local versus Inherited Values";
    30 startTest();
    31 writeHeaderToLog( SECTION + " "+ TITLE);
    33 function Employee ( name, dept ) {
    34   this.name = name || "";
    35   this.dept = dept || "general";
    36 }
    37 function WorkerBee ( name, dept, projs ) {
    38   this.projects = new Array();
    39 }
    40 WorkerBee.prototype = new Employee();
    42 var pat = new WorkerBee()
    44   Employee.prototype.specialty = "none";
    45 Employee.prototype.name = "Unknown";
    47 Array.prototype.getClass = Object.prototype.toString;
    49 // Pat, the WorkerBee
    51 new TestCase( SECTION,
    52 	      "pat.name",
    53 	      "",
    54 	      pat.name );
    56 new TestCase( SECTION,
    57 	      "pat.dept",
    58 	      "general",
    59 	      pat.dept );
    61 new TestCase( SECTION,
    62 	      "pat.projects.getClass",
    63 	      "[object Array]",
    64 	      pat.projects.getClass() );
    66 new TestCase( SECTION,
    67 	      "pat.projects.length",
    68 	      0,
    69 	      pat.projects.length );
    71 test();

mercurial