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

branch
TOR_BUG_3246
changeset 6
8bccb770b82d
equal deleted inserted replaced
-1:000000000000 0:fed47f8d8db8
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/. */
5
6
7 /**
8 File Name: proto_9.js
9 Section:
10 Description: Local versus Inherited Values
11
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
16
17 This tests the syntax ObjectName.prototype = new PrototypeObject using the
18 Employee example in the document referenced above.
19
20 This tests
21
22 Author: christine@netscape.com
23 Date: 12 november 1997
24 */
25
26 var SECTION = "proto_9";
27 var VERSION = "JS1_3";
28 var TITLE = "Local versus Inherited Values";
29
30 startTest();
31 writeHeaderToLog( SECTION + " "+ TITLE);
32
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();
41
42 var pat = new WorkerBee()
43
44 Employee.prototype.specialty = "none";
45 Employee.prototype.name = "Unknown";
46
47 Array.prototype.getClass = Object.prototype.toString;
48
49 // Pat, the WorkerBee
50
51 new TestCase( SECTION,
52 "pat.name",
53 "",
54 pat.name );
55
56 new TestCase( SECTION,
57 "pat.dept",
58 "general",
59 pat.dept );
60
61 new TestCase( SECTION,
62 "pat.projects.getClass",
63 "[object Array]",
64 pat.projects.getClass() );
65
66 new TestCase( SECTION,
67 "pat.projects.length",
68 0,
69 pat.projects.length );
70
71 test();

mercurial