| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
gTestfile = 'proto_3.js'; |
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
var SECTION = "proto_3"; |
| 26 |
var VERSION = "JS1_3"; |
| 27 |
var TITLE = "Adding properties to an Instance"; |
| 28 |
|
| 29 |
startTest(); |
| 30 |
writeHeaderToLog( SECTION + " "+ TITLE); |
| 31 |
|
| 32 |
function Employee () { |
| 33 |
this.name = ""; |
| 34 |
this.dept = "general"; |
| 35 |
} |
| 36 |
function Manager () { |
| 37 |
this.reports = []; |
| 38 |
} |
| 39 |
Manager.prototype = new Employee(); |
| 40 |
|
| 41 |
function WorkerBee () { |
| 42 |
this.projects = new Array(); |
| 43 |
} |
| 44 |
|
| 45 |
WorkerBee.prototype = new Employee(); |
| 46 |
|
| 47 |
function SalesPerson () { |
| 48 |
this.dept = "sales"; |
| 49 |
this.quota = 100; |
| 50 |
} |
| 51 |
SalesPerson.prototype = new WorkerBee(); |
| 52 |
|
| 53 |
function Engineer () { |
| 54 |
this.dept = "engineering"; |
| 55 |
this.machine = ""; |
| 56 |
} |
| 57 |
Engineer.prototype = new WorkerBee(); |
| 58 |
|
| 59 |
var jim = new Employee(); |
| 60 |
var pat = new Employee(); |
| 61 |
|
| 62 |
jim.bonus = 300; |
| 63 |
|
| 64 |
new TestCase( SECTION, |
| 65 |
"jim = new Employee(); jim.bonus = 300; jim.bonus", |
| 66 |
300, |
| 67 |
jim.bonus ); |
| 68 |
|
| 69 |
|
| 70 |
new TestCase( SECTION, |
| 71 |
"pat = new Employee(); pat.bonus", |
| 72 |
void 0, |
| 73 |
pat.bonus ); |
| 74 |
test(); |