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/. */
10
Description: new PrototypeObject
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
If you add a property to an object in the prototype chain, instances of
21
objects that derive from that prototype should inherit that property, even
22
if they were instatiated after the property was added to the prototype object.
25
Author: christine@netscape.com
26
Date: 12 november 1997
29
var SECTION = "proto_3";
30
var VERSION = "JS1_3";
31
var TITLE = "Adding properties to the prototype";
34
writeHeaderToLog( SECTION + " "+ TITLE);
36
function Employee () {
38
this.dept = "general";
43
Manager.prototype = new Employee();
45
function WorkerBee () {
46
this.projects = new Array();
49
WorkerBee.prototype = new Employee();
51
function SalesPerson () {
55
SalesPerson.prototype = new WorkerBee();
57
function Engineer () {
58
this.dept = "engineering";
61
Engineer.prototype = new WorkerBee();
63
var jim = new Employee();
64
var terry = new Engineer();
65
var sean = new SalesPerson();
66
var wally = new Manager();
68
Employee.prototype.specialty = "none";
70
var pat = new Employee();
71
var leslie = new Engineer();
72
var bubbles = new SalesPerson();
73
var furry = new Manager();
75
Engineer.prototype.specialty = "code";
77
var chris = new Engineer();
80
new TestCase( SECTION,
81
"jim = new Employee(); jim.specialty",
85
new TestCase( SECTION,
86
"terry = new Engineer(); terry.specialty",
90
new TestCase( SECTION,
91
"sean = new SalesPerson(); sean.specialty",
95
new TestCase( SECTION,
96
"wally = new Manager(); wally.specialty",
100
new TestCase( SECTION,
101
"furry = new Manager(); furry.specialty",
105
new TestCase( SECTION,
106
"pat = new Employee(); pat.specialty",
110
new TestCase( SECTION,
111
"leslie = new Engineer(); leslie.specialty",
115
new TestCase( SECTION,
116
"bubbles = new SalesPerson(); bubbles.specialty",
121
new TestCase( SECTION,
122
"chris = new Employee(); chris.specialty",