| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
gTestfile = 'proto_5.js'; |
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
var SECTION = "proto_5"; |
| 28 |
var VERSION = "JS1_3"; |
| 29 |
var TITLE = "Logical OR || in Constructors"; |
| 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 Manager () { |
| 39 |
this.reports = []; |
| 40 |
} |
| 41 |
Manager.prototype = new Employee(); |
| 42 |
|
| 43 |
function WorkerBee ( projs ) { |
| 44 |
this.projects = projs || new Array(); |
| 45 |
} |
| 46 |
WorkerBee.prototype = new Employee(); |
| 47 |
|
| 48 |
function SalesPerson () { |
| 49 |
this.dept = "sales"; |
| 50 |
this.quota = 100; |
| 51 |
} |
| 52 |
SalesPerson.prototype = new WorkerBee(); |
| 53 |
|
| 54 |
function Engineer ( machine ) { |
| 55 |
this.dept = "engineering"; |
| 56 |
this.machine = machine || ""; |
| 57 |
} |
| 58 |
Engineer.prototype = new WorkerBee(); |
| 59 |
|
| 60 |
|
| 61 |
var pat = new Engineer( "indy" ); |
| 62 |
|
| 63 |
var les = new Engineer(); |
| 64 |
|
| 65 |
new TestCase( SECTION, |
| 66 |
"var pat = new Engineer(\"indy\"); pat.name", |
| 67 |
"", |
| 68 |
pat.name ); |
| 69 |
|
| 70 |
new TestCase( SECTION, |
| 71 |
"pat.dept", |
| 72 |
"engineering", |
| 73 |
pat.dept ); |
| 74 |
|
| 75 |
new TestCase( SECTION, |
| 76 |
"pat.projects.length", |
| 77 |
0, |
| 78 |
pat.projects.length ); |
| 79 |
|
| 80 |
new TestCase( SECTION, |
| 81 |
"pat.machine", |
| 82 |
"indy", |
| 83 |
pat.machine ); |
| 84 |
|
| 85 |
new TestCase( SECTION, |
| 86 |
"pat.__proto__ == Engineer.prototype", |
| 87 |
true, |
| 88 |
pat.__proto__ == Engineer.prototype ); |
| 89 |
|
| 90 |
new TestCase( SECTION, |
| 91 |
"var les = new Engineer(); les.name", |
| 92 |
"", |
| 93 |
les.name ); |
| 94 |
|
| 95 |
new TestCase( SECTION, |
| 96 |
"les.dept", |
| 97 |
"engineering", |
| 98 |
les.dept ); |
| 99 |
|
| 100 |
new TestCase( SECTION, |
| 101 |
"les.projects.length", |
| 102 |
0, |
| 103 |
les.projects.length ); |
| 104 |
|
| 105 |
new TestCase( SECTION, |
| 106 |
"les.machine", |
| 107 |
"", |
| 108 |
les.machine ); |
| 109 |
|
| 110 |
new TestCase( SECTION, |
| 111 |
"les.__proto__ == Engineer.prototype", |
| 112 |
true, |
| 113 |
les.__proto__ == Engineer.prototype ); |
| 114 |
|
| 115 |
|
| 116 |
test(); |