Debian Codegraph @

rhino/testsrc/tests/js1_3/inherit/proto_8.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_8.js';
7
8 /**
9 File Name: proto_8.js
10 Section:
11 Description: Adding Properties to the Prototype Object
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 Author: [email protected]
22 Date: 12 november 1997
23 */
24
25 var SECTION = "proto_8";
26 var VERSION = "JS1_3";
27 var TITLE = "Adding Properties to the Prototype Object";
28
29 startTest();
30 writeHeaderToLog( SECTION + " "+ TITLE);
31
32 function Employee ( name, dept ) {
33 this.name = name || "";
34 this.dept = dept || "general";
35 }
36 function WorkerBee ( name, dept, projs ) {
37 this.base = Employee;
38 this.base( name, dept)
39 this.projects = projs || new Array();
40 }
41 WorkerBee.prototype = new Employee();
42
43 function Engineer ( name, projs, machine ) {
44 this.base = WorkerBee;
45 this.base( name, "engineering", projs )
46 this.machine = machine || "";
47 }
48 Engineer.prototype = new WorkerBee();
49
50 var pat = new Engineer( "Toonces, Pat",
51 ["SpiderMonkey", "Rhino"],
52 "indy" );
53
54 Employee.prototype.specialty = "none";
55
56
57 // Pat, the Engineer
58
59 new TestCase( SECTION,
60 "pat.name",
61 "Toonces, Pat",
62 pat.name );
63
64 new TestCase( SECTION,
65 "pat.dept",
66 "engineering",
67 pat.dept );
68
69 new TestCase( SECTION,
70 "pat.projects.length",
71 2,
72 pat.projects.length );
73
74 new TestCase( SECTION,
75 "pat.projects[0]",
76 "SpiderMonkey",
77 pat.projects[0] );
78
79 new TestCase( SECTION,
80 "pat.projects[1]",
81 "Rhino",
82 pat.projects[1] );
83
84 new TestCase( SECTION,
85 "pat.machine",
86 "indy",
87 pat.machine );
88
89 new TestCase( SECTION,
90 "pat.specialty",
91 "none",
92 pat.specialty );
93
94 test();