Debian Codegraph @

rhino/testsrc/tests/js1_3/inherit/proto_9.js

raw symbols SCIP
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 gTestfile = 'proto_9.js';
7
8 /**
9 File Name: proto_9.js
10 Section:
11 Description: Local versus Inherited Values
12
13 This tests Object Hierarchy and Inheritance, as described in the document
14 Object Hierarchy and Inheritance in JavaScript, last modified on 12/18/97
15 15:19:34 on http://devedge.netscape.com/. Current URL:
16 http://devedge.netscape.com/docs/manuals/communicator/jsobj/contents.htm
17
18 This tests the syntax ObjectName.prototype = new PrototypeObject using the
19 Employee example in the document referenced above.
20
21 This tests
22
23 Author: [email protected]
24 Date: 12 november 1997
25 */
26
27 var SECTION = "proto_9";
28 var VERSION = "JS1_3";
29 var TITLE = "Local versus Inherited Values";
30
31 startTest();
32 writeHeaderToLog( SECTION + " "+ TITLE);
33
34 function Employee ( name, dept ) {
35 this.name = name || "";
36 this.dept = dept || "general";
37 }
38 function WorkerBee ( name, dept, projs ) {
39 this.projects = new Array();
40 }
41 WorkerBee.prototype = new Employee();
42
43 var pat = new WorkerBee()
44
45 Employee.prototype.specialty = "none";
46 Employee.prototype.name = "Unknown";
47
48 Array.prototype.getClass = Object.prototype.toString;
49
50 // Pat, the WorkerBee
51
52 new TestCase( SECTION,
53 "pat.name",
54 "",
55 pat.name );
56
57 new TestCase( SECTION,
58 "pat.dept",
59 "general",
60 pat.dept );
61
62 new TestCase( SECTION,
63 "pat.projects.getClass",
64 "[object Array]",
65 pat.projects.getClass() );
66
67 new TestCase( SECTION,
68 "pat.projects.length",
69 0,
70 pat.projects.length );
71
72 test();