| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
gTestfile = 'proto_4.js'; |
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
var SECTION = "proto_3"; |
| 31 |
var VERSION = "JS1_3"; |
| 32 |
var TITLE = "Adding properties to the prototype"; |
| 33 |
|
| 34 |
startTest(); |
| 35 |
writeHeaderToLog( SECTION + " "+ TITLE); |
| 36 |
|
| 37 |
function Employee () { |
| 38 |
this.name = ""; |
| 39 |
this.dept = "general"; |
| 40 |
} |
| 41 |
function Manager () { |
| 42 |
this.reports = []; |
| 43 |
} |
| 44 |
Manager.prototype = new Employee(); |
| 45 |
|
| 46 |
function WorkerBee () { |
| 47 |
this.projects = new Array(); |
| 48 |
} |
| 49 |
|
| 50 |
WorkerBee.prototype = new Employee(); |
| 51 |
|
| 52 |
function SalesPerson () { |
| 53 |
this.dept = "sales"; |
| 54 |
this.quota = 100; |
| 55 |
} |
| 56 |
SalesPerson.prototype = new WorkerBee(); |
| 57 |
|
| 58 |
function Engineer () { |
| 59 |
this.dept = "engineering"; |
| 60 |
this.machine = ""; |
| 61 |
} |
| 62 |
Engineer.prototype = new WorkerBee(); |
| 63 |
|
| 64 |
var jim = new Employee(); |
| 65 |
var terry = new Engineer(); |
| 66 |
var sean = new SalesPerson(); |
| 67 |
var wally = new Manager(); |
| 68 |
|
| 69 |
Employee.prototype.specialty = "none"; |
| 70 |
|
| 71 |
var pat = new Employee(); |
| 72 |
var leslie = new Engineer(); |
| 73 |
var bubbles = new SalesPerson(); |
| 74 |
var furry = new Manager(); |
| 75 |
|
| 76 |
Engineer.prototype.specialty = "code"; |
| 77 |
|
| 78 |
var chris = new Engineer(); |
| 79 |
|
| 80 |
|
| 81 |
new TestCase( SECTION, |
| 82 |
"jim = new Employee(); jim.specialty", |
| 83 |
"none", |
| 84 |
jim.specialty ); |
| 85 |
|
| 86 |
new TestCase( SECTION, |
| 87 |
"terry = new Engineer(); terry.specialty", |
| 88 |
"code", |
| 89 |
terry.specialty ); |
| 90 |
|
| 91 |
new TestCase( SECTION, |
| 92 |
"sean = new SalesPerson(); sean.specialty", |
| 93 |
"none", |
| 94 |
sean.specialty ); |
| 95 |
|
| 96 |
new TestCase( SECTION, |
| 97 |
"wally = new Manager(); wally.specialty", |
| 98 |
"none", |
| 99 |
wally.specialty ); |
| 100 |
|
| 101 |
new TestCase( SECTION, |
| 102 |
"furry = new Manager(); furry.specialty", |
| 103 |
"none", |
| 104 |
furry.specialty ); |
| 105 |
|
| 106 |
new TestCase( SECTION, |
| 107 |
"pat = new Employee(); pat.specialty", |
| 108 |
"none", |
| 109 |
pat.specialty ); |
| 110 |
|
| 111 |
new TestCase( SECTION, |
| 112 |
"leslie = new Engineer(); leslie.specialty", |
| 113 |
"code", |
| 114 |
leslie.specialty ); |
| 115 |
|
| 116 |
new TestCase( SECTION, |
| 117 |
"bubbles = new SalesPerson(); bubbles.specialty", |
| 118 |
"none", |
| 119 |
bubbles.specialty ); |
| 120 |
|
| 121 |
|
| 122 |
new TestCase( SECTION, |
| 123 |
"chris = new Employee(); chris.specialty", |
| 124 |
"code", |
| 125 |
chris.specialty ); |
| 126 |
test(); |