From 5f8de423f190bbb79a62f804151bc24824fa32d8 Mon Sep 17 00:00:00 2001 From: "Matt A. Tobin" Date: Fri, 2 Feb 2018 04:16:08 -0500 Subject: Add m-esr52 at 52.6.0 --- js/src/tests/js1_3/Boolean/boolean-001.js | 43 ++++++++ js/src/tests/js1_3/Boolean/browser.js | 0 js/src/tests/js1_3/Boolean/shell.js | 0 js/src/tests/js1_3/README | 1 + js/src/tests/js1_3/Script/browser.js | 0 js/src/tests/js1_3/Script/delete-001.js | 49 ++++++++++ js/src/tests/js1_3/Script/function-001-n.js | 45 +++++++++ js/src/tests/js1_3/Script/function-002.js | 45 +++++++++ js/src/tests/js1_3/Script/in-001.js | 35 +++++++ js/src/tests/js1_3/Script/new-001.js | 89 +++++++++++++++++ js/src/tests/js1_3/Script/shell.js | 0 js/src/tests/js1_3/Script/switch-001.js | 50 ++++++++++ js/src/tests/js1_3/browser.js | 0 js/src/tests/js1_3/extensions/browser.js | 0 js/src/tests/js1_3/extensions/proto_10.js | 122 +++++++++++++++++++++++ js/src/tests/js1_3/extensions/proto_2.js | 91 +++++++++++++++++ js/src/tests/js1_3/extensions/proto_5.js | 115 ++++++++++++++++++++++ js/src/tests/js1_3/extensions/script-001.js | 140 +++++++++++++++++++++++++++ js/src/tests/js1_3/extensions/shell.js | 0 js/src/tests/js1_3/inherit/browser.js | 0 js/src/tests/js1_3/inherit/proto_1.js | 136 ++++++++++++++++++++++++++ js/src/tests/js1_3/inherit/proto_10.js | 90 +++++++++++++++++ js/src/tests/js1_3/inherit/proto_11.js | 86 ++++++++++++++++ js/src/tests/js1_3/inherit/proto_12.js | 112 +++++++++++++++++++++ js/src/tests/js1_3/inherit/proto_3.js | 73 ++++++++++++++ js/src/tests/js1_3/inherit/proto_4.js | 125 ++++++++++++++++++++++++ js/src/tests/js1_3/inherit/proto_6.js | 140 +++++++++++++++++++++++++++ js/src/tests/js1_3/inherit/proto_7.js | 95 ++++++++++++++++++ js/src/tests/js1_3/inherit/proto_8.js | 93 ++++++++++++++++++ js/src/tests/js1_3/inherit/proto_9.js | 71 ++++++++++++++ js/src/tests/js1_3/inherit/shell.js | 0 js/src/tests/js1_3/misc/browser.js | 0 js/src/tests/js1_3/misc/shell.js | 0 js/src/tests/js1_3/regress/browser.js | 0 js/src/tests/js1_3/regress/delete-001.js | 49 ++++++++++ js/src/tests/js1_3/regress/function-001-n.js | 45 +++++++++ js/src/tests/js1_3/regress/function-002.js | 45 +++++++++ js/src/tests/js1_3/regress/in-001.js | 36 +++++++ js/src/tests/js1_3/regress/new-001.js | 89 +++++++++++++++++ js/src/tests/js1_3/regress/shell.js | 0 js/src/tests/js1_3/regress/switch-001.js | 50 ++++++++++ js/src/tests/js1_3/shell.js | 0 42 files changed, 2160 insertions(+) create mode 100644 js/src/tests/js1_3/Boolean/boolean-001.js create mode 100644 js/src/tests/js1_3/Boolean/browser.js create mode 100644 js/src/tests/js1_3/Boolean/shell.js create mode 100644 js/src/tests/js1_3/README create mode 100644 js/src/tests/js1_3/Script/browser.js create mode 100644 js/src/tests/js1_3/Script/delete-001.js create mode 100644 js/src/tests/js1_3/Script/function-001-n.js create mode 100644 js/src/tests/js1_3/Script/function-002.js create mode 100644 js/src/tests/js1_3/Script/in-001.js create mode 100644 js/src/tests/js1_3/Script/new-001.js create mode 100644 js/src/tests/js1_3/Script/shell.js create mode 100644 js/src/tests/js1_3/Script/switch-001.js create mode 100644 js/src/tests/js1_3/browser.js create mode 100644 js/src/tests/js1_3/extensions/browser.js create mode 100644 js/src/tests/js1_3/extensions/proto_10.js create mode 100644 js/src/tests/js1_3/extensions/proto_2.js create mode 100644 js/src/tests/js1_3/extensions/proto_5.js create mode 100644 js/src/tests/js1_3/extensions/script-001.js create mode 100644 js/src/tests/js1_3/extensions/shell.js create mode 100644 js/src/tests/js1_3/inherit/browser.js create mode 100644 js/src/tests/js1_3/inherit/proto_1.js create mode 100644 js/src/tests/js1_3/inherit/proto_10.js create mode 100644 js/src/tests/js1_3/inherit/proto_11.js create mode 100644 js/src/tests/js1_3/inherit/proto_12.js create mode 100644 js/src/tests/js1_3/inherit/proto_3.js create mode 100644 js/src/tests/js1_3/inherit/proto_4.js create mode 100644 js/src/tests/js1_3/inherit/proto_6.js create mode 100644 js/src/tests/js1_3/inherit/proto_7.js create mode 100644 js/src/tests/js1_3/inherit/proto_8.js create mode 100644 js/src/tests/js1_3/inherit/proto_9.js create mode 100644 js/src/tests/js1_3/inherit/shell.js create mode 100644 js/src/tests/js1_3/misc/browser.js create mode 100644 js/src/tests/js1_3/misc/shell.js create mode 100644 js/src/tests/js1_3/regress/browser.js create mode 100644 js/src/tests/js1_3/regress/delete-001.js create mode 100644 js/src/tests/js1_3/regress/function-001-n.js create mode 100644 js/src/tests/js1_3/regress/function-002.js create mode 100644 js/src/tests/js1_3/regress/in-001.js create mode 100644 js/src/tests/js1_3/regress/new-001.js create mode 100644 js/src/tests/js1_3/regress/shell.js create mode 100644 js/src/tests/js1_3/regress/switch-001.js create mode 100644 js/src/tests/js1_3/shell.js (limited to 'js/src/tests/js1_3') diff --git a/js/src/tests/js1_3/Boolean/boolean-001.js b/js/src/tests/js1_3/Boolean/boolean-001.js new file mode 100644 index 000000000..a23beb321 --- /dev/null +++ b/js/src/tests/js1_3/Boolean/boolean-001.js @@ -0,0 +1,43 @@ +/* -*- 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: boolean-001.js + * Description: + * + * In JavaScript 1.2, new Boolean(false) evaluates to false. + * + * Author: christine@netscape.com + * Date: 11 August 1998 + */ +var SECTION = "boolean-001.js"; +var VERSION = "JS_1.3"; +var TITLE = "new Boolean(false) should evaluate to false"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +BooleanTest( "new Boolean(true)", new Boolean(true), true ); +BooleanTest( "new Boolean(false)", new Boolean(false), true ); +BooleanTest( "true", true, true ); +BooleanTest( "false", false, false ); + +test(); + +function BooleanTest( string, object, expect ) { + if ( object ) { + result = true; + } else { + result = false; + } + + new TestCase( + SECTION, + string, + expect, + result ); +} + diff --git a/js/src/tests/js1_3/Boolean/browser.js b/js/src/tests/js1_3/Boolean/browser.js new file mode 100644 index 000000000..e69de29bb diff --git a/js/src/tests/js1_3/Boolean/shell.js b/js/src/tests/js1_3/Boolean/shell.js new file mode 100644 index 000000000..e69de29bb diff --git a/js/src/tests/js1_3/README b/js/src/tests/js1_3/README new file mode 100644 index 000000000..82f668486 --- /dev/null +++ b/js/src/tests/js1_3/README @@ -0,0 +1 @@ +JavaScript 1.3 diff --git a/js/src/tests/js1_3/Script/browser.js b/js/src/tests/js1_3/Script/browser.js new file mode 100644 index 000000000..e69de29bb diff --git a/js/src/tests/js1_3/Script/delete-001.js b/js/src/tests/js1_3/Script/delete-001.js new file mode 100644 index 000000000..757204ec1 --- /dev/null +++ b/js/src/tests/js1_3/Script/delete-001.js @@ -0,0 +1,49 @@ +/* -*- 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: delete-001.js + Section: regress + Description: + + Regression test for + http://scopus.mcom.com/bugsplat/show_bug.cgi?id=108736 + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "JS1_2"; +var VERSION = "JS1_2"; +var TITLE = "The variable statement"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +// delete all properties of the global object +// per ecma, this does not affect variables in the global object declared +// with var or functions + +for ( p in this ) { + delete p; +} + +var result =""; + +for ( p in this ) { + result += String( p ); +} + +// not too picky here... just want to make sure we didn't crash or something + +new TestCase( SECTION, + "delete all properties of the global object", + "PASSED", + result == "" ? "FAILED" : "PASSED" ); + + +test(); + diff --git a/js/src/tests/js1_3/Script/function-001-n.js b/js/src/tests/js1_3/Script/function-001-n.js new file mode 100644 index 000000000..7d3726d0c --- /dev/null +++ b/js/src/tests/js1_3/Script/function-001-n.js @@ -0,0 +1,45 @@ +// |reftest| skip -- obsolete test +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 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: boolean-001.js + * Description: + * + * http://scopus.mcom.com/bugsplat/show_bug.cgi?id=99232 + * + * eval("function f(){}function g(){}") at top level is an error for JS1.2 + * and above (missing ; between named function expressions), but declares f + * and g as functions below 1.2. + * + * Fails to produce error regardless of version: + * js> version(100) + * 120 + * js> eval("function f(){}function g(){}") + * js> version(120); + * 100 + * js> eval("function f(){}function g(){}") + * js> + * Author: christine@netscape.com + * Date: 11 August 1998 + */ +var SECTION = "function-001.js"; +var VERSION = "JS_1.3"; +var TITLE = "functions not separated by semicolons are errors in version 120 and higher"; +var BUGNUMBER="10278"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( + SECTION, + "eval(\"function f(){}function g(){}\")", + "error", + eval("function f(){}function g(){}") ); + +test(); + + diff --git a/js/src/tests/js1_3/Script/function-002.js b/js/src/tests/js1_3/Script/function-002.js new file mode 100644 index 000000000..144e2e4b0 --- /dev/null +++ b/js/src/tests/js1_3/Script/function-002.js @@ -0,0 +1,45 @@ +/* -*- 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: function-002.js + Section: + Description: + + http://scopus.mcom.com/bugsplat/show_bug.cgi?id=249579 + + function definitions in conditional statements should be allowed. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "function-002"; +var VERSION = "JS1_3"; +var TITLE = "Regression test for 249579"; +var BUGNUMBER="249579"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( + SECTION, + "0?function(){}:0", + 0, + 0?function(){}:0 ); + + +bar = true; +foo = bar ? function () { return true; } : function() { return false; }; + +new TestCase( + SECTION, + "bar = true; foo = bar ? function () { return true; } : function() { return false; }; foo()", + true, + foo() ); + + +test(); + diff --git a/js/src/tests/js1_3/Script/in-001.js b/js/src/tests/js1_3/Script/in-001.js new file mode 100644 index 000000000..298cf5942 --- /dev/null +++ b/js/src/tests/js1_3/Script/in-001.js @@ -0,0 +1,35 @@ +/* -*- 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: in-001.js + Section: + Description: + + http://scopus.mcom.com/bugsplat/show_bug.cgi?id=196109 + + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "in-001"; +var VERSION = "JS1_3"; +var TITLE = "Regression test for 196109"; +var BUGNUMBER="196109"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +o = {}; +o.foo = 'sil'; + +new TestCase( + SECTION, + "\"foo\" in o", + true, + "foo" in o ); + +test(); diff --git a/js/src/tests/js1_3/Script/new-001.js b/js/src/tests/js1_3/Script/new-001.js new file mode 100644 index 000000000..9e7c5c28c --- /dev/null +++ b/js/src/tests/js1_3/Script/new-001.js @@ -0,0 +1,89 @@ +/* -*- 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: new-001.js + Section: + Description: + + http://scopus.mcom.com/bugsplat/show_bug.cgi?id=76103 + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "new-001"; +var VERSION = "JS1_3"; +var TITLE = "new-001"; +var BUGNUMBER="31567"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +function Test_One (x) { + this.v = x+1; + return x*2 + } + +function Test_Two( x, y ) { + this.v = x; + return y; +} + +new TestCase( + SECTION, + "Test_One(18)", + 36, + Test_One(18) ); + +new TestCase( + SECTION, + "new Test_One(18)", + "[object Object]", + new Test_One(18) +"" ); + +new TestCase( + SECTION, + "new Test_One(18).v", + 19, + new Test_One(18).v ); + +new TestCase( + SECTION, + "Test_Two(2,7)", + 7, + Test_Two(2,7) ); + +new TestCase( + SECTION, + "new Test_Two(2,7)", + "[object Object]", + new Test_Two(2,7) +"" ); + +new TestCase( + SECTION, + "new Test_Two(2,7).v", + 2, + new Test_Two(2,7).v ); + +new TestCase( + SECTION, + "new (Function)(\"x\", \"return x+3\")(5,6)", + 8, + new (Function)("x","return x+3")(5,6) ); + +new TestCase( + SECTION, + "new new Test_Two(String, 2).v(0123)", + "83", + new new Test_Two(String, 2).v(0123) +""); + +new TestCase( + SECTION, + "new new Test_Two(String, 2).v(0123).length", + 2, + new new Test_Two(String, 2).v(0123).length ); + +test(); diff --git a/js/src/tests/js1_3/Script/shell.js b/js/src/tests/js1_3/Script/shell.js new file mode 100644 index 000000000..e69de29bb diff --git a/js/src/tests/js1_3/Script/switch-001.js b/js/src/tests/js1_3/Script/switch-001.js new file mode 100644 index 000000000..aad1505db --- /dev/null +++ b/js/src/tests/js1_3/Script/switch-001.js @@ -0,0 +1,50 @@ +/* -*- 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: switch-001.js + Section: + Description: + + http://scopus.mcom.com/bugsplat/show_bug.cgi?id=315767 + + Verify that switches do not use strict equality in + versions of JavaScript < 1.4 + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "switch-001"; +var VERSION = "JS1_3"; +var TITLE = "switch-001"; +var BUGNUMBER="315767"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +result = "fail: did not enter switch"; + +switch (true) { +case 1: + result = "fail: for backwards compatibility, version 130 use strict equality"; + break; +case true: + result = "pass"; + break; +default: + result = "fail: evaluated default statement"; +} + +new TestCase( + SECTION, + "switch / case should use strict equality in version of JS < 1.4", + "pass", + result ); + + + +test(); + diff --git a/js/src/tests/js1_3/browser.js b/js/src/tests/js1_3/browser.js new file mode 100644 index 000000000..e69de29bb diff --git a/js/src/tests/js1_3/extensions/browser.js b/js/src/tests/js1_3/extensions/browser.js new file mode 100644 index 000000000..e69de29bb diff --git a/js/src/tests/js1_3/extensions/proto_10.js b/js/src/tests/js1_3/extensions/proto_10.js new file mode 100644 index 000000000..3cfc919e1 --- /dev/null +++ b/js/src/tests/js1_3/extensions/proto_10.js @@ -0,0 +1,122 @@ +/* -*- 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 ) { + while ( object != null ) { + if ( object == constructor.prototype ) { + return true; + } + object = object.__proto__; + } + return false; +} +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, + "pat.__proto__ == Engineer.prototype", + true, + pat.__proto__ == Engineer.prototype ); + +new TestCase( SECTION, + "pat.__proto__.__proto__ == WorkerBee.prototype", + true, + pat.__proto__.__proto__ == WorkerBee.prototype ); + +new TestCase( SECTION, + "pat.__proto__.__proto__.__proto__ == Employee.prototype", + true, + pat.__proto__.__proto__.__proto__ == Employee.prototype ); + +new TestCase( SECTION, + "pat.__proto__.__proto__.__proto__.__proto__ == Object.prototype", + true, + pat.__proto__.__proto__.__proto__.__proto__ == Object.prototype ); + +new TestCase( SECTION, + "pat.__proto__.__proto__.__proto__.__proto__.__proto__ == null", + true, + pat.__proto__.__proto__.__proto__.__proto__.__proto__ == null ); + + +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/extensions/proto_2.js b/js/src/tests/js1_3/extensions/proto_2.js new file mode 100644 index 000000000..7a0446f1e --- /dev/null +++ b/js/src/tests/js1_3/extensions/proto_2.js @@ -0,0 +1,91 @@ +/* -*- 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_2.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_2"; +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 employee = new Employee(); +var manager = new Manager(); +var workerbee = new WorkerBee(); +var salesperson = new SalesPerson(); +var engineer = new Engineer(); + +new TestCase( SECTION, + "employee.__proto__ == Employee.prototype", + true, + employee.__proto__ == Employee.prototype ); + +new TestCase( SECTION, + "manager.__proto__ == Manager.prototype", + true, + manager.__proto__ == Manager.prototype ); + +new TestCase( SECTION, + "workerbee.__proto__ == WorkerBee.prototype", + true, + workerbee.__proto__ == WorkerBee.prototype ); + +new TestCase( SECTION, + "salesperson.__proto__ == SalesPerson.prototype", + true, + salesperson.__proto__ == SalesPerson.prototype ); + +new TestCase( SECTION, + "engineer.__proto__ == Engineer.prototype", + true, + engineer.__proto__ == Engineer.prototype ); + +test(); + diff --git a/js/src/tests/js1_3/extensions/proto_5.js b/js/src/tests/js1_3/extensions/proto_5.js new file mode 100644 index 000000000..3255c9e2a --- /dev/null +++ b/js/src/tests/js1_3/extensions/proto_5.js @@ -0,0 +1,115 @@ +/* -*- 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_5.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_5"; +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 ( projs ) { + this.projects = projs || new Array(); +} +WorkerBee.prototype = new Employee(); + +function SalesPerson () { + this.dept = "sales"; + this.quota = 100; +} +SalesPerson.prototype = new WorkerBee(); + +function Engineer ( machine ) { + this.dept = "engineering"; + this.machine = machine || ""; +} +Engineer.prototype = new WorkerBee(); + + +var pat = new Engineer( "indy" ); + +var les = new Engineer(); + +new TestCase( SECTION, + "var pat = new Engineer(\"indy\"); pat.name", + "", + pat.name ); + +new TestCase( SECTION, + "pat.dept", + "engineering", + pat.dept ); + +new TestCase( SECTION, + "pat.projects.length", + 0, + pat.projects.length ); + +new TestCase( SECTION, + "pat.machine", + "indy", + pat.machine ); + +new TestCase( SECTION, + "pat.__proto__ == Engineer.prototype", + true, + pat.__proto__ == Engineer.prototype ); + +new TestCase( SECTION, + "var les = new Engineer(); les.name", + "", + les.name ); + +new TestCase( SECTION, + "les.dept", + "engineering", + les.dept ); + +new TestCase( SECTION, + "les.projects.length", + 0, + les.projects.length ); + +new TestCase( SECTION, + "les.machine", + "", + les.machine ); + +new TestCase( SECTION, + "les.__proto__ == Engineer.prototype", + true, + les.__proto__ == Engineer.prototype ); + + +test(); diff --git a/js/src/tests/js1_3/extensions/script-001.js b/js/src/tests/js1_3/extensions/script-001.js new file mode 100644 index 000000000..0ff83c8cd --- /dev/null +++ b/js/src/tests/js1_3/extensions/script-001.js @@ -0,0 +1,140 @@ +/* -*- 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: script-001.js + Section: + Description: new NativeScript object + + + js> parseInt(123,"hi") + 123 + js> parseInt(123, "blah") + 123 + js> s + js: s is not defined + js> s = new Script + + undefined; + + + js> s = new Script() + + undefined; + + + js> s.getJSClass + js> s.getJSClass = Object.prototype.toString + function toString() { + [native code] + } + + js> s.getJSClass() + [object Script] + js> s.compile( "return 3+4" ) + js: JavaScript exception: javax.javascript.EvaluatorException: " s.compile( "3+4" ) + + 3 + 4; + + + js> typeof s + function + js> s() + Jit failure! + invalid opcode: 1 + Jit Pass1 Failure! + javax/javascript/gen/c13 initScript (Ljavax/javascript/Scriptable;)V + An internal JIT error has occurred. Please report this with .class + jit-bugs@itools.symantec.com + + 7 + js> s.compile("3+4") + + 3 + 4; + + + js> s() + Jit failure! + invalid opcode: 1 + Jit Pass1 Failure! + javax/javascript/gen/c17 initScript (Ljavax/javascript/Scriptable;)V + An internal JIT error has occurred. Please report this with .class + jit-bugs@itools.symantec.com + + 7 + js> quit() + + C:\src\ns_priv\js\tests\ecma>shell + + C:\src\ns_priv\js\tests\ecma>java -classpath c:\cafe\java\JavaScope; + :\src\ns_priv\js\tests javax.javascript.examples.Shell + Symantec Java! JustInTime Compiler Version 210.054 for JDK 1.1.2 + Copyright (C) 1996-97 Symantec Corporation + + js> s = new Script("3+4") + + 3 + 4; + + + js> s() + 7 + js> s2 = new Script(); + + undefined; + + + js> s.compile( "3+4") + + 3 + 4; + + + js> s() + Jit failure! + invalid opcode: 1 + Jit Pass1 Failure! + javax/javascript/gen/c7 initScript (Ljavax/javascript/Scriptable;)V + An internal JIT error has occurred. Please report this with .class + jit-bugs@itools.symantec.com + + 7 + js> quit() + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "script-001"; +var VERSION = "JS1_3"; +var TITLE = "NativeScript"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +if (typeof Script == 'undefined') +{ + print('Test skipped. Script not defined.'); + new TestCase( SECTION, + "var s = new Script(); typeof s", + "Script not supported, test skipped.", + "Script not supported, test skipped." ); +} +else +{ + var s = new Script(); + s.getJSClass = Object.prototype.toString; + + new TestCase( SECTION, + "var s = new Script(); typeof s", + "function", + typeof s ); + + new TestCase( SECTION, + "s.getJSClass()", + "[object Script]", + s.getJSClass() ); +} + +test(); diff --git a/js/src/tests/js1_3/extensions/shell.js b/js/src/tests/js1_3/extensions/shell.js new file mode 100644 index 000000000..e69de29bb 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 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 diff --git a/js/src/tests/js1_3/misc/browser.js b/js/src/tests/js1_3/misc/browser.js new file mode 100644 index 000000000..e69de29bb diff --git a/js/src/tests/js1_3/misc/shell.js b/js/src/tests/js1_3/misc/shell.js new file mode 100644 index 000000000..e69de29bb diff --git a/js/src/tests/js1_3/regress/browser.js b/js/src/tests/js1_3/regress/browser.js new file mode 100644 index 000000000..e69de29bb diff --git a/js/src/tests/js1_3/regress/delete-001.js b/js/src/tests/js1_3/regress/delete-001.js new file mode 100644 index 000000000..757204ec1 --- /dev/null +++ b/js/src/tests/js1_3/regress/delete-001.js @@ -0,0 +1,49 @@ +/* -*- 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: delete-001.js + Section: regress + Description: + + Regression test for + http://scopus.mcom.com/bugsplat/show_bug.cgi?id=108736 + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + +var SECTION = "JS1_2"; +var VERSION = "JS1_2"; +var TITLE = "The variable statement"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +// delete all properties of the global object +// per ecma, this does not affect variables in the global object declared +// with var or functions + +for ( p in this ) { + delete p; +} + +var result =""; + +for ( p in this ) { + result += String( p ); +} + +// not too picky here... just want to make sure we didn't crash or something + +new TestCase( SECTION, + "delete all properties of the global object", + "PASSED", + result == "" ? "FAILED" : "PASSED" ); + + +test(); + diff --git a/js/src/tests/js1_3/regress/function-001-n.js b/js/src/tests/js1_3/regress/function-001-n.js new file mode 100644 index 000000000..7d3726d0c --- /dev/null +++ b/js/src/tests/js1_3/regress/function-001-n.js @@ -0,0 +1,45 @@ +// |reftest| skip -- obsolete test +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 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: boolean-001.js + * Description: + * + * http://scopus.mcom.com/bugsplat/show_bug.cgi?id=99232 + * + * eval("function f(){}function g(){}") at top level is an error for JS1.2 + * and above (missing ; between named function expressions), but declares f + * and g as functions below 1.2. + * + * Fails to produce error regardless of version: + * js> version(100) + * 120 + * js> eval("function f(){}function g(){}") + * js> version(120); + * 100 + * js> eval("function f(){}function g(){}") + * js> + * Author: christine@netscape.com + * Date: 11 August 1998 + */ +var SECTION = "function-001.js"; +var VERSION = "JS_1.3"; +var TITLE = "functions not separated by semicolons are errors in version 120 and higher"; +var BUGNUMBER="10278"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( + SECTION, + "eval(\"function f(){}function g(){}\")", + "error", + eval("function f(){}function g(){}") ); + +test(); + + diff --git a/js/src/tests/js1_3/regress/function-002.js b/js/src/tests/js1_3/regress/function-002.js new file mode 100644 index 000000000..144e2e4b0 --- /dev/null +++ b/js/src/tests/js1_3/regress/function-002.js @@ -0,0 +1,45 @@ +/* -*- 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: function-002.js + Section: + Description: + + http://scopus.mcom.com/bugsplat/show_bug.cgi?id=249579 + + function definitions in conditional statements should be allowed. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "function-002"; +var VERSION = "JS1_3"; +var TITLE = "Regression test for 249579"; +var BUGNUMBER="249579"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +new TestCase( + SECTION, + "0?function(){}:0", + 0, + 0?function(){}:0 ); + + +bar = true; +foo = bar ? function () { return true; } : function() { return false; }; + +new TestCase( + SECTION, + "bar = true; foo = bar ? function () { return true; } : function() { return false; }; foo()", + true, + foo() ); + + +test(); + diff --git a/js/src/tests/js1_3/regress/in-001.js b/js/src/tests/js1_3/regress/in-001.js new file mode 100644 index 000000000..99f57ae26 --- /dev/null +++ b/js/src/tests/js1_3/regress/in-001.js @@ -0,0 +1,36 @@ +/* -*- 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: in-001.js + Section: + Description: + + http://scopus.mcom.com/bugsplat/show_bug.cgi?id=196109 + + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "in-001"; +var VERSION = "JS1_3"; +var TITLE = "Regression test for 196109"; +var BUGNUMBER="196109"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +o = {}; +o.foo = 'sil'; + +new TestCase( + SECTION, + "\"foo\" in o", + true, + "foo" in o ); + +test(); + diff --git a/js/src/tests/js1_3/regress/new-001.js b/js/src/tests/js1_3/regress/new-001.js new file mode 100644 index 000000000..9e7c5c28c --- /dev/null +++ b/js/src/tests/js1_3/regress/new-001.js @@ -0,0 +1,89 @@ +/* -*- 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: new-001.js + Section: + Description: + + http://scopus.mcom.com/bugsplat/show_bug.cgi?id=76103 + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "new-001"; +var VERSION = "JS1_3"; +var TITLE = "new-001"; +var BUGNUMBER="31567"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +function Test_One (x) { + this.v = x+1; + return x*2 + } + +function Test_Two( x, y ) { + this.v = x; + return y; +} + +new TestCase( + SECTION, + "Test_One(18)", + 36, + Test_One(18) ); + +new TestCase( + SECTION, + "new Test_One(18)", + "[object Object]", + new Test_One(18) +"" ); + +new TestCase( + SECTION, + "new Test_One(18).v", + 19, + new Test_One(18).v ); + +new TestCase( + SECTION, + "Test_Two(2,7)", + 7, + Test_Two(2,7) ); + +new TestCase( + SECTION, + "new Test_Two(2,7)", + "[object Object]", + new Test_Two(2,7) +"" ); + +new TestCase( + SECTION, + "new Test_Two(2,7).v", + 2, + new Test_Two(2,7).v ); + +new TestCase( + SECTION, + "new (Function)(\"x\", \"return x+3\")(5,6)", + 8, + new (Function)("x","return x+3")(5,6) ); + +new TestCase( + SECTION, + "new new Test_Two(String, 2).v(0123)", + "83", + new new Test_Two(String, 2).v(0123) +""); + +new TestCase( + SECTION, + "new new Test_Two(String, 2).v(0123).length", + 2, + new new Test_Two(String, 2).v(0123).length ); + +test(); diff --git a/js/src/tests/js1_3/regress/shell.js b/js/src/tests/js1_3/regress/shell.js new file mode 100644 index 000000000..e69de29bb diff --git a/js/src/tests/js1_3/regress/switch-001.js b/js/src/tests/js1_3/regress/switch-001.js new file mode 100644 index 000000000..ffd0623e5 --- /dev/null +++ b/js/src/tests/js1_3/regress/switch-001.js @@ -0,0 +1,50 @@ +/* -*- 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: switch-001.js + Section: + Description: + + http://scopus.mcom.com/bugsplat/show_bug.cgi?id=315767 + + Verify that switches do not use strict equality in + versions of JavaScript < 1.4. It's now been decided that + we won't put in version switches, so all switches will + be ECMA. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ +var SECTION = "switch-001"; +var VERSION = "JS1_3"; +var TITLE = "switch-001"; +var BUGNUMBER="315767"; + +startTest(); +writeHeaderToLog( SECTION + " "+ TITLE); + +result = "fail: did not enter switch"; + +switch (true) { +case 1: + result = "fail: version 130 should force strict equality"; + break; +case true: + result = "pass"; + break; +default: + result = "fail: evaluated default statement"; +} + +new TestCase( + SECTION, + "switch / case should use strict equality in version of JS < 1.4", + "pass", + result ); + +test(); + diff --git a/js/src/tests/js1_3/shell.js b/js/src/tests/js1_3/shell.js new file mode 100644 index 000000000..e69de29bb -- cgit v1.2.3