| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
gTestfile = 'proto_2.js'; |
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
var SECTION = "proto_2"; |
| 26 |
var VERSION = "JS1_3"; |
| 27 |
var TITLE = "new PrototypeObject"; |
| 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 |
|
| 60 |
var employee = new Employee(); |
| 61 |
var manager = new Manager(); |
| 62 |
var workerbee = new WorkerBee(); |
| 63 |
var salesperson = new SalesPerson(); |
| 64 |
var engineer = new Engineer(); |
| 65 |
|
| 66 |
new TestCase( SECTION, |
| 67 |
"employee.__proto__ == Employee.prototype", |
| 68 |
true, |
| 69 |
employee.__proto__ == Employee.prototype ); |
| 70 |
|
| 71 |
new TestCase( SECTION, |
| 72 |
"manager.__proto__ == Manager.prototype", |
| 73 |
true, |
| 74 |
manager.__proto__ == Manager.prototype ); |
| 75 |
|
| 76 |
new TestCase( SECTION, |
| 77 |
"workerbee.__proto__ == WorkerBee.prototype", |
| 78 |
true, |
| 79 |
workerbee.__proto__ == WorkerBee.prototype ); |
| 80 |
|
| 81 |
new TestCase( SECTION, |
| 82 |
"salesperson.__proto__ == SalesPerson.prototype", |
| 83 |
true, |
| 84 |
salesperson.__proto__ == SalesPerson.prototype ); |
| 85 |
|
| 86 |
new TestCase( SECTION, |
| 87 |
"engineer.__proto__ == Engineer.prototype", |
| 88 |
true, |
| 89 |
engineer.__proto__ == Engineer.prototype ); |
| 90 |
|
| 91 |
test(); |
| 92 |
|