Wed, 31 Dec 2014 06:55:50 +0100
Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2
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_8.js
9 Section:
10 Description: Adding Properties to the Prototype Object
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 Author: christine@netscape.com
21 Date: 12 november 1997
22 */
24 var SECTION = "proto_8";
25 var VERSION = "JS1_3";
26 var TITLE = "Adding Properties to the Prototype Object";
28 startTest();
29 writeHeaderToLog( SECTION + " "+ TITLE);
31 function Employee ( name, dept ) {
32 this.name = name || "";
33 this.dept = dept || "general";
34 }
35 function WorkerBee ( name, dept, projs ) {
36 this.base = Employee;
37 this.base( name, dept)
38 this.projects = projs || new Array();
39 }
40 WorkerBee.prototype = new Employee();
42 function Engineer ( name, projs, machine ) {
43 this.base = WorkerBee;
44 this.base( name, "engineering", projs )
45 this.machine = machine || "";
46 }
47 Engineer.prototype = new WorkerBee();
49 var pat = new Engineer( "Toonces, Pat",
50 ["SpiderMonkey", "Rhino"],
51 "indy" );
53 Employee.prototype.specialty = "none";
56 // Pat, the Engineer
58 new TestCase( SECTION,
59 "pat.name",
60 "Toonces, Pat",
61 pat.name );
63 new TestCase( SECTION,
64 "pat.dept",
65 "engineering",
66 pat.dept );
68 new TestCase( SECTION,
69 "pat.projects.length",
70 2,
71 pat.projects.length );
73 new TestCase( SECTION,
74 "pat.projects[0]",
75 "SpiderMonkey",
76 pat.projects[0] );
78 new TestCase( SECTION,
79 "pat.projects[1]",
80 "Rhino",
81 pat.projects[1] );
83 new TestCase( SECTION,
84 "pat.machine",
85 "indy",
86 pat.machine );
88 new TestCase( SECTION,
89 "pat.specialty",
90 "none",
91 pat.specialty );
93 test();