diff options
Diffstat (limited to 'js/src/tests/js1_3/inherit')
-rw-r--r-- | js/src/tests/js1_3/inherit/browser.js | 0 | ||||
-rw-r--r-- | js/src/tests/js1_3/inherit/proto_1.js | 136 | ||||
-rw-r--r-- | js/src/tests/js1_3/inherit/proto_10.js | 90 | ||||
-rw-r--r-- | js/src/tests/js1_3/inherit/proto_11.js | 86 | ||||
-rw-r--r-- | js/src/tests/js1_3/inherit/proto_12.js | 112 | ||||
-rw-r--r-- | js/src/tests/js1_3/inherit/proto_3.js | 73 | ||||
-rw-r--r-- | js/src/tests/js1_3/inherit/proto_4.js | 125 | ||||
-rw-r--r-- | js/src/tests/js1_3/inherit/proto_6.js | 140 | ||||
-rw-r--r-- | js/src/tests/js1_3/inherit/proto_7.js | 95 | ||||
-rw-r--r-- | js/src/tests/js1_3/inherit/proto_8.js | 93 | ||||
-rw-r--r-- | js/src/tests/js1_3/inherit/proto_9.js | 71 | ||||
-rw-r--r-- | js/src/tests/js1_3/inherit/shell.js | 0 |
12 files changed, 1021 insertions, 0 deletions
diff --git a/js/src/tests/js1_3/inherit/browser.js b/js/src/tests/js1_3/inherit/browser.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/src/tests/js1_3/inherit/browser.js diff --git a/js/src/tests/js1_3/inherit/proto_1.js b/js/src/tests/js1_3/inherit/proto_1.js new file mode 100644 index 000000000..79911f342 --- /dev/null +++ b/js/src/tests/js1_3/inherit/proto_1.js @@ -0,0 +1,136 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: proto_1.js + Section: + Description: new PrototypeObject + + This tests Object Hierarchy and Inheritance, as described in the document + Object Hierarchy and Inheritance in JavaScript, last modified on 12/18/97 + 15:19:34 on http://devedge.netscape.com/. Current URL: + http://devedge.netscape.com/docs/manuals/communicator/jsobj/contents.htm + + This tests the syntax ObjectName.prototype = new PrototypeObject using the + Employee example in the document referenced above. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "proto_1"; +var VERSION = "JS1_3"; +var TITLE = "new PrototypeObject"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +function Employee () { + this.name = ""; + this.dept = "general"; +} +function Manager () { + this.reports = []; +} +Manager.prototype = new Employee(); + +function WorkerBee () { + this.projects = new Array(); +} +WorkerBee.prototype = new Employee(); + +function SalesPerson () { + this.dept = "sales"; + this.quota = 100; +} +SalesPerson.prototype = new WorkerBee(); + +function Engineer () { + this.dept = "engineering"; + this.machine = ""; +} +Engineer.prototype = new WorkerBee(); + +var jim = new Employee(); + +new TestCase( SECTION, + "jim = new Employee(); jim.name", + "", + jim.name ); + + +new TestCase( SECTION, + "jim = new Employee(); jim.dept", + "general", + jim.dept ); + +var sally = new Manager(); + +new TestCase( SECTION, + "sally = new Manager(); sally.name", + "", + sally.name ); +new TestCase( SECTION, + "sally = new Manager(); sally.dept", + "general", + sally.dept ); + +new TestCase( SECTION, + "sally = new Manager(); sally.reports.length", + 0, + sally.reports.length ); + +new TestCase( SECTION, + "sally = new Manager(); typeof sally.reports", + "object", + typeof sally.reports ); + +var fred = new SalesPerson(); + +new TestCase( SECTION, + "fred = new SalesPerson(); fred.name", + "", + fred.name ); + +new TestCase( SECTION, + "fred = new SalesPerson(); fred.dept", + "sales", + fred.dept ); + +new TestCase( SECTION, + "fred = new SalesPerson(); fred.quota", + 100, + fred.quota ); + +new TestCase( SECTION, + "fred = new SalesPerson(); fred.projects.length", + 0, + fred.projects.length ); + +var jane = new Engineer(); + +new TestCase( SECTION, + "jane = new Engineer(); jane.name", + "", + jane.name ); + +new TestCase( SECTION, + "jane = new Engineer(); jane.dept", + "engineering", + jane.dept ); + +new TestCase( SECTION, + "jane = new Engineer(); jane.projects.length", + 0, + jane.projects.length ); + +new TestCase( SECTION, + "jane = new Engineer(); jane.machine", + "", + jane.machine ); + + +test(); diff --git a/js/src/tests/js1_3/inherit/proto_10.js b/js/src/tests/js1_3/inherit/proto_10.js new file mode 100644 index 000000000..4a671f9c8 --- /dev/null +++ b/js/src/tests/js1_3/inherit/proto_10.js @@ -0,0 +1,90 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: proto_10.js + Section: + Description: Determining Instance Relationships + + This tests Object Hierarchy and Inheritance, as described in the document + Object Hierarchy and Inheritance in JavaScript, last modified on 12/18/97 + 15:19:34 on http://devedge.netscape.com/. Current URL: + http://devedge.netscape.com/docs/manuals/communicator/jsobj/contents.htm + + This tests the syntax ObjectName.prototype = new PrototypeObject using the + Employee example in the document referenced above. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "proto_10"; +var VERSION = "JS1_3"; +var TITLE = "Determining Instance Relationships"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +function InstanceOf( object, constructor ) { + return object instanceof constructor; +} +function Employee ( name, dept ) { + this.name = name || ""; + this.dept = dept || "general"; +} + +function Manager () { + this.reports = []; +} +Manager.prototype = new Employee(); + +function WorkerBee ( name, dept, projs ) { + this.base = Employee; + this.base( name, dept) + this.projects = projs || new Array(); +} +WorkerBee.prototype = new Employee(); + +function SalesPerson () { + this.dept = "sales"; + this.quota = 100; +} +SalesPerson.prototype = new WorkerBee(); + +function Engineer ( name, projs, machine ) { + this.base = WorkerBee; + this.base( name, "engineering", projs ) + this.machine = machine || ""; +} +Engineer.prototype = new WorkerBee(); + +var pat = new Engineer(); + +new TestCase( SECTION, + "InstanceOf( pat, Engineer )", + true, + InstanceOf( pat, Engineer ) ); + +new TestCase( SECTION, + "InstanceOf( pat, WorkerBee )", + true, + InstanceOf( pat, WorkerBee ) ); + +new TestCase( SECTION, + "InstanceOf( pat, Employee )", + true, + InstanceOf( pat, Employee ) ); + +new TestCase( SECTION, + "InstanceOf( pat, Object )", + true, + InstanceOf( pat, Object ) ); + +new TestCase( SECTION, + "InstanceOf( pat, SalesPerson )", + false, + InstanceOf ( pat, SalesPerson ) ); +test(); diff --git a/js/src/tests/js1_3/inherit/proto_11.js b/js/src/tests/js1_3/inherit/proto_11.js new file mode 100644 index 000000000..02ea4b474 --- /dev/null +++ b/js/src/tests/js1_3/inherit/proto_11.js @@ -0,0 +1,86 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: proto_11.js + Section: + Description: Global Information in Constructors + + This tests Object Hierarchy and Inheritance, as described in the document + Object Hierarchy and Inheritance in JavaScript, last modified on 12/18/97 + 15:19:34 on http://devedge.netscape.com/. Current URL: + http://devedge.netscape.com/docs/manuals/communicator/jsobj/contents.htm + + This tests the syntax ObjectName.prototype = new PrototypeObject using the + Employee example in the document referenced above. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "proto_11"; +var VERSION = "JS1_3"; +var TITLE = "Global Information in Constructors"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +var idCounter = 1; + + +function Employee ( name, dept ) { + this.name = name || ""; + this.dept = dept || "general"; + this.id = idCounter++; +} +function Manager () { + this.reports = []; +} +Manager.prototype = new Employee(); + +function WorkerBee ( name, dept, projs ) { + this.base = Employee; + this.base( name, dept) + this.projects = projs || new Array(); +} +WorkerBee.prototype = new Employee(); + +function SalesPerson () { + this.dept = "sales"; + this.quota = 100; +} +SalesPerson.prototype = new WorkerBee(); + +function Engineer ( name, projs, machine ) { + this.base = WorkerBee; + this.base( name, "engineering", projs ) + this.machine = machine || ""; +} +Engineer.prototype = new WorkerBee(); + +var pat = new Employee( "Toonces, Pat", "Tech Pubs" ) + var terry = new Employee( "O'Sherry Terry", "Marketing" ); + +var les = new Engineer( "Morris, Les", new Array("JavaScript"), "indy" ); + +new TestCase( SECTION, + "pat.id", + 5, + pat.id ); + +new TestCase( SECTION, + "terry.id", + 6, + terry.id ); + +new TestCase( SECTION, + "les.id", + 7, + les.id ); + + +test(); + diff --git a/js/src/tests/js1_3/inherit/proto_12.js b/js/src/tests/js1_3/inherit/proto_12.js new file mode 100644 index 000000000..c223bb3fa --- /dev/null +++ b/js/src/tests/js1_3/inherit/proto_12.js @@ -0,0 +1,112 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: proto_12.js + Section: + Description: new PrototypeObject + + This tests Object Hierarchy and Inheritance, as described in the document + Object Hierarchy and Inheritance in JavaScript, last modified on 12/18/97 + 15:19:34 on http://devedge.netscape.com/. Current URL: + http://devedge.netscape.com/docs/manuals/communicator/jsobj/contents.htm + + No Multiple Inheritance + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "proto_12"; +var VERSION = "JS1_3"; +var TITLE = "No Multiple Inheritance"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +function Employee ( name, dept ) { + this.name = name || ""; + this.dept = dept || "general"; + this.id = idCounter++; +} +function Manager () { + this.reports = []; +} +Manager.prototype = new Employee(); + +function WorkerBee ( name, dept, projs ) { + this.base = Employee; + this.base( name, dept) + this.projects = projs || new Array(); +} +WorkerBee.prototype = new Employee(); + +function SalesPerson () { + this.dept = "sales"; + this.quota = 100; +} +SalesPerson.prototype = new WorkerBee(); + +function Hobbyist( hobby ) { + this.hobby = hobby || "yodeling"; +} + +function Engineer ( name, projs, machine, hobby ) { + this.base1 = WorkerBee; + this.base1( name, "engineering", projs ) + + this.base2 = Hobbyist; + this.base2( hobby ); + + this.projects = projs || new Array(); + this.machine = machine || ""; +} +Engineer.prototype = new WorkerBee(); + +var idCounter = 1; + +var les = new Engineer( "Morris, Les", new Array("JavaScript"), "indy" ); + +Hobbyist.prototype.equipment = [ "horn", "mountain", "goat" ]; + +new TestCase( SECTION, + "les.name", + "Morris, Les", + les.name ); + +new TestCase( SECTION, + "les.dept", + "engineering", + les.dept ); + +Array.prototype.getClass = Object.prototype.toString; + +new TestCase( SECTION, + "les.projects.getClass()", + "[object Array]", + les.projects.getClass() ); + +new TestCase( SECTION, + "les.projects[0]", + "JavaScript", + les.projects[0] ); + +new TestCase( SECTION, + "les.machine", + "indy", + les.machine ); + +new TestCase( SECTION, + "les.hobby", + "yodeling", + les.hobby ); + +new TestCase( SECTION, + "les.equpment", + void 0, + les.equipment ); + +test(); diff --git a/js/src/tests/js1_3/inherit/proto_3.js b/js/src/tests/js1_3/inherit/proto_3.js new file mode 100644 index 000000000..0e9183bfb --- /dev/null +++ b/js/src/tests/js1_3/inherit/proto_3.js @@ -0,0 +1,73 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: proto_3.js + Section: + Description: Adding properties to an instance + + This tests Object Hierarchy and Inheritance, as described in the document + Object Hierarchy and Inheritance in JavaScript, last modified on 12/18/97 + 15:19:34 on http://devedge.netscape.com/. Current URL: + http://devedge.netscape.com/docs/manuals/communicator/jsobj/contents.htm + + This tests the syntax ObjectName.prototype = new PrototypeObject using the + Employee example in the document referenced above. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "proto_3"; +var VERSION = "JS1_3"; +var TITLE = "Adding properties to an Instance"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +function Employee () { + this.name = ""; + this.dept = "general"; +} +function Manager () { + this.reports = []; +} +Manager.prototype = new Employee(); + +function WorkerBee () { + this.projects = new Array(); +} + +WorkerBee.prototype = new Employee(); + +function SalesPerson () { + this.dept = "sales"; + this.quota = 100; +} +SalesPerson.prototype = new WorkerBee(); + +function Engineer () { + this.dept = "engineering"; + this.machine = ""; +} +Engineer.prototype = new WorkerBee(); + +var jim = new Employee(); +var pat = new Employee(); + +jim.bonus = 300; + +new TestCase( SECTION, + "jim = new Employee(); jim.bonus = 300; jim.bonus", + 300, + jim.bonus ); + + +new TestCase( SECTION, + "pat = new Employee(); pat.bonus", + void 0, + pat.bonus ); +test(); diff --git a/js/src/tests/js1_3/inherit/proto_4.js b/js/src/tests/js1_3/inherit/proto_4.js new file mode 100644 index 000000000..9fe1fe0bb --- /dev/null +++ b/js/src/tests/js1_3/inherit/proto_4.js @@ -0,0 +1,125 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: proto_4.js + Section: + Description: new PrototypeObject + + This tests Object Hierarchy and Inheritance, as described in the document + Object Hierarchy and Inheritance in JavaScript, last modified on 12/18/97 + 15:19:34 on http://devedge.netscape.com/. Current URL: + http://devedge.netscape.com/docs/manuals/communicator/jsobj/contents.htm + + This tests the syntax ObjectName.prototype = new PrototypeObject using the + Employee example in the document referenced above. + + If you add a property to an object in the prototype chain, instances of + objects that derive from that prototype should inherit that property, even + if they were instatiated after the property was added to the prototype object. + + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "proto_3"; +var VERSION = "JS1_3"; +var TITLE = "Adding properties to the prototype"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +function Employee () { + this.name = ""; + this.dept = "general"; +} +function Manager () { + this.reports = []; +} +Manager.prototype = new Employee(); + +function WorkerBee () { + this.projects = new Array(); +} + +WorkerBee.prototype = new Employee(); + +function SalesPerson () { + this.dept = "sales"; + this.quota = 100; +} +SalesPerson.prototype = new WorkerBee(); + +function Engineer () { + this.dept = "engineering"; + this.machine = ""; +} +Engineer.prototype = new WorkerBee(); + +var jim = new Employee(); +var terry = new Engineer(); +var sean = new SalesPerson(); +var wally = new Manager(); + +Employee.prototype.specialty = "none"; + +var pat = new Employee(); +var leslie = new Engineer(); +var bubbles = new SalesPerson(); +var furry = new Manager(); + +Engineer.prototype.specialty = "code"; + +var chris = new Engineer(); + + +new TestCase( SECTION, + "jim = new Employee(); jim.specialty", + "none", + jim.specialty ); + +new TestCase( SECTION, + "terry = new Engineer(); terry.specialty", + "code", + terry.specialty ); + +new TestCase( SECTION, + "sean = new SalesPerson(); sean.specialty", + "none", + sean.specialty ); + +new TestCase( SECTION, + "wally = new Manager(); wally.specialty", + "none", + wally.specialty ); + +new TestCase( SECTION, + "furry = new Manager(); furry.specialty", + "none", + furry.specialty ); + +new TestCase( SECTION, + "pat = new Employee(); pat.specialty", + "none", + pat.specialty ); + +new TestCase( SECTION, + "leslie = new Engineer(); leslie.specialty", + "code", + leslie.specialty ); + +new TestCase( SECTION, + "bubbles = new SalesPerson(); bubbles.specialty", + "none", + bubbles.specialty ); + + +new TestCase( SECTION, + "chris = new Employee(); chris.specialty", + "code", + chris.specialty ); +test(); diff --git a/js/src/tests/js1_3/inherit/proto_6.js b/js/src/tests/js1_3/inherit/proto_6.js new file mode 100644 index 000000000..3ffc0b43e --- /dev/null +++ b/js/src/tests/js1_3/inherit/proto_6.js @@ -0,0 +1,140 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: proto_6.js + Section: + Description: Logical OR || in constructors + + This tests Object Hierarchy and Inheritance, as described in the document + Object Hierarchy and Inheritance in JavaScript, last modified on 12/18/97 + 15:19:34 on http://devedge.netscape.com/. Current URL: + http://devedge.netscape.com/docs/manuals/communicator/jsobj/contents.htm + + This tests the syntax ObjectName.prototype = new PrototypeObject using the + Employee example in the document referenced above. + + This tests the logical OR opererator || syntax in constructors. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "proto_6"; +var VERSION = "JS1_3"; +var TITLE = "Logical OR || in constructors"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +function Employee ( name, dept ) { + this.name = name || ""; + this.dept = dept || "general"; +} +function Manager () { + this.reports = []; +} +Manager.prototype = new Employee(); + +function WorkerBee ( name, dept, projs ) { + this.base = Employee; + this.base( name, dept) + this.projects = projs || new Array(); +} + +WorkerBee.prototype = new Employee(); + +function SalesPerson () { + this.dept = "sales"; + this.quota = 100; +} +SalesPerson.prototype = new WorkerBee(); + +function Engineer ( name, projs, machine ) { + this.base = WorkerBee; + this.base( name, "engineering", projs ) + this.machine = machine || ""; +} +Engineer.prototype = new WorkerBee(); + +var pat = new Engineer( "Toonces, Pat", + ["SpiderMonkey", "Rhino"], + "indy" ); + +var les = new WorkerBee( "Morris, Les", + "Training", + ["Hippo"] ) + + var terry = new Employee( "Boomberi, Terry", + "Marketing" ); + +// Pat, the Engineer + +new TestCase( SECTION, + "pat.name", + "Toonces, Pat", + pat.name ); + +new TestCase( SECTION, + "pat.dept", + "engineering", + pat.dept ); + +new TestCase( SECTION, + "pat.projects.length", + 2, + pat.projects.length ); + +new TestCase( SECTION, + "pat.projects[0]", + "SpiderMonkey", + pat.projects[0] ); + +new TestCase( SECTION, + "pat.projects[1]", + "Rhino", + pat.projects[1] ); + +new TestCase( SECTION, + "pat.machine", + "indy", + pat.machine ); + + +// Les, the WorkerBee + +new TestCase( SECTION, + "les.name", + "Morris, Les", + les.name ); + +new TestCase( SECTION, + "les.dept", + "Training", + les.dept ); + +new TestCase( SECTION, + "les.projects.length", + 1, + les.projects.length ); + +new TestCase( SECTION, + "les.projects[0]", + "Hippo", + les.projects[0] ); + +// Terry, the Employee +new TestCase( SECTION, + "terry.name", + "Boomberi, Terry", + terry.name ); + +new TestCase( SECTION, + "terry.dept", + "Marketing", + terry.dept ); +test(); + diff --git a/js/src/tests/js1_3/inherit/proto_7.js b/js/src/tests/js1_3/inherit/proto_7.js new file mode 100644 index 000000000..fa52daa56 --- /dev/null +++ b/js/src/tests/js1_3/inherit/proto_7.js @@ -0,0 +1,95 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: proto_7.js + Section: + Description: Adding Properties to the Prototype Object + + This tests Object Hierarchy and Inheritance, as described in the document + Object Hierarchy and Inheritance in JavaScript, last modified on 12/18/97 + 15:19:34 on http://devedge.netscape.com/. Current URL: + http://devedge.netscape.com/docs/manuals/communicator/jsobj/contents.htm + + This tests the syntax ObjectName.prototype = new PrototypeObject using the + Employee example in the document referenced above. + + This tests + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "proto_6"; +var VERSION = "JS1_3"; +var TITLE = "Adding properties to the Prototype Object"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +function Employee ( name, dept ) { + this.name = name || ""; + this.dept = dept || "general"; +} +function WorkerBee ( name, dept, projs ) { + this.base = Employee; + this.base( name, dept) + this.projects = projs || new Array(); +} +WorkerBee.prototype = new Employee(); + +function Engineer ( name, projs, machine ) { + this.base = WorkerBee; + this.base( name, "engineering", projs ) + this.machine = machine || ""; +} +// Engineer.prototype = new WorkerBee(); + +var pat = new Engineer( "Toonces, Pat", + ["SpiderMonkey", "Rhino"], + "indy" ); + +Employee.prototype.specialty = "none"; + + +// Pat, the Engineer + +new TestCase( SECTION, + "pat.name", + "Toonces, Pat", + pat.name ); + +new TestCase( SECTION, + "pat.dept", + "engineering", + pat.dept ); + +new TestCase( SECTION, + "pat.projects.length", + 2, + pat.projects.length ); + +new TestCase( SECTION, + "pat.projects[0]", + "SpiderMonkey", + pat.projects[0] ); + +new TestCase( SECTION, + "pat.projects[1]", + "Rhino", + pat.projects[1] ); + +new TestCase( SECTION, + "pat.machine", + "indy", + pat.machine ); + +new TestCase( SECTION, + "pat.specialty", + void 0, + pat.specialty ); + +test(); diff --git a/js/src/tests/js1_3/inherit/proto_8.js b/js/src/tests/js1_3/inherit/proto_8.js new file mode 100644 index 000000000..98e6a4738 --- /dev/null +++ b/js/src/tests/js1_3/inherit/proto_8.js @@ -0,0 +1,93 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: proto_8.js + Section: + Description: Adding Properties to the Prototype Object + + This tests Object Hierarchy and Inheritance, as described in the document + Object Hierarchy and Inheritance in JavaScript, last modified on 12/18/97 + 15:19:34 on http://devedge.netscape.com/. Current URL: + http://devedge.netscape.com/docs/manuals/communicator/jsobj/contents.htm + + This tests the syntax ObjectName.prototype = new PrototypeObject using the + Employee example in the document referenced above. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "proto_8"; +var VERSION = "JS1_3"; +var TITLE = "Adding Properties to the Prototype Object"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +function Employee ( name, dept ) { + this.name = name || ""; + this.dept = dept || "general"; +} +function WorkerBee ( name, dept, projs ) { + this.base = Employee; + this.base( name, dept) + this.projects = projs || new Array(); +} +WorkerBee.prototype = new Employee(); + +function Engineer ( name, projs, machine ) { + this.base = WorkerBee; + this.base( name, "engineering", projs ) + this.machine = machine || ""; +} +Engineer.prototype = new WorkerBee(); + +var pat = new Engineer( "Toonces, Pat", + ["SpiderMonkey", "Rhino"], + "indy" ); + +Employee.prototype.specialty = "none"; + + +// Pat, the Engineer + +new TestCase( SECTION, + "pat.name", + "Toonces, Pat", + pat.name ); + +new TestCase( SECTION, + "pat.dept", + "engineering", + pat.dept ); + +new TestCase( SECTION, + "pat.projects.length", + 2, + pat.projects.length ); + +new TestCase( SECTION, + "pat.projects[0]", + "SpiderMonkey", + pat.projects[0] ); + +new TestCase( SECTION, + "pat.projects[1]", + "Rhino", + pat.projects[1] ); + +new TestCase( SECTION, + "pat.machine", + "indy", + pat.machine ); + +new TestCase( SECTION, + "pat.specialty", + "none", + pat.specialty ); + +test(); diff --git a/js/src/tests/js1_3/inherit/proto_9.js b/js/src/tests/js1_3/inherit/proto_9.js new file mode 100644 index 000000000..d789afc67 --- /dev/null +++ b/js/src/tests/js1_3/inherit/proto_9.js @@ -0,0 +1,71 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +/** + File Name: proto_9.js + Section: + Description: Local versus Inherited Values + + This tests Object Hierarchy and Inheritance, as described in the document + Object Hierarchy and Inheritance in JavaScript, last modified on 12/18/97 + 15:19:34 on http://devedge.netscape.com/. Current URL: + http://devedge.netscape.com/docs/manuals/communicator/jsobj/contents.htm + + This tests the syntax ObjectName.prototype = new PrototypeObject using the + Employee example in the document referenced above. + + This tests + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "proto_9"; +var VERSION = "JS1_3"; +var TITLE = "Local versus Inherited Values"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +function Employee ( name, dept ) { + this.name = name || ""; + this.dept = dept || "general"; +} +function WorkerBee ( name, dept, projs ) { + this.projects = new Array(); +} +WorkerBee.prototype = new Employee(); + +var pat = new WorkerBee() + + Employee.prototype.specialty = "none"; +Employee.prototype.name = "Unknown"; + +Array.prototype.getClass = Object.prototype.toString; + +// Pat, the WorkerBee + +new TestCase( SECTION, + "pat.name", + "", + pat.name ); + +new TestCase( SECTION, + "pat.dept", + "general", + pat.dept ); + +new TestCase( SECTION, + "pat.projects.getClass", + "[object Array]", + pat.projects.getClass() ); + +new TestCase( SECTION, + "pat.projects.length", + 0, + pat.projects.length ); + +test(); diff --git a/js/src/tests/js1_3/inherit/shell.js b/js/src/tests/js1_3/inherit/shell.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/src/tests/js1_3/inherit/shell.js |