Wed, 31 Dec 2014 13:27:57 +0100
Ignore runtime configuration files generated during quality assurance.
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
michael@0 | 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | |
michael@0 | 7 | /** |
michael@0 | 8 | File Name: proto_6.js |
michael@0 | 9 | Section: |
michael@0 | 10 | Description: Logical OR || in constructors |
michael@0 | 11 | |
michael@0 | 12 | This tests Object Hierarchy and Inheritance, as described in the document |
michael@0 | 13 | Object Hierarchy and Inheritance in JavaScript, last modified on 12/18/97 |
michael@0 | 14 | 15:19:34 on http://devedge.netscape.com/. Current URL: |
michael@0 | 15 | http://devedge.netscape.com/docs/manuals/communicator/jsobj/contents.htm |
michael@0 | 16 | |
michael@0 | 17 | This tests the syntax ObjectName.prototype = new PrototypeObject using the |
michael@0 | 18 | Employee example in the document referenced above. |
michael@0 | 19 | |
michael@0 | 20 | This tests the logical OR opererator || syntax in constructors. |
michael@0 | 21 | |
michael@0 | 22 | Author: christine@netscape.com |
michael@0 | 23 | Date: 12 november 1997 |
michael@0 | 24 | */ |
michael@0 | 25 | |
michael@0 | 26 | var SECTION = "proto_6"; |
michael@0 | 27 | var VERSION = "JS1_3"; |
michael@0 | 28 | var TITLE = "Logical OR || in constructors"; |
michael@0 | 29 | |
michael@0 | 30 | startTest(); |
michael@0 | 31 | writeHeaderToLog( SECTION + " "+ TITLE); |
michael@0 | 32 | |
michael@0 | 33 | function Employee ( name, dept ) { |
michael@0 | 34 | this.name = name || ""; |
michael@0 | 35 | this.dept = dept || "general"; |
michael@0 | 36 | } |
michael@0 | 37 | function Manager () { |
michael@0 | 38 | this.reports = []; |
michael@0 | 39 | } |
michael@0 | 40 | Manager.prototype = new Employee(); |
michael@0 | 41 | |
michael@0 | 42 | function WorkerBee ( name, dept, projs ) { |
michael@0 | 43 | this.base = Employee; |
michael@0 | 44 | this.base( name, dept) |
michael@0 | 45 | this.projects = projs || new Array(); |
michael@0 | 46 | } |
michael@0 | 47 | |
michael@0 | 48 | WorkerBee.prototype = new Employee(); |
michael@0 | 49 | |
michael@0 | 50 | function SalesPerson () { |
michael@0 | 51 | this.dept = "sales"; |
michael@0 | 52 | this.quota = 100; |
michael@0 | 53 | } |
michael@0 | 54 | SalesPerson.prototype = new WorkerBee(); |
michael@0 | 55 | |
michael@0 | 56 | function Engineer ( name, projs, machine ) { |
michael@0 | 57 | this.base = WorkerBee; |
michael@0 | 58 | this.base( name, "engineering", projs ) |
michael@0 | 59 | this.machine = machine || ""; |
michael@0 | 60 | } |
michael@0 | 61 | Engineer.prototype = new WorkerBee(); |
michael@0 | 62 | |
michael@0 | 63 | var pat = new Engineer( "Toonces, Pat", |
michael@0 | 64 | ["SpiderMonkey", "Rhino"], |
michael@0 | 65 | "indy" ); |
michael@0 | 66 | |
michael@0 | 67 | var les = new WorkerBee( "Morris, Les", |
michael@0 | 68 | "Training", |
michael@0 | 69 | ["Hippo"] ) |
michael@0 | 70 | |
michael@0 | 71 | var terry = new Employee( "Boomberi, Terry", |
michael@0 | 72 | "Marketing" ); |
michael@0 | 73 | |
michael@0 | 74 | // Pat, the Engineer |
michael@0 | 75 | |
michael@0 | 76 | new TestCase( SECTION, |
michael@0 | 77 | "pat.name", |
michael@0 | 78 | "Toonces, Pat", |
michael@0 | 79 | pat.name ); |
michael@0 | 80 | |
michael@0 | 81 | new TestCase( SECTION, |
michael@0 | 82 | "pat.dept", |
michael@0 | 83 | "engineering", |
michael@0 | 84 | pat.dept ); |
michael@0 | 85 | |
michael@0 | 86 | new TestCase( SECTION, |
michael@0 | 87 | "pat.projects.length", |
michael@0 | 88 | 2, |
michael@0 | 89 | pat.projects.length ); |
michael@0 | 90 | |
michael@0 | 91 | new TestCase( SECTION, |
michael@0 | 92 | "pat.projects[0]", |
michael@0 | 93 | "SpiderMonkey", |
michael@0 | 94 | pat.projects[0] ); |
michael@0 | 95 | |
michael@0 | 96 | new TestCase( SECTION, |
michael@0 | 97 | "pat.projects[1]", |
michael@0 | 98 | "Rhino", |
michael@0 | 99 | pat.projects[1] ); |
michael@0 | 100 | |
michael@0 | 101 | new TestCase( SECTION, |
michael@0 | 102 | "pat.machine", |
michael@0 | 103 | "indy", |
michael@0 | 104 | pat.machine ); |
michael@0 | 105 | |
michael@0 | 106 | |
michael@0 | 107 | // Les, the WorkerBee |
michael@0 | 108 | |
michael@0 | 109 | new TestCase( SECTION, |
michael@0 | 110 | "les.name", |
michael@0 | 111 | "Morris, Les", |
michael@0 | 112 | les.name ); |
michael@0 | 113 | |
michael@0 | 114 | new TestCase( SECTION, |
michael@0 | 115 | "les.dept", |
michael@0 | 116 | "Training", |
michael@0 | 117 | les.dept ); |
michael@0 | 118 | |
michael@0 | 119 | new TestCase( SECTION, |
michael@0 | 120 | "les.projects.length", |
michael@0 | 121 | 1, |
michael@0 | 122 | les.projects.length ); |
michael@0 | 123 | |
michael@0 | 124 | new TestCase( SECTION, |
michael@0 | 125 | "les.projects[0]", |
michael@0 | 126 | "Hippo", |
michael@0 | 127 | les.projects[0] ); |
michael@0 | 128 | |
michael@0 | 129 | // Terry, the Employee |
michael@0 | 130 | new TestCase( SECTION, |
michael@0 | 131 | "terry.name", |
michael@0 | 132 | "Boomberi, Terry", |
michael@0 | 133 | terry.name ); |
michael@0 | 134 | |
michael@0 | 135 | new TestCase( SECTION, |
michael@0 | 136 | "terry.dept", |
michael@0 | 137 | "Marketing", |
michael@0 | 138 | terry.dept ); |
michael@0 | 139 | test(); |
michael@0 | 140 |