diff options
author | Steve Block <steveblock@google.com> | 2011-05-13 06:44:40 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-05-13 06:44:40 -0700 |
commit | 08014c20784f3db5df3a89b73cce46037b77eb59 (patch) | |
tree | 47749210d31e19e6e2f64036fa8fae2ad693476f /Source/JavaScriptCore/tests/mozilla/ecma_2 | |
parent | 860220379e56aeb66424861ad602b07ee22b4055 (diff) | |
parent | 4c3661f7918f8b3f139f824efb7855bedccb4c94 (diff) | |
download | external_webkit-08014c20784f3db5df3a89b73cce46037b77eb59.zip external_webkit-08014c20784f3db5df3a89b73cce46037b77eb59.tar.gz external_webkit-08014c20784f3db5df3a89b73cce46037b77eb59.tar.bz2 |
Merge changes Ide388898,Ic49f367c,I1158a808,Iacb6ca5d,I2100dd3a,I5c1abe54,Ib0ef9902,I31dbc523,I570314b3
* changes:
Merge WebKit at r75315: Update WebKit version
Merge WebKit at r75315: Add FrameLoaderClient PageCache stubs
Merge WebKit at r75315: Stub out AXObjectCache::remove()
Merge WebKit at r75315: Fix ImageBuffer
Merge WebKit at r75315: Fix PluginData::initPlugins()
Merge WebKit at r75315: Fix conflicts
Merge WebKit at r75315: Fix Makefiles
Merge WebKit at r75315: Move Android-specific WebCore files to Source
Merge WebKit at r75315: Initial merge by git.
Diffstat (limited to 'Source/JavaScriptCore/tests/mozilla/ecma_2')
174 files changed, 11509 insertions, 0 deletions
diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/boolean-001.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/boolean-001.js new file mode 100644 index 0000000..1645ad4 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/boolean-001.js @@ -0,0 +1,43 @@ +/** + File Name: boolean-001.js + Description: Corresponds to ecma/Boolean/15.6.4.2-4-n.js + + The toString function is not generic; it generates + a runtime error if its this value is not a Boolean + object. Therefore it cannot be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: june 27, 1997 +*/ + var SECTION = "boolean-001.js"; + var VERSION = "JS1_4"; + var TITLE = "Boolean.prototype.toString()"; + startTest(); + writeHeaderToLog( SECTION +" "+ TITLE ); + + var tc = 0; + var testcases = new Array(); + + var exception = "No exception thrown"; + var result = "Failed"; + + var TO_STRING = Boolean.prototype.toString; + + try { + var s = new String("Not a Boolean"); + s.toString = TO_STRING; + s.toString(); + } catch ( e ) { + result = "Passed!"; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "Assigning Boolean.prototype.toString to a String object "+ + "(threw " +exception +")", + "Passed!", + result ); + + test(); diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/boolean-002.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/boolean-002.js new file mode 100644 index 0000000..be31b99 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/boolean-002.js @@ -0,0 +1,47 @@ +/** + File Name: boolean-001.js + Description: Corresponds to ecma/Boolean/15.6.4.3-4-n.js + + 15.6.4.3 Boolean.prototype.valueOf() + Returns this boolean value. + + The valueOf function is not generic; it generates + a runtime error if its this value is not a Boolean + object. Therefore it cannot be transferred to other + kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 09 september 1998 +*/ + var SECTION = "boolean-002.js"; + var VERSION = "JS1_4"; + var TITLE = "Boolean.prototype.valueOf()"; + startTest(); + writeHeaderToLog( SECTION +" "+ TITLE ); + + var tc = 0; + var testcases = new Array(); + + var exception = "No exception thrown"; + var result = "Failed"; + + var VALUE_OF = Boolean.prototype.valueOf; + + try { + var s = new String("Not a Boolean"); + s.valueOf = VALUE_0F; + s.valueOf(); + } catch ( e ) { + result = "Passed!"; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "Assigning Boolean.prototype.valueOf to a String object "+ + "(threw " +exception +")", + "Passed!", + result ); + + test(); + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/date-001.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/date-001.js new file mode 100644 index 0000000..60ef3a4 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/date-001.js @@ -0,0 +1,57 @@ +/** + File Name: date-001.js + Corresponds To: 15.9.5.2-2.js + ECMA Section: 15.9.5.2 Date.prototype.toString + Description: + This function returns a string value. The contents of the string are + implementation dependent, but are intended to represent the Date in a + convenient, human-readable form in the current time zone. + + The toString function is not generic; it generates a runtime error if its + this value is not a Date object. Therefore it cannot be transferred to + other kinds of objects for use as a method. + + + This verifies that calling toString on an object that is not a string + generates a runtime error. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "date-001"; + var VERSION = "JS1_4"; + var TITLE = "Date.prototype.toString"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + var OBJ = new MyObject( new Date(0) ); + result = OBJ.toString(); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "OBJECT = new MyObject( new Date(0)) ; result = OBJ.toString()" + + " (threw " + exception +")", + expect, + result ); + + test(); + +function MyObject( value ) { + this.value = value; + this.valueOf = new Function( "return this.value" ); + this.toString = Date.prototype.toString; + return this; +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/date-002.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/date-002.js new file mode 100644 index 0000000..6fd5a64 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/date-002.js @@ -0,0 +1,51 @@ +/** + File Name: date-002.js + Corresponds To: 15.9.5.23-3-n.js + ECMA Section: 15.9.5.23 + Description: Date.prototype.setTime + + 1. If the this value is not a Date object, generate a runtime error. + 2. Call ToNumber(time). + 3. Call TimeClip(Result(1)). + 4. Set the [[Value]] property of the this value to Result(2). + 5. Return the value of the [[Value]] property of the this value. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "date-002"; + var VERSION = "JS1_4"; + var TITLE = "Date.prototype.setTime()"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + var MYDATE = new MyDate(); + result = MYDATE.setTime(0); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "MYDATE = new MyDate(); MYDATE.setTime(0)" + + " (threw " + exception +")", + expect, + result ); + + test(); + +function MyDate(value) { + this.value = value; + this.setTime = Date.prototype.setTime; + return this; +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/date-003.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/date-003.js new file mode 100644 index 0000000..b675fdd --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/date-003.js @@ -0,0 +1,53 @@ +/** + File Name: date-003.js + Corresponds To 15.9.5.3-1.js + ECMA Section: 15.9.5.3-1 Date.prototype.valueOf + Description: + + The valueOf function returns a number, which is this time value. + + The valueOf function is not generic; it generates a runtime error if + its this value is not a Date object. Therefore it cannot be transferred + to other kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "date-003"; + var VERSION = "JS1_4"; + var TITLE = "Date.prototype.valueOf"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + var OBJ = new MyObject( new Date(0) ); + result = OBJ.valueOf(); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "OBJ = new MyObject( new Date(0)); OBJ.valueOf()" + + " (threw " + exception +")", + expect, + result ); + + test(); + +function MyObject( value ) { + this.value = value; + this.valueOf = Date.prototype.valueOf; +// The following line causes an infinte loop +// this.toString = new Function( "return this+\"\";"); + return this; +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/date-004.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/date-004.js new file mode 100644 index 0000000..fc2e419 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/date-004.js @@ -0,0 +1,47 @@ +/** + File Name: date-004.js + Corresponds To: 15.9.5.4-2-n.js + ECMA Section: 15.9.5.4-1 Date.prototype.getTime + Description: + + 1. If the this value is not an object whose [[Class]] property is "Date", + generate a runtime error. + 2. Return this time value. + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "date-004"; + var VERSION = "JS1_4"; + var TITLE = "Date.prototype.getTime"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + var MYDATE = new MyDate(); + result = MYDATE.getTime(); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "MYDATE = new MyDate(); MYDATE.getTime()" + + " (threw " + exception +")", + expect, + result ); + + test(); + +function MyDate( value ) { + this.value = value; + this.getTime = Date.prototype.getTime; +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/exception-001.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/exception-001.js new file mode 100644 index 0000000..eeeaa86 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/exception-001.js @@ -0,0 +1,42 @@ +/** + * File Name: exception-001 + * ECMA Section: + * Description: Tests for JavaScript Standard Exceptions + * + * Call error. + * + * Author: christine@netscape.com + * Date: 31 August 1998 + */ + var SECTION = "exception-001"; + var VERSION = "js1_4"; + var TITLE = "Tests for JavaScript Standard Exceptions: CallError"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + Call_1(); + + test(); + + function Call_1() { + result = "failed: no exception thrown"; + exception = null; + + try { + Math(); + } catch ( e ) { + result = "passed: threw exception", + exception = e.toString(); + } finally { + testcases[tc++] = new TestCase( + SECTION, + "Math() [ exception is " + exception +" ]", + "passed: threw exception", + result ); + } + } + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/exception-002.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/exception-002.js new file mode 100644 index 0000000..680fcbf --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/exception-002.js @@ -0,0 +1,42 @@ +/** + * File Name: exception-002 + * ECMA Section: + * Description: Tests for JavaScript Standard Exceptions + * + * Construct error. + * + * Author: christine@netscape.com + * Date: 31 August 1998 + */ + var SECTION = "exception-002"; + var VERSION = "js1_4"; + var TITLE = "Tests for JavaScript Standard Exceptions: ConstructError"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + Construct_1(); + + test(); + + function Construct_1() { + result = "failed: no exception thrown"; + exception = null; + + try { + result = new Math(); + } catch ( e ) { + result = "passed: threw exception", + exception = e.toString(); + } finally { + testcases[tc++] = new TestCase( + SECTION, + "new Math() [ exception is " + exception +" ]", + "passed: threw exception", + result ); + } + } + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/exception-003.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/exception-003.js new file mode 100644 index 0000000..d073fbc --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/exception-003.js @@ -0,0 +1,46 @@ +/** + * File Name: exception-003 + * ECMA Section: + * Description: Tests for JavaScript Standard Exceptions + * + * Target error. + * + * Author: christine@netscape.com + * Date: 31 August 1998 + */ + var SECTION = "exception-003"; + var VERSION = "js1_4"; + var TITLE = "Tests for JavaScript Standard Exceptions: TargetError"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + Target_1(); + + test(); + + function Target_1() { + result = "failed: no exception thrown"; + exception = null; + + try { + string = new String("hi"); + string.toString = Boolean.prototype.toString; + string.toString(); + } catch ( e ) { + result = "passed: threw exception", + exception = e.toString(); + } finally { + testcases[tc++] = new TestCase( + SECTION, + "string = new String(\"hi\");"+ + "string.toString = Boolean.prototype.toString" + + "string.toString() [ exception is " + exception +" ]", + "passed: threw exception", + result ); + } + } + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/exception-004.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/exception-004.js new file mode 100644 index 0000000..1fde959 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/exception-004.js @@ -0,0 +1,42 @@ +/** + * File Name: exception-004 + * ECMA Section: + * Description: Tests for JavaScript Standard Exceptions + * + * ToObject error. + * + * Author: christine@netscape.com + * Date: 31 August 1998 + */ + var SECTION = "exception-004"; + var VERSION = "js1_4"; + var TITLE = "Tests for JavaScript Standard Exceptions: ToObjectError"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + ToObject_1(); + + test(); + + function ToObject_1() { + result = "failed: no exception thrown"; + exception = null; + + try { + result = foo["bar"]; + } catch ( e ) { + result = "passed: threw exception", + exception = e.toString(); + } finally { + testcases[tc++] = new TestCase( + SECTION, + "foo[\"bar\"] [ exception is " + exception +" ]", + "passed: threw exception", + result ); + } + } + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/exception-005.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/exception-005.js new file mode 100644 index 0000000..2fbb984 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/exception-005.js @@ -0,0 +1,42 @@ +/** + * File Name: exception-005 + * ECMA Section: + * Description: Tests for JavaScript Standard Exceptions + * + * ToObject error. + * + * Author: christine@netscape.com + * Date: 31 August 1998 + */ + var SECTION = "exception-005"; + var VERSION = "js1_4"; + var TITLE = "Tests for JavaScript Standard Exceptions: ToObjectError"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + ToObject_1(); + + test(); + + function ToObject_1() { + result = "failed: no exception thrown"; + exception = null; + + try { + result = foo["bar"]; + } catch ( e ) { + result = "passed: threw exception", + exception = e.toString(); + } finally { + testcases[tc++] = new TestCase( + SECTION, + "foo[\"bar\"] [ exception is " + exception +" ]", + "passed: threw exception", + result ); + } + } + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/exception-006.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/exception-006.js new file mode 100644 index 0000000..583e976 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/exception-006.js @@ -0,0 +1,53 @@ +/** + * File Name: exception-006 + * ECMA Section: + * Description: Tests for JavaScript Standard Exceptions + * + * ToPrimitive error. + * + * Author: christine@netscape.com + * Date: 31 August 1998 + */ + var SECTION = "exception-006"; + var VERSION = "js1_4"; + var TITLE = "Tests for JavaScript Standard Exceptions: TypeError"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + ToPrimitive_1(); + + test(); + + + /** + * Getting the [[DefaultValue]] of any instances of MyObject + * should result in a runtime error in ToPrimitive. + */ + + function MyObject() { + this.toString = void 0; + this.valueOf = void 0; + } + + function ToPrimitive_1() { + result = "failed: no exception thrown"; + exception = null; + + try { + result = new MyObject() + new MyObject(); + } catch ( e ) { + result = "passed: threw exception", + exception = e.toString(); + } finally { + testcases[tc++] = new TestCase( + SECTION, + "new MyObject() + new MyObject() [ exception is " + exception +" ]", + "passed: threw exception", + result ); + } + } + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/exception-007.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/exception-007.js new file mode 100644 index 0000000..e26a40e --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/exception-007.js @@ -0,0 +1,54 @@ +/** + * File Name: exception-007 + * ECMA Section: + * Description: Tests for JavaScript Standard Exceptions + * + * DefaultValue error. + * + * Author: christine@netscape.com + * Date: 31 August 1998 + */ + var SECTION = "exception-007"; + var VERSION = "js1_4"; + var TITLE = "Tests for JavaScript Standard Exceptions: TypeError"; + var BUGNUMBER="318250"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + DefaultValue_1(); + + test(); + + + /** + * Getting the [[DefaultValue]] of any instances of MyObject + * should result in a runtime error in ToPrimitive. + */ + + function MyObject() { + this.toString = void 0; + this.valueOf = new Object(); + } + + function DefaultValue_1() { + result = "failed: no exception thrown"; + exception = null; + + try { + result = new MyObject() + new MyObject(); + } catch ( e ) { + result = "passed: threw exception", + exception = e.toString(); + } finally { + testcases[tc++] = new TestCase( + SECTION, + "new MyObject() + new MyObject() [ exception is " + exception +" ]", + "passed: threw exception", + result ); + } + } + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/exception-008.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/exception-008.js new file mode 100644 index 0000000..797f125 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/exception-008.js @@ -0,0 +1,41 @@ +/** + * File Name: exception-008 + * ECMA Section: + * Description: Tests for JavaScript Standard Exceptions + * + * SyntaxError. + * + * Author: christine@netscape.com + * Date: 31 August 1998 + */ + var SECTION = "exception-008"; + var VERSION = "js1_4"; + var TITLE = "Tests for JavaScript Standard Exceptions: SyntaxError"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + Syntax_1(); + + test(); + + function Syntax_1() { + result = "failed: no exception thrown"; + exception = null; + + try { + result = eval("continue;"); + } catch ( e ) { + result = "passed: threw exception", + exception = e.toString(); + } finally { + testcases[tc++] = new TestCase( + SECTION, + "eval(\"continue\") [ exception is " + exception +" ]", + "passed: threw exception", + result ); + } + } diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/exception-009.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/exception-009.js new file mode 100644 index 0000000..b153532 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/exception-009.js @@ -0,0 +1,50 @@ +/** + * File Name: exception-009 + * ECMA Section: + * Description: Tests for JavaScript Standard Exceptions + * + * Regression test for nested try blocks. + * + * http://scopus.mcom.com/bugsplat/show_bug.cgi?id=312964 + * + * Author: christine@netscape.com + * Date: 31 August 1998 + */ + var SECTION = "exception-009"; + var VERSION = "JS1_4"; + var TITLE = "Tests for JavaScript Standard Exceptions: SyntaxError"; + var BUGNUMBER= "312964"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + try { + expect = "passed: no exception thrown"; + result = expect; + Nested_1(); + } catch ( e ) { + result = "failed: threw " + e; + } finally { + testcases[tc++] = new TestCase( + SECTION, + "nested try", + expect, + result ); + } + + + test(); + + function Nested_1() { + try { + try { + } catch (a) { + } finally { + } + } catch (b) { + } finally { + } + } diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/exception-010-n.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/exception-010-n.js new file mode 100644 index 0000000..3b4ec82 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/exception-010-n.js @@ -0,0 +1,36 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * Rob Ginda rginda@netscape.com + */ + +test(); + +function test() +{ + print ("Null throw test."); + print ("BUGNUMBER: 21799"); + + throw null; + + print ("FAILED!: Should have exited with uncaught exception."); + +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/exception-011-n.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/exception-011-n.js new file mode 100644 index 0000000..9088420 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/exception-011-n.js @@ -0,0 +1,35 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * Rob Ginda rginda@netscape.com + */ + +test(); + +function test() +{ + print ("Undefined throw test."); + + throw (void 0); + + print ("FAILED!: Should have exited with uncaught exception."); + +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/expression-001.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/expression-001.js new file mode 100644 index 0000000..b1baf6f --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/expression-001.js @@ -0,0 +1,47 @@ +/** + File Name: expression-001.js + Corresponds to: ecma/Expressions/11.12-2-n.js + ECMA Section: 11.12 + Description: + + The grammar for a ConditionalExpression in ECMAScript is a little bit + different from that in C and Java, which each allow the second + subexpression to be an Expression but restrict the third expression to + be a ConditionalExpression. The motivation for this difference in + ECMAScript is to allow an assignment expression to be governed by either + arm of a conditional and to eliminate the confusing and fairly useless + case of a comma expression as the center expression. + + Author: christine@netscape.com + Date: 09 september 1998 +*/ + var SECTION = "expression-001"; + var VERSION = "JS1_4"; + var TITLE = "Conditional operator ( ? : )" + startTest(); + writeHeaderToLog( SECTION + " " + TITLE ); + + var tc = 0; + var testcases = new Array(); + + // the following expression should be an error in JS. + + var result = "Failed" + var exception = "No exception was thrown"; + + try { + eval("var MY_VAR = true ? \"EXPR1\", \"EXPR2\" : \"EXPR3\""); + } catch ( e ) { + result = "Passed"; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "comma expression in a conditional statement "+ + "(threw "+ exception +")", + "Passed", + result ); + + + test(); diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/expression-002.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/expression-002.js new file mode 100644 index 0000000..1a73ebe --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/expression-002.js @@ -0,0 +1,57 @@ +/** + File Name: expressions-002.js + Corresponds to: ecma/Expressions/11.2.1-3-n.js + ECMA Section: 11.2.1 Property Accessors + Description: + + Try to access properties of an object whose value is undefined. + + Author: christine@netscape.com + Date: 09 september 1998 +*/ + var SECTION = "expressions-002.js"; + var VERSION = "JS1_4"; + var TITLE = "Property Accessors"; + writeHeaderToLog( SECTION + " "+TITLE ); + + startTest(); + + var tc = 0; + var testcases = new Array(); + + // go through all Native Function objects, methods, and properties and get their typeof. + + var PROPERTY = new Array(); + var p = 0; + + // try to access properties of primitive types + + OBJECT = new Property( "undefined", void 0, "undefined", NaN ); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + result = OBJECT.value.valueOf(); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + + testcases[tc++] = new TestCase( + SECTION, + "Get the value of an object whose value is undefined "+ + "(threw " + exception +")", + expect, + result ); + + test(); + +function Property( object, value, string, number ) { + this.object = object; + this.string = String(value); + this.number = Number(value); + this.valueOf = value; +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/expression-003.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/expression-003.js new file mode 100644 index 0000000..30b5369 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/expression-003.js @@ -0,0 +1,52 @@ +/** + File Name: expressions-003.js + Corresponds to: ecma/Expressions/11.2.1-3-n.js + ECMA Section: 11.2.1 Property Accessors + Description: + + Try to access properties of an object whose value is undefined. + + Author: christine@netscape.com + Date: 09 september 1998 +*/ + var SECTION = "expressions-003.js"; + var VERSION = "JS1_4"; + var TITLE = "Property Accessors"; + writeHeaderToLog( SECTION + " "+TITLE ); + + startTest(); + + var tc = 0; + var testcases = new Array(); + + // try to access properties of primitive types + + OBJECT = new Property( "undefined", void 0, "undefined", NaN ); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + result = OBJECT.value.toString(); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + + testcases[tc++] = new TestCase( + SECTION, + "Get the toString value of an object whose value is undefined "+ + "(threw " + exception +")", + expect, + result ); + + test(); + +function Property( object, value, string, number ) { + this.object = object; + this.string = String(value); + this.number = Number(value); + this.value = value; +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/expression-004.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/expression-004.js new file mode 100644 index 0000000..0ce3864 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/expression-004.js @@ -0,0 +1,46 @@ +/** + File Name: expression-004.js + Corresponds To: 11.2.1-4-n.js + ECMA Section: 11.2.1 Property Accessors + Description: + + Author: christine@netscape.com + Date: 09 september 1998 +*/ + var SECTION = "expression-004"; + var VERSION = "JS1_4"; + var TITLE = "Property Accessors"; + writeHeaderToLog( SECTION + " "+TITLE ); + startTest(); + + var tc = 0; + var testcases = new Array(); + + var OBJECT = new Property( "null", null, "null", 0 ); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + result = OBJECT.value.toString(); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "Get the toString value of an object whose value is null "+ + "(threw " + exception +")", + expect, + result ); + + test(); + +function Property( object, value, string, number ) { + this.object = object; + this.string = String(value); + this.number = Number(value); + this.value = value; +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/expression-005.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/expression-005.js new file mode 100644 index 0000000..df69144 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/expression-005.js @@ -0,0 +1,38 @@ +/** + File Name: expression-005.js + Corresponds To: 11.2.2-10-n.js + ECMA Section: 11.2.2. The new operator + Description: + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + + var SECTION = "expression-005"; + var VERSION = "JS1_4"; + var TITLE = "The new operator"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var expect = "Passed"; + var exception = "No exception thrown"; + + try { + result = new Math(); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "result= new Math() (threw " + exception + ")", + expect, + result ); + + test(); diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/expression-006.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/expression-006.js new file mode 100644 index 0000000..1bf0798 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/expression-006.js @@ -0,0 +1,43 @@ +/** + File Name: expression-006.js + Corresponds to: 11.2.2-1-n.js + ECMA Section: 11.2.2. The new operator + Description: + + http://scopus/bugsplat/show_bug.cgi?id=327765 + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "expression-006.js"; + var VERSION = "JS1_4"; + var TITLE = "The new operator"; + var BUGNUMBER="327765"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + var OBJECT = new Object(); + result = new OBJECT(); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "OBJECT = new Object; result = new OBJECT()" + + " (threw " + exception +")", + expect, + result ); + + test(); + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/expression-007.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/expression-007.js new file mode 100644 index 0000000..988109b --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/expression-007.js @@ -0,0 +1,41 @@ +/** + File Name: expression-007.js + Corresponds To: 11.2.2-2-n.js + ECMA Section: 11.2.2. The new operator + Description: + + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "expression-007"; + var VERSION = "JS1_4"; + var TITLE = "The new operator"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + UNDEFINED = void 0; + result = new UNDEFINED(); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "UNDEFINED = void 0; result = new UNDEFINED()" + + " (threw " + exception +")", + expect, + result ); + + test(); + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/expression-008.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/expression-008.js new file mode 100644 index 0000000..caa8912 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/expression-008.js @@ -0,0 +1,38 @@ +/** + File Name: expression-008 + Corresponds To: 11.2.2-3-n.js + ECMA Section: 11.2.2. The new operator + Description: + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "expression-008"; + var VERSION = "JS1_4"; + var TITLE = "The new operator"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var NULL = null; + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + result = new NULL(); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "NULL = null; result = new NULL()" + + " (threw " + exception +")", + expect, + result ); + + test(); diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/expression-009.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/expression-009.js new file mode 100644 index 0000000..2aa63b6 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/expression-009.js @@ -0,0 +1,39 @@ +/** + File Name: expression-009 + Corresponds to: ecma/Expressions/11.2.2-4-n.js + ECMA Section: 11.2.2. The new operator + Description: + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "expression-009"; + var VERSION = "JS1_4"; + var TITLE = "The new operator"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var STRING = ""; + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + result = new STRING(); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "STRING = ''; result = new STRING()" + + " (threw " + exception +")", + expect, + result ); + + test();
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/expression-010.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/expression-010.js new file mode 100644 index 0000000..bb21aba --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/expression-010.js @@ -0,0 +1,40 @@ +/** + File Name: expression-010.js + Corresponds To: 11.2.2-5-n.js + ECMA Section: 11.2.2. The new operator + Description: + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "expression-010"; + var VERSION = "JS1_4"; + var TITLE = "The new operator"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var NUMBER = 0; + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + result = new NUMBER(); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "NUMBER=0, result = new NUMBER()" + + " (threw " + exception +")", + expect, + result ); + + test(); + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/expression-011.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/expression-011.js new file mode 100644 index 0000000..71c601a --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/expression-011.js @@ -0,0 +1,40 @@ +/** + File Name: expression-011.js + Corresponds To: ecma/Expressions/11.2.2-6-n.js + ECMA Section: 11.2.2. The new operator + Description: + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "expression-011"; + var VERSION = "JS1_4"; + var TITLE = "The new operator"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var BOOLEAN = true; + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + var OBJECT = new BOOLEAN(); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "BOOLEAN = true; result = new BOOLEAN()" + + " (threw " + exception +")", + expect, + result ); + + test(); + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/expression-012.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/expression-012.js new file mode 100644 index 0000000..31eb099 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/expression-012.js @@ -0,0 +1,41 @@ +/** + File Name: expression-012.js + Corresponds To: ecma/Expressions/11.2.2-6-n.js + ECMA Section: 11.2.2. The new operator + Description: + http://scopus/bugsplat/show_bug.cgi?id=327765 + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "expression-012"; + var VERSION = "JS1_4"; + var TITLE = "The new operator"; + var BUGNUMBER= "327765"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var STRING = new String("hi"); + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + result = new STRING(); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "STRING = new String(\"hi\"); result = new STRING()" + + " (threw " + exception +")", + expect, + result ); + + test(); + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/expression-013.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/expression-013.js new file mode 100644 index 0000000..cc75a77 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/expression-013.js @@ -0,0 +1,41 @@ +/** + File Name: expression-013.js + Corresponds To: ecma/Expressions/11.2.2-8-n.js + ECMA Section: 11.2.2. The new operator + Description: + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "expression-013"; + var VERSION = "JS1_4"; + var TITLE = "The new operator"; + var BUGNUMBER= "327765"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var NUMBER = new Number(1); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + result = new NUMBER(); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "NUMBER = new Number(1); result = new NUMBER()" + + " (threw " + exception +")", + expect, + result ); + + test(); + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/expression-014.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/expression-014.js new file mode 100644 index 0000000..4a09cd1 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/expression-014.js @@ -0,0 +1,43 @@ +/** + File Name: expression-014.js + Corresponds To: ecma/Expressions/11.2.2-9-n.js + ECMA Section: 11.2.2. The new operator + Description: + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "expression-014.js"; + var VERSION = "ECMA_1"; + var TITLE = "The new operator"; + var BUGNUMBER= "327765"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var BOOLEAN = new Boolean(); + + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + result = new BOOLEAN(); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "BOOLEAN = new Boolean(); result = new BOOLEAN()" + + " (threw " + exception +")", + expect, + result ); + + test(); + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/expression-015.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/expression-015.js new file mode 100644 index 0000000..09577fc --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/expression-015.js @@ -0,0 +1,37 @@ +/** + File Name: expression-015.js + Corresponds To: ecma/Expressions/11.2.3-2-n.js + ECMA Section: 11.2.3. Function Calls + Description: + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "expression-015"; + var VERSION = "JS1_4"; + var TITLE = "Function Calls"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("result = 3.valueOf();"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "3.valueOf()" + + " (threw " + exception +")", + expect, + result ); + + test(); diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/expression-016.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/expression-016.js new file mode 100644 index 0000000..4a55110 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/expression-016.js @@ -0,0 +1,37 @@ +/** + File Name: expression-016.js + Corresponds To: ecma/Expressions/11.2.3-3-n.js + ECMA Section: 11.2.3. Function Calls + Description: + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "expression-016"; + var VERSION = "JS1_4"; + var TITLE = "Function Calls"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + result = (void 0).valueOf(); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "(void 0).valueOf()" + + " (threw " + exception +")", + expect, + result ); + + test(); diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/expression-017.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/expression-017.js new file mode 100644 index 0000000..949cf3f --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/expression-017.js @@ -0,0 +1,37 @@ +/** + File Name: expression-07.js + Corresponds To: ecma/Expressions/11.2.3-4-n.js + ECMA Section: 11.2.3. Function Calls + Description: + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "expression-017"; + var VERSION = "JS1_4"; + var TITLE = "Function Calls"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + result = nullvalueOf(); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "null.valueOf()" + + " (threw " + exception +")", + expect, + result ); + + test(); diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/expression-019.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/expression-019.js new file mode 100644 index 0000000..0ef02cb --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/expression-019.js @@ -0,0 +1,41 @@ +/** + File Name: expression-019.js + Corresponds To: 11.2.2-7-n.js + ECMA Section: 11.2.2. The new operator + Description: + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "expression-019"; + var VERSION = "JS1_4"; + var TITLE = "The new operator"; + var BUGNUMBER= "327765"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + var STRING = new String("hi"); + result = new STRING(); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "var STRING = new String(\"hi\"); result = new STRING();" + + " (threw " + exception + ")", + expect, + result ); + + test(); + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/function-001.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/function-001.js new file mode 100644 index 0000000..3cbd19e --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/function-001.js @@ -0,0 +1,64 @@ +/** + * 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_12"; + var TITLE = "functions not separated by semicolons are errors in version 120 and higher"; + var BUGNUMBER="10278"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "fail"; + var exception = "no exception thrown"; + + try { + eval("function f(){}function g(){}"); + } catch ( e ) { + result = "pass" + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "eval(\"function f(){}function g(){}\") (threw "+exception, + "pass", + result ); + + test(); + + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/global-001.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/global-001.js new file mode 100644 index 0000000..3b1bd98 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/global-001.js @@ -0,0 +1,43 @@ +/** + File Name: global-001 + Corresponds To: ecma/GlobalObject/15.1-1-n.js + ECMA Section: The global object + Description: + + The global object does not have a [[Construct]] property; it is not + possible to use the global object as a constructor with the new operator. + + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "global-001"; + var VERSION = "ECMA_1"; + var TITLE = "The Global Object"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + result = new this(); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "result = new this()" + + " (threw " + exception +")", + expect, + result ); + + test(); diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/global-002.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/global-002.js new file mode 100644 index 0000000..2453c29 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/global-002.js @@ -0,0 +1,43 @@ +/** + File Name: global-002 + Corresponds To: ecma/GlobalObject/15.1-2-n.js + ECMA Section: The global object + Description: + + The global object does not have a [[Construct]] property; it is not + possible to use the global object as a constructor with the new operator. + + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "global-002"; + var VERSION = "JS1_4"; + var TITLE = "The Global Object"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + result = this(); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "result = this()" + + " (threw " + exception +")", + expect, + result ); + + test(); diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-001.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-001.js new file mode 100644 index 0000000..528a573 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-001.js @@ -0,0 +1,49 @@ +/** + File Name: lexical-001.js + CorrespondsTo: ecma/LexicalConventions/7.2.js + ECMA Section: 7.2 Line Terminators + Description: - readability + - separate tokens + - may occur between any two tokens + - cannot occur within any token, not even a string + - affect the process of automatic semicolon insertion. + + white space characters are: + unicode name formal name string representation + \u000A line feed <LF> \n + \u000D carriage return <CR> \r + + this test uses onerror to capture line numbers. because + we use on error, we can only have one test case per file. + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + var SECTION = "lexical-001"; + var VERSION = "JS1_4"; + var TITLE = "Line Terminators"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + result = eval("\r\n\expect"); + } catch ( e ) { + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "OBJECT = new Object; result = new OBJECT()" + + " (threw " + exception +")", + expect, + result ); + + test(); diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-002.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-002.js new file mode 100644 index 0000000..b1521c2 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-002.js @@ -0,0 +1,49 @@ +/** + File Name: lexical-002.js + Corresponds To: ecma/LexicalConventions/7.2-3-n.js + ECMA Section: 7.2 Line Terminators + Description: - readability + - separate tokens + - may occur between any two tokens + - cannot occur within any token, not even a string + - affect the process of automatic semicolon insertion. + + white space characters are: + unicode name formal name string representation + \u000A line feed <LF> \n + \u000D carriage return <CR> \r + + this test uses onerror to capture line numbers. because + we use on error, we can only have one test case per file. + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + var SECTION = "lexical-002"; + var VERSION = "JS1_4"; + var TITLE = "Line Terminators"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + result = eval("\r\n\expect"); + } catch ( e ) { + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "result=eval(\"\r\nexpect\")" + + " (threw " + exception +")", + expect, + result ); + + test(); diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-003.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-003.js new file mode 100644 index 0000000..a622d12 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-003.js @@ -0,0 +1,41 @@ +/** + File Name: lexical-003.js + Corresponds To: 7.3-13-n.js + ECMA Section: 7.3 Comments + Description: + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "lexical-003.js"; + var VERSION = "JS1_4"; + var TITLE = "Comments"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("/*\n/* nested comment */\n*/\n"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "/*/*nested comment*/ */" + + " (threw " + exception +")", + expect, + result ); + + test(); + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-004.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-004.js new file mode 100644 index 0000000..6475838 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-004.js @@ -0,0 +1,49 @@ +/** + File Name: lexical-004.js + Corresponds To: ecma/LexicalExpressions/7.4.1-1-n.js + ECMA Section: 7.4.1 + + Description: + + Reserved words cannot be used as identifiers. + + ReservedWord :: + Keyword + FutureReservedWord + NullLiteral + BooleanLiteral + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "lexical-004"; + var VERSION = "JS1_4"; + var TITLE = "Keywords"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("var null = true;"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "var null = true" + + " (threw " + exception +")", + expect, + result ); + + test(); + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-005.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-005.js new file mode 100644 index 0000000..a9cdd6b --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-005.js @@ -0,0 +1,50 @@ +/** + File Name: lexical-005.js + Corresponds To: 7.4.1-2.js + ECMA Section: 7.4.1 + + Description: + + Reserved words cannot be used as identifiers. + + ReservedWord :: + Keyword + FutureReservedWord + NullLiteral + BooleanLiteral + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "lexical-005"; + var VERSION = "JS1_4"; + var TITLE = "Keywords"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("true = false;"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "true = false" + + " (threw " + exception +")", + expect, + result ); + + test(); + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-006.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-006.js new file mode 100644 index 0000000..89c45f3 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-006.js @@ -0,0 +1,55 @@ +/** + File Name: lexical-006.js + Corresponds To: 7.4.2-1.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "lexical-006"; + var VERSION = "JS1_4"; + var TITLE = "Keywords"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("break = new Object();"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "break = new Object()" + + " (threw " + exception +")", + expect, + result ); + + test(); + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-007.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-007.js new file mode 100644 index 0000000..d34afe4 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-007.js @@ -0,0 +1,48 @@ +/** + File Name: lexical-005.js + Corresponds To: 7.4.1-3-n.js + ECMA Section: 7.4.1 + + Description: + + Reserved words cannot be used as identifiers. + + ReservedWord :: + Keyword + FutureReservedWord + NullLiteral + BooleanLiteral + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "lexical-005"; + var VERSION = "JS1_4"; + var TITLE = "Keywords"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("false = true;"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "false = true" + + " (threw " + exception +")", + expect, + result ); + + test(); + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-008.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-008.js new file mode 100644 index 0000000..f819eae --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-008.js @@ -0,0 +1,50 @@ +/** + File Name: lexical-008.js + Corresponds To: 7.4.3-1-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "lexical-008.js"; + var VERSION = "JS1_4"; + var TITLE = "Future Reserved Words"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("case = true;"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "case = true" + + " (threw " + exception +")", + expect, + result ); + + test(); + + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-009.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-009.js new file mode 100644 index 0000000..39fc71a --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-009.js @@ -0,0 +1,49 @@ +/** + File Name: lexical-009 + Corresponds To: 7.4.3-2-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "lexical-009"; + var VERSION = "ECMA_1"; + var TITLE = "Future Reserved Words"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("debugger = true;"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "debugger = true" + + " (threw " + exception +")", + expect, + result ); + + test(); + + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-010.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-010.js new file mode 100644 index 0000000..9e9f664 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-010.js @@ -0,0 +1,48 @@ +/** + File Name: lexical-010.js + Corresponds To: 7.4.3-3-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "lexical-010"; + var VERSION = "ECMA_1"; + var TITLE = "Future Reserved Words"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("export = true;"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "export = true" + + " (threw " + exception +")", + expect, + result ); + + test(); diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-011.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-011.js new file mode 100644 index 0000000..1c054f2 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-011.js @@ -0,0 +1,50 @@ +/** + File Name: lexical-011.js + Corresponds To: 7.4.3-4-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "lexical-011"; + var VERSION = "JS1_4"; + var TITLE = "Future Reserved Words"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("super = true;"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "super = true" + + " (threw " + exception +")", + expect, + result ); + + test(); + + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-012.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-012.js new file mode 100644 index 0000000..e4579fd --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-012.js @@ -0,0 +1,50 @@ +/** + File Name: lexical-012.js + Corresponds To: 7.4.3-5-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "lexical-012"; + var VERSION = "JS1_4"; + var TITLE = "Future Reserved Words"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("catch = true;"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "catch = true" + + " (threw " + exception +")", + expect, + result ); + + test(); + + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-013.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-013.js new file mode 100644 index 0000000..699d06a --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-013.js @@ -0,0 +1,49 @@ +/** + File Name: lexical-013.js + Corresponds To: 7.4.3-6-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "lexical-013"; + var VERSION = "JS1_4"; + var TITLE = "Future Reserved Words"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("default = true;"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "default = true" + + " (threw " + exception +")", + expect, + result ); + + test(); + + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-014.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-014.js new file mode 100644 index 0000000..41b12ff --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-014.js @@ -0,0 +1,50 @@ +/** + File Name: lexical-014.js + Corresponds To: 7.4.3-7-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "lexical-014.js"; + var VERSION = "JS1_4"; + var TITLE = "Future Reserved Words"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("extends = true;"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "extends = true" + + " (threw " + exception +")", + expect, + result ); + + test(); + + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-015.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-015.js new file mode 100644 index 0000000..7cbcc04 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-015.js @@ -0,0 +1,50 @@ +/** + File Name: lexical-015.js + Corresponds To: 7.4.3-8-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "lexical-015"; + var VERSION = "JS1_4"; + var TITLE = "Future Reserved Words"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("switch = true;"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "switch = true" + + " (threw " + exception +")", + expect, + result ); + + test(); + + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-016.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-016.js new file mode 100644 index 0000000..8126550 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-016.js @@ -0,0 +1,48 @@ +/** + File Name: lexical-016 + Corresponds To: 7.4.3-9-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "lexical-016"; + var VERSION = "JS1_4"; + var TITLE = "Future Reserved Words"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("class = true;"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "class = true" + + " (threw " + exception +")", + expect, + result ); + + test(); diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-017.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-017.js new file mode 100644 index 0000000..96849b7 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-017.js @@ -0,0 +1,50 @@ +/** + File Name: lexical-017.js + Corresponds To: 7.4.3-10-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "lexical-017"; + var VERSION = "JS1_4"; + var TITLE = "Future Reserved Words"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("do = true;"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "do = true" + + " (threw " + exception +")", + expect, + result ); + + test(); + + + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-018.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-018.js new file mode 100644 index 0000000..5d46c5f --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-018.js @@ -0,0 +1,50 @@ +/** + File Name: lexical-018 + Corresponds To: 7.4.3-11-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "lexical-018"; + var VERSION = "JS1_4"; + var TITLE = "Future Reserved Words"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("finally = true;"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "finally = true" + + " (threw " + exception +")", + expect, + result ); + + test(); + + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-019.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-019.js new file mode 100644 index 0000000..9f01fc0 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-019.js @@ -0,0 +1,50 @@ +/** + File Name: lexical-019.js + Corresponds To: 7.4.3-12-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "lexical-019"; + var VERSION = "JS1_4"; + var TITLE = "Future Reserved Words"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("throw = true;"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "throw = true" + + " (threw " + exception +")", + expect, + result ); + + test(); + + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-020.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-020.js new file mode 100644 index 0000000..362a3d5 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-020.js @@ -0,0 +1,50 @@ +/** + File Name: lexical-020.js + Corresponds To 7.4.3-13-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "lexical-020"; + var VERSION = "JS1_4"; + var TITLE = "Future Reserved Words"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("const = true;"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "const = true" + + " (threw " + exception +")", + expect, + result ); + + test(); + + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-021.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-021.js new file mode 100644 index 0000000..9fb3ede --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-021.js @@ -0,0 +1,50 @@ +/** + File Name: lexical-021.js + Corresponds To: 7.4.3-14-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "lexical-021.js"; + var VERSION = "ECMA_1"; + var TITLE = "Future Reserved Words"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("enum = true;"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "enum = true" + + " (threw " + exception +")", + expect, + result ); + + test(); + + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-022.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-022.js new file mode 100644 index 0000000..54f256a --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-022.js @@ -0,0 +1,50 @@ +/** + File Name: lexical-022 + Corresponds To 7.4.3-15-n.js + ECMA Section: 7.4.3 + + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "lexical-022.js"; + var VERSION = "ECMA_1"; + var TITLE = "Future Reserved Words"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("import = true;"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "import = true" + + " (threw " + exception +")", + expect, + result ); + + test(); + + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-023.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-023.js new file mode 100644 index 0000000..0715a3d --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-023.js @@ -0,0 +1,49 @@ +/** + File Name: lexical-023.js + Corresponds To: 7.4.3-16-n.js + ECMA Section: 7.4.3 + Description: + The following words are used as keywords in proposed extensions and are + therefore reserved to allow for the possibility of future adoption of + those extensions. + + FutureReservedWord :: one of + case debugger export super + catch default extends switch + class do finally throw + const enum import try + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "lexical-023.js"; + var VERSION = "ECMA_1"; + var TITLE = "Future Reserved Words"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("try = true;"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "try = true" + + " (threw " + exception +")", + expect, + result ); + + test(); + + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-024.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-024.js new file mode 100644 index 0000000..d731791 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-024.js @@ -0,0 +1,56 @@ +/** + File Name: lexical-024 + Corresponds To: 7.4.2-1-n.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "lexical-024"; + var VERSION = "JS1_4"; + var TITLE = "Keywords"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("var break;"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "var break" + + " (threw " + exception +")", + expect, + result ); + + test(); + + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-025.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-025.js new file mode 100644 index 0000000..16a44d6 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-025.js @@ -0,0 +1,56 @@ +/** + File Name: lexical-025.js + Corresponds To 7.4.2-2-n.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "lexical-025"; + var VERSION = "JS1_4"; + var TITLE = "Keywords"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("var for;"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "var for" + + " (threw " + exception +")", + expect, + result ); + + test(); + + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-026.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-026.js new file mode 100644 index 0000000..73aea73 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-026.js @@ -0,0 +1,56 @@ +/** + File Name: lexical-026.js + Corresponds To: 7.4.2-3-n.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "lexical-026"; + var VERSION = "JS1_4"; + var TITLE = "Keywords"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("var new;"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "var new" + + " (threw " + exception +")", + expect, + result ); + + test(); + + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-027.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-027.js new file mode 100644 index 0000000..b8f8593 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-027.js @@ -0,0 +1,58 @@ +/** + File Name: lexical-027.js + Corresponds To: 7.4.2-4-n.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + var + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "lexical-027"; + var VERSION = "JS1_4"; + var TITLE = "Keywords"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("var var;"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "var var" + + " (threw " + exception +")", + expect, + result ); + + test(); + + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-028.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-028.js new file mode 100644 index 0000000..a985527 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-028.js @@ -0,0 +1,56 @@ +/** + File Name: lexical-028.js + Corresponds To: 7.4.2-5-n.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "lexical-028"; + var VERSION = "JS1_4"; + var TITLE = "Keywords"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("var continue=true;"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "var continue=true" + + " (threw " + exception +")", + expect, + result ); + + test(); + + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-029.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-029.js new file mode 100644 index 0000000..0b38cbe --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-029.js @@ -0,0 +1,56 @@ +/** + File Name: lexical-029.js + Corresponds To: 7.4.2-6.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "lexical-029"; + var VERSION = "JS1_4"; + var TITLE = "Keywords"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("var function = true;"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "var function = true" + + " (threw " + exception +")", + expect, + result ); + + test(); + + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-030.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-030.js new file mode 100644 index 0000000..bc85472 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-030.js @@ -0,0 +1,56 @@ +/** + File Name: lexical-030.js + Corresponds To: 7.4.2-7-n.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "lexical-030"; + var VERSION = "JS1_4"; + var TITLE = "Keywords"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("var return = true;"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "var return = true" + + " (threw " + exception +")", + expect, + result ); + + test(); + + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-031.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-031.js new file mode 100644 index 0000000..d2251ba --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-031.js @@ -0,0 +1,56 @@ +/** + File Name: lexical-031.js + Corresponds To: 7.4.2-8-n.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "lexical-031"; + var VERSION = "JS1_4"; + var TITLE = "Keywords"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("var return;"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "var return" + + " (threw " + exception +")", + expect, + result ); + + test(); + + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-032.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-032.js new file mode 100644 index 0000000..5ac71cb --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-032.js @@ -0,0 +1,56 @@ +/** + File Name: lexical-032.js + Corresponds To: 7.4.2-9-n.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "lexical-032"; + var VERSION = "JS1_4"; + var TITLE = "Keywords"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("delete = true;"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "delete = true" + + " (threw " + exception +")", + expect, + result ); + + test(); + + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-033.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-033.js new file mode 100644 index 0000000..2a357fe --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-033.js @@ -0,0 +1,56 @@ +/** + File Name: lexical-033.js + Corresponds To: 7.4.2-10.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "lexical-033"; + var VERSION = "JS1_4"; + var TITLE = "Keywords"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("if = true;"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "if = true" + + " (threw " + exception +")", + expect, + result ); + + test(); + + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-034.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-034.js new file mode 100644 index 0000000..d6c03a2 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-034.js @@ -0,0 +1,55 @@ +/** + File Name: 7.4.2-11-n.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "lexical-034"; + var VERSION = "JS1_4"; + var TITLE = "Keywords"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("this = true"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "this = true" + + " (threw " + exception +")", + expect, + result ); + + test(); + + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-035.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-035.js new file mode 100644 index 0000000..f5fca59 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-035.js @@ -0,0 +1,56 @@ +/** + File Name: lexical-035.js + Correpsonds To: 7.4.2-12-n.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "lexical-035"; + var VERSION = "JS1_4"; + var TITLE = "Keywords"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("var while"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "var while" + + " (threw " + exception +")", + expect, + result ); + + test(); + + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-036.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-036.js new file mode 100644 index 0000000..3512c9b --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-036.js @@ -0,0 +1,56 @@ +/** + File Name: lexical-036.js + Corresponds To: 7.4.2-13-n.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "lexical-036"; + var VERSION = "JS1_4"; + var TITLE = "Keywords"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("else = true;"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "else = true" + + " (threw " + exception +")", + expect, + result ); + + test(); + + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-037.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-037.js new file mode 100644 index 0000000..641c9de --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-037.js @@ -0,0 +1,56 @@ +/** + File Name: lexical-037.js + Corresponds To: 7.4.2-14-n.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "lexical-028"; + var VERSION = "JS1_4"; + var TITLE = "Keywords"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("var in;"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "var in" + + " (threw " + exception +")", + expect, + result ); + + test(); + + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-038.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-038.js new file mode 100644 index 0000000..f44b6b3 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-038.js @@ -0,0 +1,56 @@ +/** + File Name: lexical-038.js + Corresponds To: 7.4.2-15-n.js + ECMA Section: 7.4.2 + + Description: + The following tokens are ECMAScript keywords and may not be used as + identifiers in ECMAScript programs. + + Syntax + + Keyword :: one of + break for new var + continue function return void + delete if this while + else in typeof with + + This test verifies that the keyword cannot be used as an identifier. + Functioinal tests of the keyword may be found in the section corresponding + to the function of the keyword. + + Author: christine@netscape.com + Date: 12 november 1997 + +*/ + var SECTION = "lexical-038"; + var VERSION = "JS1_4"; + var TITLE = "Keywords"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("typeof = true;"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "typeof = true" + + " (threw " + exception +")", + expect, + result ); + + test(); + + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-039.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-039.js new file mode 100644 index 0000000..e40b21b --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-039.js @@ -0,0 +1,43 @@ +/** + File Name: lexical-039 + Corresponds To: 7.5-2-n.js + ECMA Section: 7.5 Identifiers + Description: Identifiers are of unlimited length + - can contain letters, a decimal digit, _, or $ + - the first character cannot be a decimal digit + - identifiers are case sensitive + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + var SECTION = "lexical-039"; + var VERSION = "JS1_4"; + var TITLE = "Identifiers"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("var 0abc;"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "var 0abc" + + " (threw " + exception +")", + expect, + result ); + + test(); + + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-040.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-040.js new file mode 100644 index 0000000..fb306c1 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-040.js @@ -0,0 +1,43 @@ +/** + File Name: lexical-040.js + Corresponds To: 7.5-2.js + ECMA Section: 7.5 Identifiers + Description: Identifiers are of unlimited length + - can contain letters, a decimal digit, _, or $ + - the first character cannot be a decimal digit + - identifiers are case sensitive + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + var SECTION = "lexical-040"; + var VERSION = "JS1_4"; + var TITLE = "Identifiers"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("var 1abc;"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "var 1abc" + + " (threw " + exception +")", + expect, + result ); + + test(); + + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-041.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-041.js new file mode 100644 index 0000000..da830f8 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-041.js @@ -0,0 +1,45 @@ +/** + File Name: lexical-041.js + Corresponds To: 7.5-8-n.js + ECMA Section: 7.5 Identifiers + Description: Identifiers are of unlimited length + - can contain letters, a decimal digit, _, or $ + - the first character cannot be a decimal digit + - identifiers are case sensitive + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + var SECTION = "lexical-041"; + var VERSION = "ECMA_1"; + var TITLE = "Identifiers"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("var @abc;"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "var @abc" + + " (threw " + exception +")", + expect, + result ); + + test(); + + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-042.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-042.js new file mode 100644 index 0000000..88ee509 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-042.js @@ -0,0 +1,46 @@ +/** + File Name: lexical-042.js + Corresponds To: 7.5-9-n.js + ECMA Section: 7.5 Identifiers + Description: Identifiers are of unlimited length + - can contain letters, a decimal digit, _, or $ + - the first character cannot be a decimal digit + - identifiers are case sensitive + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + var SECTION = "lexical-042"; + var VERSION = "JS1_4"; + var TITLE = "Identifiers"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("var 123;"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "var 123" + + " (threw " + exception +")", + expect, + result ); + + test(); + + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-047.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-047.js new file mode 100644 index 0000000..b5e3548 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-047.js @@ -0,0 +1,47 @@ +/** + File Name: lexical-047.js + Corresponds To: 7.8.1-7-n.js + ECMA Section: 7.8.1 + Description: + Author: christine@netscape.com + Date: 15 september 1997 +*/ + + var SECTION = "lexical-047"; + var VERSION = "JS1_4"; + var TITLE = "for loops"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + var counter = 0; + eval("for ( counter = 0\n" + + "counter <= 1\n" + + "counter++ )\n" + + "{\n" + + "result += \": got to inner loop\";\n" + + "}\n"); + + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "line breaks within a for expression" + + " (threw " + exception +")", + expect, + result ); + + test(); + + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-048.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-048.js new file mode 100644 index 0000000..39a0600 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-048.js @@ -0,0 +1,41 @@ + /** + File Name: lexical-048.js + Corresponds To: 7.8.1-1.js + ECMA Section: 7.8.1 Rules of Automatic Semicolon Insertion + Description: + Author: christine@netscape.com + Date: 15 september 1997 +*/ + + var SECTION = "lexical-048"; + var VERSION = "JS1_4"; + var TITLE = "The Rules of Automatic Semicolon Insertion"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + var counter = 0; + eval( "for ( counter = 0;\ncounter <= 1\ncounter++ ) {\nresult += \": got inside for loop\")"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "line breaks within a for expression" + + " (threw " + exception +")", + expect, + result ); + + test(); + + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-049.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-049.js new file mode 100644 index 0000000..e03cfec --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-049.js @@ -0,0 +1,46 @@ + /** + File Name: lexical-049 + Corresponds To: 7.8.1-1.js + ECMA Section: 7.8.1 Rules of Automatic Semicolon Insertioin + Description: + Author: christine@netscape.com + Date: 15 september 1997 +*/ + var SECTION = "lexical-049"; + var VERSION = "JS1_4"; + var TITLE = "The Rules of Automatic Semicolon Insertion"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + var counter = 0; + eval("for ( counter = 0\n" + + "counter <= 1;\n" + + "counter++ )\n" + + "{\n" + + "result += \": got inside for loop\";\n" + + "}\n"); + + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "line breaks within a for expression" + + " (threw " + exception +")", + expect, + result ); + + test(); + + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-050.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-050.js new file mode 100644 index 0000000..bc871a7 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-050.js @@ -0,0 +1,42 @@ +/** + File Name: lexical-050.js + Corresponds to: 7.8.2-1-n.js + ECMA Section: 7.8.2 Examples of Automatic Semicolon Insertion + Description: compare some specific examples of the automatic + insertion rules in the EMCA specification. + Author: christine@netscape.com + Date: 15 september 1997 +*/ + + var SECTION = "lexical-050"; + var VERSION = "JS1_4"; + var TITLE = "Examples of Automatic Semicolon Insertion"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("{ 1 2 } 3"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "{ 1 2 } 3" + + " (threw " + exception +")", + expect, + result ); + + test(); + + + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-051.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-051.js new file mode 100644 index 0000000..68e6b44 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-051.js @@ -0,0 +1,42 @@ +/** + File Name: lexical-051.js + Corresponds to: 7.8.2-3-n.js + ECMA Section: 7.8.2 Examples of Automatic Semicolon Insertion + Description: compare some specific examples of the automatic + insertion rules in the EMCA specification. + Author: christine@netscape.com + Date: 15 september 1997 +*/ + + var SECTION = "lexical-051"; + var VERSION = "JS1_4"; + var TITLE = "Examples of Automatic Semicolon Insertion"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("for (a; b\n) result += \": got to inner loop\";") + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "for (a; b\n)" + + " (threw " + exception +")", + expect, + result ); + + test(); + + + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-052.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-052.js new file mode 100644 index 0000000..49aa7c7 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-052.js @@ -0,0 +1,44 @@ +/** + File Name: lexical-052.js + Corresponds to: 7.8.2-4-n.js + ECMA Section: 7.8.2 Examples of Automatic Semicolon Insertion + Description: compare some specific examples of the automatic + insertion rules in the EMCA specification. + Author: christine@netscape.com + Date: 15 september 1997 +*/ + + var SECTION = "lexical-052"; + var VERSION = "JS1_4"; + var TITLE = "Examples of Automatic Semicolon Insertion"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + MyFunction(); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "calling return indirectly" + + " (threw " + exception +")", + expect, + result ); + + test(); + +function MyFunction() { + var s = "return"; + eval(s); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-053.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-053.js new file mode 100644 index 0000000..6e3ae99 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-053.js @@ -0,0 +1,42 @@ +/** + File Name: lexical-053.js + Corresponds to: 7.8.2-7-n.js + ECMA Section: 7.8.2 Examples of Automatic Semicolon Insertion + Description: compare some specific examples of the automatic + insertion rules in the EMCA specification. + Author: christine@netscape.com + Date: 15 september 1997 +*/ + + var SECTION = "lexical-053"; + var VERSION = "JS1_4"; + var TITLE = "Examples of Automatic Semicolon Insertion"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + a = true + b = false + + eval('if (a > b)\nelse result += ": got to else statement"'); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "calling return indirectly" + + " (threw " + exception +")", + expect, + result ); + + test(); diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-054.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-054.js new file mode 100644 index 0000000..c4b9e9f --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/lexical-054.js @@ -0,0 +1,43 @@ +/** + File Name: lexical-054.js + Corresponds to: 7.8.2-7-n.js + ECMA Section: 7.8.2 Examples of Automatic Semicolon Insertion + Description: compare some specific examples of the automatic + insertion rules in the EMCA specification. + Author: christine@netscape.com + Date: 15 september 1997 +*/ + + var SECTION = "lexical-054"; + var VERSION = "JS1_4"; + var TITLE = "Examples of Automatic Semicolon Insertion"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + a=0; + b=1; + c=2; + d=3; + eval("if (a > b)\nelse c = d"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "if (a > b)\nelse c = d" + + " (threw " + exception +")", + expect, + result ); + + test(); diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/number-001.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/number-001.js new file mode 100644 index 0000000..1f45603 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/number-001.js @@ -0,0 +1,52 @@ +/** + File Name: number-001 + Corresponds To: 15.7.4.2-2-n.js + ECMA Section: 15.7.4.2.2 Number.prototype.toString() + Description: + If the radix is the number 10 or not supplied, then this number value is + given as an argument to the ToString operator; the resulting string value + is returned. + + If the radix is supplied and is an integer from 2 to 36, but not 10, the + result is a string, the choice of which is implementation dependent. + + The toString function is not generic; it generates a runtime error if its + this value is not a Number object. Therefore it cannot be transferred to + other kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + var SECTION = "number-001"; + var VERSION = "JS1_4"; + var TITLE = "Exceptions for Number.toString()"; + + startTest(); + writeHeaderToLog( SECTION + " Number.prototype.toString()"); + + var testcases = new Array(); + var tc = 0; + + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + + try { + object= new Object(); + object.toString = Number.prototype.toString; + result = object.toString(); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "object = new Object(); object.toString = Number.prototype.toString; object.toString()" + + " (threw " + exception +")", + expect, + result ); + + test(); diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/number-002.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/number-002.js new file mode 100644 index 0000000..5e84ebf --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/number-002.js @@ -0,0 +1,45 @@ +/** + File Name: number-002.js + Corresponds To: ecma/Number/15.7.4.3-2-n.js + ECMA Section: 15.7.4.3.1 Number.prototype.valueOf() + Description: + Returns this number value. + + The valueOf function is not generic; it generates a runtime error if its + this value is not a Number object. Therefore it cannot be transferred to + other kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + var SECTION = "number-002"; + var VERSION = "JS1_4"; + var TITLE = "Exceptions for Number.valueOf()"; + + startTest(); + writeHeaderToLog( SECTION + " Number.prototype.valueOf()"); + + var testcases = new Array(); + var tc = 0; + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + object= new Object(); + object.toString = Number.prototype.valueOf; + result = object.toString(); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "object = new Object(); object.valueOf = Number.prototype.valueOf; object.valueOf()" + + " (threw " + exception +")", + expect, + result ); + + test(); diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/number-003.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/number-003.js new file mode 100644 index 0000000..947d3d2 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/number-003.js @@ -0,0 +1,47 @@ +/** + File Name: number-003.js + Corresponds To: 15.7.4.3-3.js + ECMA Section: 15.7.4.3.1 Number.prototype.valueOf() + Description: + Returns this number value. + + The valueOf function is not generic; it generates a runtime error if its + this value is not a Number object. Therefore it cannot be transferred to + other kinds of objects for use as a method. + + Author: christine@netscape.com + Date: 16 september 1997 +*/ + var SECTION = "number-003"; + var VERSION = "JS1_4"; + var TITLE = "Exceptions for Number.valueOf()"; + + var tc = 0; + var testcases = new Array(); + + startTest(); + writeHeaderToLog( SECTION + " Number.prototype.valueOf()"); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + VALUE_OF = Number.prototype.valueOf; + OBJECT = new String("Infinity"); + OBJECT.valueOf = VALUE_OF; + result = OBJECT.valueOf(); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "Assigning Number.prototype.valueOf as the valueOf of a String object " + + " (threw " + exception +")", + expect, + result ); + + test(); + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/statement-001.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/statement-001.js new file mode 100644 index 0000000..928a04d --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/statement-001.js @@ -0,0 +1,44 @@ +/** + File Name: statement-001.js + Corresponds To: 12.6.2-9-n.js + ECMA Section: 12.6.2 The for Statement + + 1. first expression is not present. + 2. second expression is not present + 3. third expression is not present + + + Author: christine@netscape.com + Date: 15 september 1997 +*/ + + var SECTION = "statement-001.js"; +// var SECTION = "12.6.2-9-n"; + var VERSION = "ECMA_1"; + var TITLE = "The for statment"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + var tc = 0; + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("for (i) {\n}"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "for(i) {}" + + " (threw " + exception +")", + expect, + result ); + + test(); diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/statement-002.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/statement-002.js new file mode 100644 index 0000000..83c642c --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/statement-002.js @@ -0,0 +1,66 @@ +/** + File Name: statement-002.js + Corresponds To: 12.6.3-1.js + ECMA Section: 12.6.3 The for...in Statement + Description: + The production IterationStatement : for ( LeftHandSideExpression in Expression ) + Statement is evaluated as follows: + + 1. Evaluate the Expression. + 2. Call GetValue(Result(1)). + 3. Call ToObject(Result(2)). + 4. Let C be "normal completion". + 5. Get the name of the next property of Result(3) that doesn't have the + DontEnum attribute. If there is no such property, go to step 14. + 6. Evaluate the LeftHandSideExpression ( it may be evaluated repeatedly). + 7. Call PutValue(Result(6), Result(5)). PutValue( V, W ): + 1. If Type(V) is not Reference, generate a runtime error. + 2. Call GetBase(V). + 3. If Result(2) is null, go to step 6. + 4. Call the [[Put]] method of Result(2), passing GetPropertyName(V) + for the property name and W for the value. + 5. Return. + 6. Call the [[Put]] method for the global object, passing + GetPropertyName(V) for the property name and W for the value. + 7. Return. + 8. Evaluate Statement. + 9. If Result(8) is a value completion, change C to be "normal completion + after value V" where V is the value carried by Result(8). + 10. If Result(8) is a break completion, go to step 14. + 11. If Result(8) is a continue completion, go to step 5. + 12. If Result(8) is a return completion, return Result(8). + 13. Go to step 5. + 14. Return C. + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + var SECTION = "statement-002"; + var VERSION = "JS1_4"; + var TITLE = "The for..in statment"; + + var testcases = new Array(); + var tc = 0; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval(" for ( var i, p in this) { result += this[p]; }"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "more than one member expression" + + " (threw " + exception +")", + expect, + result ); + + test(); diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/statement-003.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/statement-003.js new file mode 100644 index 0000000..c7ffc7f --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/statement-003.js @@ -0,0 +1,77 @@ +/** + File Name: statement-003 + Corresponds To: 12.6.3-7-n.js + ECMA Section: 12.6.3 The for...in Statement + Description: + The production IterationStatement : for ( LeftHandSideExpression in Expression ) + Statement is evaluated as follows: + + 1. Evaluate the Expression. + 2. Call GetValue(Result(1)). + 3. Call ToObject(Result(2)). + 4. Let C be "normal completion". + 5. Get the name of the next property of Result(3) that doesn't have the + DontEnum attribute. If there is no such property, go to step 14. + 6. Evaluate the LeftHandSideExpression ( it may be evaluated repeatedly). + 7. Call PutValue(Result(6), Result(5)). PutValue( V, W ): + 1. If Type(V) is not Reference, generate a runtime error. + 2. Call GetBase(V). + 3. If Result(2) is null, go to step 6. + 4. Call the [[Put]] method of Result(2), passing GetPropertyName(V) + for the property name and W for the value. + 5. Return. + 6. Call the [[Put]] method for the global object, passing + GetPropertyName(V) for the property name and W for the value. + 7. Return. + 8. Evaluate Statement. + 9. If Result(8) is a value completion, change C to be "normal completion + after value V" where V is the value carried by Result(8). + 10. If Result(8) is a break completion, go to step 14. + 11. If Result(8) is a continue completion, go to step 5. + 12. If Result(8) is a return completion, return Result(8). + 13. Go to step 5. + 14. Return C. + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + var SECTION = "statement-003"; + var VERSION = "JS1_4"; + var TITLE = "The for..in statment"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + var tc = 0; + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + var o = new MyObject(); + var result = 0; + + eval("for ( this in o) {\n" + + "result += this[p];\n" + + "}\n"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "bad left-hand side expression" + + " (threw " + exception +")", + expect, + result ); + + test(); + +function MyObject() { + this.value = 2; + this[0] = 4; + return this; +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/statement-004.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/statement-004.js new file mode 100644 index 0000000..9eee4e6 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/statement-004.js @@ -0,0 +1,49 @@ +/** + File Name: statement-004.js + Corresponds To: 12.6.3-1.js + ECMA Section: 12.6.3 The for...in Statement + Description: + Author: christine@netscape.com + Date: 11 september 1997 +*/ + var SECTION = "statement-004"; + var VERSION = "JS1_4"; + var TITLE = "The for..in statment"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + var tc = 0; + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + var o = new MyObject(); + + eval("for ( \"a\" in o) {\n" + + "result += this[p];\n" + + "}"); + + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "bad left-hand side expression" + + " (threw " + exception +")", + expect, + result ); + + test(); + + +function MyObject() { + this.value = 2; + this[0] = 4; + return this; +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/statement-005.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/statement-005.js new file mode 100644 index 0000000..50933b0 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/statement-005.js @@ -0,0 +1,48 @@ +/** + File Name: statement-005.js + Corresponds To: 12.6.3-8-n.js + ECMA Section: 12.6.3 The for...in Statement + Description: + Author: christine@netscape.com + Date: 11 september 1997 +*/ + var SECTION = "statement-005"; + var VERSION = "JS1_4"; + var TITLE = "The for..in statment"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var testcases = new Array(); + var tc = 0; + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + var o = new MyObject(); + result = 0; + + eval("for (1 in o) {\n" + + "result += this[p];" + + "}\n"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "bad left-hand side expression" + + " (threw " + exception +")", + expect, + result ); + + test(); + +function MyObject() { + this.value = 2; + this[0] = 4; + return this; +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/statement-006.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/statement-006.js new file mode 100644 index 0000000..1fe0325 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/statement-006.js @@ -0,0 +1,48 @@ +/** + File Name: statement-006.js + Corresponds To: 12.6.3-9-n.js + ECMA Section: 12.6.3 The for...in Statement + Description: + + Author: christine@netscape.com + Date: 11 september 1997 +*/ + var SECTION = "statement-006"; + var VERSION = "JS1_4"; + var TITLE = "The for..in statment"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + var o = new MyObject(); + var result = 0; + for ( var o in foo) { + result += this[o]; + } + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "object is not defined" + + " (threw " + exception +")", + expect, + result ); + + test(); + +function MyObject() { + this.value = 2; + this[0] = 4; + return this; +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/statement-007.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/statement-007.js new file mode 100644 index 0000000..506578b --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/statement-007.js @@ -0,0 +1,39 @@ +/** + File Name: statement-007.js + Corresponds To: 12.7-1-n.js + ECMA Section: 12.7 The continue statement + Description: + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "statement-007"; + var VERSION = "JS1_4"; + var TITLE = "The continue statment"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("continue;"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "continue outside of an iteration statement" + + " (threw " + exception +")", + expect, + result ); + + test(); + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/statement-008.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/statement-008.js new file mode 100644 index 0000000..e293964 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/statement-008.js @@ -0,0 +1,39 @@ +/** + File Name: statement-008.js + Corresponds To: 12.8-1-n.js + ECMA Section: 12.8 The break statement + Description: + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "statement-008"; + var VERSION = "JS1_4"; + var TITLE = "The break in statment"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("break;"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "break outside of an iteration statement" + + " (threw " + exception +")", + expect, + result ); + + test(); + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/statement-009.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/statement-009.js new file mode 100644 index 0000000..136d3f1 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/statement-009.js @@ -0,0 +1,38 @@ +/** + File Name: 12.9-1-n.js + ECMA Section: 12.9 The return statement + Description: + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "12.9-1-n"; + var VERSION = "ECMA_1"; + var TITLE = "The return statment"; + + startTest(); + writeHeaderToLog( SECTION + " The return statement"); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + eval("return;"); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "return outside of a function" + + " (threw " + exception +")", + expect, + result ); + + test(); + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/string-001.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/string-001.js new file mode 100644 index 0000000..9ba39af --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/string-001.js @@ -0,0 +1,50 @@ +/** + File Name: string-001.js + Corresponds To: 15.5.4.2-2-n.js + ECMA Section: 15.5.4.2 String.prototype.toString() + + Description: Returns this string value. Note that, for a String + object, the toString() method happens to return the same + thing as the valueOf() method. + + The toString function is not generic; it generates a + runtime error if its this value is not a String object. + Therefore it connot be transferred to the other kinds of + objects for use as a method. + + Author: christine@netscape.com + Date: 1 october 1997 +*/ + var SECTION = "string-001"; + var VERSION = "JS1_4"; + var TITLE = "String.prototype.toString"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + OBJECT = new Object(); + OBJECT.toString = String.prototype.toString(); + result = OBJECT.toString(); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "OBJECT = new Object; "+ + " OBJECT.toString = String.prototype.toString; OBJECT.toString()" + + " (threw " + exception +")", + expect, + result ); + + test(); + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/string-002.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/string-002.js new file mode 100644 index 0000000..857271e --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Exceptions/string-002.js @@ -0,0 +1,49 @@ +/** + File Name: string-002.js + Corresponds To: 15.5.4.3-3-n.js + ECMA Section: 15.5.4.3 String.prototype.valueOf() + + Description: Returns this string value. + + The valueOf function is not generic; it generates a + runtime error if its this value is not a String object. + Therefore it connot be transferred to the other kinds of + objects for use as a method. + + Author: christine@netscape.com + Date: 1 october 1997 +*/ + var SECTION = "string-002"; + var VERSION = "JS1_4"; + var TITLE = "String.prototype.valueOf"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var result = "Failed"; + var exception = "No exception thrown"; + var expect = "Passed"; + + try { + var OBJECT =new Object(); + OBJECT.valueOf = String.prototype.valueOf; + result = OBJECT.valueOf(); + } catch ( e ) { + result = expect; + exception = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "OBJECT = new Object; OBJECT.valueOf = String.prototype.valueOf;"+ + "result = OBJECT.valueOf();" + + " (threw " + exception +")", + expect, + result ); + + test(); + + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Expressions/StrictEquality-001.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Expressions/StrictEquality-001.js new file mode 100644 index 0000000..c3ac507 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Expressions/StrictEquality-001.js @@ -0,0 +1,70 @@ +/** + * File Name: StrictEquality-001.js + * ECMA Section: 11.9.6.js + * Description: + * + * Author: christine@netscape.com + * Date: 4 september 1998 + */ + var SECTION = "StrictEquality-001 - 11.9.6"; + var VERSION = "ECMA_2"; + var TITLE = "The strict equality operator ( === )"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + + // 1. If Type(x) is different from Type(y) return false + + StrictEquality( true, new Boolean(true), false ); + StrictEquality( new Boolean(), false, false ); + StrictEquality( "", new String(), false ); + StrictEquality( new String("hi"), "hi", false ); + + // 2. If Type(x) is not Number go to step 9. + + // 3. If x is NaN, return false + StrictEquality( NaN, NaN, false ); + StrictEquality( NaN, 0, false ); + + // 4. If y is NaN, return false. + StrictEquality( 0, NaN, false ); + + // 5. if x is the same number value as y, return true + + // 6. If x is +0 and y is -0, return true + + // 7. If x is -0 and y is +0, return true + + // 8. Return false. + + + // 9. If Type(x) is String, then return true if x and y are exactly + // the same sequence of characters ( same length and same characters + // in corresponding positions.) Otherwise return false. + + // 10. If Type(x) is Boolean, return true if x and y are both true or + // both false. otherwise return false. + + + // Return true if x and y refer to the same object. Otherwise return + // false. + + // Return false. + + + test(); + +function StrictEquality( x, y, expect ) { + result = ( x === y ); + + testcases[tc++] = new TestCase( + SECTION, + x +" === " + y, + expect, + result ); +} + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Expressions/instanceof-001.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Expressions/instanceof-001.js new file mode 100644 index 0000000..2e7412a --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Expressions/instanceof-001.js @@ -0,0 +1,117 @@ +/** + * File Name: instanceof-001.js + * ECMA Section: 11.8.6 + * Description: + * + * RelationalExpression instanceof Identifier + * + * Author: christine@netscape.com + * Date: 2 September 1998 + */ + var SECTION = "instanceof-001"; + var VERSION = "ECMA_2"; + var TITLE = "instanceof" + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + function InstanceOf( object_1, object_2, expect ) { + result = object_1 instanceof object_2; + + testcases[tc++] = new TestCase( + SECTION, + "(" + object_1 + ") instanceof " + object_2, + expect, + result ); + } + + function Gen3(value) { + this.value = value; + this.generation = 3; + this.toString = new Function ( "return \"(Gen\"+this.generation+\" instance)\"" ); + } + Gen3.name = 3; + Gen3.__proto__.toString = new Function( "return \"(\"+this.name+\" object)\""); + + function Gen2(value) { + this.value = value; + this.generation = 2; + } + Gen2.name = 2; + Gen2.prototype = new Gen3(); + + function Gen1(value) { + this.value = value; + this.generation = 1; + } + Gen1.name = 1; + Gen1.prototype = new Gen2(); + + function Gen0(value) { + this.value = value; + this.generation = 0; + } + Gen0.name = 0; + Gen0.prototype = new Gen1(); + + + function GenA(value) { + this.value = value; + this.generation = "A"; + this.toString = new Function ( "return \"(instance of Gen\"+this.generation+\")\"" ); + + } + GenA.prototype = new Gen0(); + GenA.name = "A"; + + function GenB(value) { + this.value = value; + this.generation = "B"; + this.toString = new Function ( "return \"(instance of Gen\"+this.generation+\")\"" ); + } + GenB.name = "B" + GenB.prototype = void 0; + + // RelationalExpression is not an object. + + InstanceOf( true, Boolean, false ); + InstanceOf( new Boolean(false), Boolean, true ); + + // Identifier is not a function + +// InstanceOf( true, true, false ); +// InstanceOf( new Boolean(true), false, false ); + + // Identifier is a function, prototype of Identifier is not an object + +// InstanceOf( new GenB(), GenB, false ); + + // __proto__ of RelationalExpression is null. should return false + genA = new GenA(); + genA.__proto__ = null; + + InstanceOf( genA, GenA, false ); + + // RelationalExpression.__proto__ == (but not ===) Identifier.prototype + + InstanceOf( new Gen2(), Gen0, false ); + InstanceOf( new Gen2(), Gen1, false ); + InstanceOf( new Gen2(), Gen2, true ); + InstanceOf( new Gen2(), Gen3, true ); + + // RelationalExpression.__proto__.__proto__ === Identifier.prototype + InstanceOf( new Gen0(), Gen0, true ); + InstanceOf( new Gen0(), Gen1, true ); + InstanceOf( new Gen0(), Gen2, true ); + InstanceOf( new Gen0(), Gen3, true ); + + InstanceOf( new Gen0(), Object, true ); + InstanceOf( new Gen0(), Function, false ); + + InstanceOf( Gen0, Function, true ); + InstanceOf( Gen0, Object, true ); + + test();
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Expressions/instanceof-002.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Expressions/instanceof-002.js new file mode 100644 index 0000000..68697d0 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Expressions/instanceof-002.js @@ -0,0 +1,124 @@ +/** + File Name: instanceof-002.js + Section: + Description: Determining Instance Relationships + + This test is the same as js1_3/inherit/proto-002, except that it uses + the builtin instanceof operator rather than a user-defined function + called InstanceOf. + + 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 +*/ +// onerror = err; + + var SECTION = "instanceof-002"; + var VERSION = "ECMA_2"; + var TITLE = "Determining Instance Relationships"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + +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() + + testcases[tc++] = new TestCase( SECTION, + "pat.__proto__ == Engineer.prototype", + true, + pat.__proto__ == Engineer.prototype ); + + testcases[tc++] = new TestCase( SECTION, + "pat.__proto__.__proto__ == WorkerBee.prototype", + true, + pat.__proto__.__proto__ == WorkerBee.prototype ); + + testcases[tc++] = new TestCase( SECTION, + "pat.__proto__.__proto__.__proto__ == Employee.prototype", + true, + pat.__proto__.__proto__.__proto__ == Employee.prototype ); + + testcases[tc++] = new TestCase( SECTION, + "pat.__proto__.__proto__.__proto__.__proto__ == Object.prototype", + true, + pat.__proto__.__proto__.__proto__.__proto__ == Object.prototype ); + + testcases[tc++] = new TestCase( SECTION, + "pat.__proto__.__proto__.__proto__.__proto__.__proto__ == null", + true, + pat.__proto__.__proto__.__proto__.__proto__.__proto__ == null ); + + testcases[tc++] = new TestCase( SECTION, + "pat instanceof Engineer", + true, + pat instanceof Engineer ); + + testcases[tc++] = new TestCase( SECTION, + "pat instanceof WorkerBee )", + true, + pat instanceof WorkerBee ); + + testcases[tc++] = new TestCase( SECTION, + "pat instanceof Employee )", + true, + pat instanceof Employee ); + + testcases[tc++] = new TestCase( SECTION, + "pat instanceof Object )", + true, + pat instanceof Object ); + + testcases[tc++] = new TestCase( SECTION, + "pat instanceof SalesPerson )", + false, + pat instanceof SalesPerson ); + test(); diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Expressions/instanceof-003-n.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Expressions/instanceof-003-n.js new file mode 100644 index 0000000..f48108e --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Expressions/instanceof-003-n.js @@ -0,0 +1,93 @@ +/** + * File Name: instanceof-001.js + * ECMA Section: 11.8.6 + * Description: + * + * RelationalExpression instanceof Identifier + * + * Author: christine@netscape.com + * Date: 2 September 1998 + */ + var SECTION = "instanceof-001"; + var VERSION = "ECMA_2"; + var TITLE = "instanceof" + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + function InstanceOf( object_1, object_2, expect ) { + result = object_1 instanceof object_2; + + testcases[tc++] = new TestCase( + SECTION, + "(" + object_1 + ") instanceof " + object_2, + expect, + result ); + } + + function Gen3(value) { + this.value = value; + this.generation = 3; + this.toString = new Function ( "return \"(Gen\"+this.generation+\" instance)\"" ); + } + Gen3.name = 3; + Gen3.__proto__.toString = new Function( "return \"(\"+this.name+\" object)\""); + + function Gen2(value) { + this.value = value; + this.generation = 2; + } + Gen2.name = 2; + Gen2.prototype = new Gen3(); + + function Gen1(value) { + this.value = value; + this.generation = 1; + } + Gen1.name = 1; + Gen1.prototype = new Gen2(); + + function Gen0(value) { + this.value = value; + this.generation = 0; + } + Gen0.name = 0; + Gen0.prototype = new Gen1(); + + + function GenA(value) { + this.value = value; + this.generation = "A"; + this.toString = new Function ( "return \"(instance of Gen\"+this.generation+\")\"" ); + + } + GenA.prototype = new Gen0(); + GenA.name = "A"; + + function GenB(value) { + this.value = value; + this.generation = "B"; + this.toString = new Function ( "return \"(instance of Gen\"+this.generation+\")\"" ); + } + GenB.name = "B" + GenB.prototype = void 0; + + // RelationalExpression is not an object. + + InstanceOf( true, Boolean, false ); +// InstanceOf( new Boolean(false), Boolean, true ); + + // Identifier is not a function + + InstanceOf( true, true, false ); +// InstanceOf( new Boolean(true), false, false ); + + // Identifier is a function, prototype of Identifier is not an object + +// InstanceOf( new GenB(), GenB, false ); + + + test();
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Expressions/instanceof-004-n.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Expressions/instanceof-004-n.js new file mode 100644 index 0000000..664a553 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Expressions/instanceof-004-n.js @@ -0,0 +1,92 @@ +/** + * File Name: instanceof-001.js + * ECMA Section: 11.8.6 + * Description: + * + * RelationalExpression instanceof Identifier + * + * Author: christine@netscape.com + * Date: 2 September 1998 + */ + var SECTION = "instanceof-001"; + var VERSION = "ECMA_2"; + var TITLE = "instanceof" + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + function InstanceOf( object_1, object_2, expect ) { + result = object_1 instanceof object_2; + + testcases[tc++] = new TestCase( + SECTION, + "(" + object_1 + ") instanceof " + object_2, + expect, + result ); + } + + function Gen3(value) { + this.value = value; + this.generation = 3; + this.toString = new Function ( "return \"(Gen\"+this.generation+\" instance)\"" ); + } + Gen3.name = 3; + Gen3.__proto__.toString = new Function( "return \"(\"+this.name+\" object)\""); + + function Gen2(value) { + this.value = value; + this.generation = 2; + } + Gen2.name = 2; + Gen2.prototype = new Gen3(); + + function Gen1(value) { + this.value = value; + this.generation = 1; + } + Gen1.name = 1; + Gen1.prototype = new Gen2(); + + function Gen0(value) { + this.value = value; + this.generation = 0; + } + Gen0.name = 0; + Gen0.prototype = new Gen1(); + + + function GenA(value) { + this.value = value; + this.generation = "A"; + this.toString = new Function ( "return \"(instance of Gen\"+this.generation+\")\"" ); + + } + GenA.prototype = new Gen0(); + GenA.name = "A"; + + function GenB(value) { + this.value = value; + this.generation = "B"; + this.toString = new Function ( "return \"(instance of Gen\"+this.generation+\")\"" ); + } + GenB.name = "B" + GenB.prototype = void 0; + + // RelationalExpression is not an object. + + InstanceOf( true, Boolean, false ); + InstanceOf( new Boolean(false), Boolean, true ); + + // Identifier is not a function + + InstanceOf( new Boolean(true), false, false ); + + // Identifier is a function, prototype of Identifier is not an object + +// InstanceOf( new GenB(), GenB, false ); + + + test();
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Expressions/instanceof-005-n.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Expressions/instanceof-005-n.js new file mode 100644 index 0000000..c3a621d --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Expressions/instanceof-005-n.js @@ -0,0 +1,84 @@ +/** + * File Name: instanceof-001.js + * ECMA Section: 11.8.6 + * Description: + * + * RelationalExpression instanceof Identifier + * + * Author: christine@netscape.com + * Date: 2 September 1998 + */ + var SECTION = "instanceof-001"; + var VERSION = "ECMA_2"; + var TITLE = "instanceof" + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + function InstanceOf( object_1, object_2, expect ) { + result = object_1 instanceof object_2; + + testcases[tc++] = new TestCase( + SECTION, + "(" + object_1 + ") instanceof " + object_2, + expect, + result ); + } + + function Gen3(value) { + this.value = value; + this.generation = 3; + this.toString = new Function ( "return \"(Gen\"+this.generation+\" instance)\"" ); + } + Gen3.name = 3; + Gen3.__proto__.toString = new Function( "return \"(\"+this.name+\" object)\""); + + function Gen2(value) { + this.value = value; + this.generation = 2; + } + Gen2.name = 2; + Gen2.prototype = new Gen3(); + + function Gen1(value) { + this.value = value; + this.generation = 1; + } + Gen1.name = 1; + Gen1.prototype = new Gen2(); + + function Gen0(value) { + this.value = value; + this.generation = 0; + } + Gen0.name = 0; + Gen0.prototype = new Gen1(); + + + function GenA(value) { + this.value = value; + this.generation = "A"; + this.toString = new Function ( "return \"(instance of Gen\"+this.generation+\")\"" ); + + } + GenA.prototype = new Gen0(); + GenA.name = "A"; + + function GenB(value) { + this.value = value; + this.generation = "B"; + this.toString = new Function ( "return \"(instance of Gen\"+this.generation+\")\"" ); + } + GenB.name = "B" + GenB.prototype = void 0; + + + // Identifier is a function, prototype of Identifier is not an object + + InstanceOf( new GenB(), GenB, false ); + + + test();
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Expressions/instanceof-006.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Expressions/instanceof-006.js new file mode 100644 index 0000000..f1be0b4 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Expressions/instanceof-006.js @@ -0,0 +1,83 @@ +/** + * File Name: instanceof-001.js + * ECMA Section: 11.8.6 + * Description: + * + * RelationalExpression instanceof Identifier + * + * Author: christine@netscape.com + * Date: 2 September 1998 + */ + var SECTION = "instanceof-001"; + var VERSION = "ECMA_2"; + var TITLE = "instanceof" + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + function InstanceOf( object_1, object_2, expect ) { + result = object_1 instanceof object_2; + + testcases[tc++] = new TestCase( + SECTION, + "(" + object_1 + ") instanceof " + object_2, + expect, + result ); + } + + function Gen3(value) { + this.value = value; + this.generation = 3; + this.toString = new Function ( "return \"(Gen\"+this.generation+\" instance)\"" ); + } + Gen3.name = 3; + Gen3.__proto__.toString = new Function( "return \"(\"+this.name+\" object)\""); + + function Gen2(value) { + this.value = value; + this.generation = 2; + } + Gen2.name = 2; + Gen2.prototype = new Gen3(); + + function Gen1(value) { + this.value = value; + this.generation = 1; + } + Gen1.name = 1; + Gen1.prototype = new Gen2(); + + function Gen0(value) { + this.value = value; + this.generation = 0; + } + Gen0.name = 0; + Gen0.prototype = new Gen1(); + + + function GenA(value) { + this.value = value; + this.generation = "A"; + this.toString = new Function ( "return \"(instance of Gen\"+this.generation+\")\"" ); + + } + GenA.prototype = new Gen0(); + GenA.name = "A"; + + function GenB(value) { + this.value = value; + this.generation = "B"; + this.toString = new Function ( "return \"(instance of Gen\"+this.generation+\")\"" ); + } + GenB.name = "B" + GenB.prototype = void 0; + + // RelationalExpression is not an object. + +// InstanceOf( true, Boolean, false ); + InstanceOf( new Boolean(false), Boolean, true ); + + test();
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/FunctionObjects/apply-001-n.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/FunctionObjects/apply-001-n.js new file mode 100644 index 0000000..2a2bf40 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/FunctionObjects/apply-001-n.js @@ -0,0 +1,39 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is Mozilla Communicator client code, released March + * 31, 1998. + * + * The Initial Developer of the Original Code is Netscape Communications + * Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + * Rob Ginda rginda@netscape.com + */ + +print ("STATUS: f.apply crash test."); + +print ("BUGNUMBER: 21836"); + +function f () +{ +} + +test (); + +function test () +{ + f.apply(2,2); +} + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/FunctionObjects/call-1.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/FunctionObjects/call-1.js new file mode 100644 index 0000000..9ea9074 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/FunctionObjects/call-1.js @@ -0,0 +1,40 @@ +/** + File Name: call-1.js + Section: Function.prototype.call + Description: + + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = "call-1"; + var VERSION = "ECMA_2"; + var TITLE = "Function.prototype.call"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + + testcases[tc++] = new TestCase( SECTION, + "ToString.call( this, this )", + GLOBAL, + ToString.call( this, this ) ); + + testcases[tc++] = new TestCase( SECTION, + "ToString.call( Boolean, Boolean.prototype )", + "false", + ToString.call( Boolean, Boolean.prototype ) ); + + testcases[tc++] = new TestCase( SECTION, + "ToString.call( Boolean, Boolean.prototype.valueOf() )", + "false", + ToString.call( Boolean, Boolean.prototype.valueOf() ) ); + + test(); + +function ToString( obj ) { + return obj +""; +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/LexicalConventions/keywords-001.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/LexicalConventions/keywords-001.js new file mode 100644 index 0000000..19e930d --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/LexicalConventions/keywords-001.js @@ -0,0 +1,31 @@ +/** + * File Name: + * ECMA Section: + * Description: + * + * + * Author: christine@netscape.com + * Date: 11 August 1998 + */ + var SECTION = ""; + var VERSION = "ECMA_2"; + var TITLE = "Keywords"; + + startTest(); + + var result = "failed"; + + try { + eval("super;"); + } + catch (x) { + if (x instanceof SyntaxError) + result = x.name; + } + + AddTestCase( + "using the expression \"super\" shouldn't cause js to crash", + "SyntaxError", + result ); + + test(); diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/LexicalConventions/regexp-literals-001.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/LexicalConventions/regexp-literals-001.js new file mode 100644 index 0000000..6af945b --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/LexicalConventions/regexp-literals-001.js @@ -0,0 +1,38 @@ +/** + * File Name: LexicalConventions/regexp-literals-001.js + * ECMA Section: 7.8.5 + * Description: + * + * + * Author: christine@netscape.com + * Date: 11 August 1998 + */ + var SECTION = "LexicalConventions/regexp-literals-001.js"; + var VERSION = "ECMA_2"; + var TITLE = "Regular Expression Literals"; + + startTest(); + + // Regular Expression Literals may not be empty; // should be regarded + // as a comment, not a RegExp literal. + + s = //; + + "passed"; + + AddTestCase( + "// should be a comment, not a regular expression literal", + "passed", + String(s)); + + AddTestCase( + "// typeof object should be type of object declared on following line", + "passed", + (typeof s) == "string" ? "passed" : "failed" ); + + AddTestCase( + "// should not return an object of the type RegExp", + "passed", + (typeof s == "object") ? "failed" : "passed" ); + + test(); diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/LexicalConventions/regexp-literals-002.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/LexicalConventions/regexp-literals-002.js new file mode 100644 index 0000000..c67184b --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/LexicalConventions/regexp-literals-002.js @@ -0,0 +1,22 @@ +/** + * File Name: LexicalConventions/regexp-literals-002.js + * ECMA Section: 7.8.5 + * Description: Based on ECMA 2 Draft 8 October 1999 + * + * Author: christine@netscape.com + * Date: 19 February 1999 + */ + var SECTION = "LexicalConventions/regexp-literals-002.js"; + var VERSION = "ECMA_2"; + var TITLE = "Regular Expression Literals"; + + startTest(); + + // A regular expression literal represents an object of type RegExp. + + AddTestCase( + "// A regular expression literal represents an object of type RegExp.", + "true", + (/x*/ instanceof RegExp).toString() ); + + test(); diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/RegExp/constructor-001.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/RegExp/constructor-001.js new file mode 100644 index 0000000..be904e5 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/RegExp/constructor-001.js @@ -0,0 +1,66 @@ +/** + * File Name: RegExp/constructor-001.js + * ECMA Section: 15.7.3.3 + * Description: Based on ECMA 2 Draft 7 February 1999 + * + * Author: christine@netscape.com + * Date: 19 February 1999 + */ + var SECTION = "RegExp/constructor-001"; + var VERSION = "ECMA_2"; + var TITLE = "new RegExp()"; + + startTest(); + + /* + * for each test case, verify: + * - verify that [[Class]] property is RegExp + * - prototype property should be set to RegExp.prototype + * - source is set to the empty string + * - global property is set to false + * - ignoreCase property is set to false + * - multiline property is set to false + * - lastIndex property is set to 0 + */ + + RegExp.prototype.getClassProperty = Object.prototype.toString; + var re = new RegExp(); + + AddTestCase( + "new RegExp().__proto__", + RegExp.prototype, + re.__proto__ + ); + + AddTestCase( + "RegExp.prototype.getClassProperty = Object.prototype.toString; " + + "(new RegExp()).getClassProperty()", + "[object RegExp]", + re.getClassProperty() ); + + AddTestCase( + "(new RegExp()).source", + "", + re.source ); + + AddTestCase( + "(new RegExp()).global", + false, + re.global ); + + AddTestCase( + "(new RegExp()).ignoreCase", + false, + re.ignoreCase ); + + AddTestCase( + "(new RegExp()).multiline", + false, + re.multiline ); + + AddTestCase( + "(new RegExp()).lastIndex", + 0, + re.lastIndex ); + + test() diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/RegExp/exec-001.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/RegExp/exec-001.js new file mode 100644 index 0000000..69edc11 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/RegExp/exec-001.js @@ -0,0 +1,34 @@ +/** + * File Name: RegExp/exec-001.js + * ECMA Section: 15.7.5.3 + * Description: Based on ECMA 2 Draft 7 February 1999 + * + * Author: christine@netscape.com + * Date: 19 February 1999 + */ + var SECTION = "RegExp/exec-001"; + var VERSION = "ECMA_2"; + var TITLE = "RegExp.prototype.exec(string)"; + + startTest(); + + /* + * for each test case, verify: + * - type of object returned + * - length of the returned array + * - value of lastIndex + * - value of index + * - value of input + * - value of the array indices + */ + + // test cases without subpatterns + // test cases with subpatterns + // global property is true + // global property is false + // test cases in which the exec returns null + + testcases[0] = { expect:"PASSED", actual:"PASSED", description:"NO TESTS EXIST" }; + + test(); + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/RegExp/exec-002.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/RegExp/exec-002.js new file mode 100644 index 0000000..c811b61 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/RegExp/exec-002.js @@ -0,0 +1,182 @@ +/** + * File Name: RegExp/exec-002.js + * ECMA Section: 15.7.5.3 + * Description: Based on ECMA 2 Draft 7 February 1999 + * + * Test cases provided by rogerl@netscape.com + * + * Author: christine@netscape.com + * Date: 19 February 1999 + */ + var SECTION = "RegExp/exec-002"; + var VERSION = "ECMA_2"; + var TITLE = "RegExp.prototype.exec(string)"; + + startTest(); + + /* + * for each test case, verify: + * - type of object returned + * - length of the returned array + * - value of lastIndex + * - value of index + * - value of input + * - value of the array indices + */ + + AddRegExpCases( + /(a|d|q|)x/i, + "bcaDxqy", + 3, + ["Dx", "D"] ); + + AddRegExpCases( + /(a|(e|q))(x|y)/, + "bcaddxqy", + 6, + ["qy","q","q","y"] ); + + + AddRegExpCases( + /a+b+d/, + "aabbeeaabbs", + 0, + null ); + + AddRegExpCases( + /a*b/, + "aaadaabaaa", + 4, + ["aab"] ); + + AddRegExpCases( + /a*b/, + "dddb", + 3, + ["b"] ); + + AddRegExpCases( + /a*b/, + "xxx", + 0, + null ); + + AddRegExpCases( + /x\d\dy/, + "abcx45ysss235", + 3, + ["x45y"] ); + + AddRegExpCases( + /[^abc]def[abc]+/, + "abxdefbb", + 2, + ["xdefbb"] ); + + AddRegExpCases( + /(a*)baa/, + "ccdaaabaxaabaa", + 9, + ["aabaa", "aa"] ); + + AddRegExpCases( + /(a*)baa/, + "aabaa", + 0, + ["aabaa", "aa"] ); + + AddRegExpCases( + /q(a|b)*q/, + "xxqababqyy", + 2, + ["qababq", "b"] ); + + AddRegExpCases( + /(a(.|[^d])c)*/, + "adcaxc", + 0, + ["adcaxc", "axc", "x"] ); + + AddRegExpCases( + /(a*)b\1/, + "abaaaxaabaayy", + 0, + ["aba", "a"] ); + + AddRegExpCases( + /(a*)b\1/, + "abaaaxaabaayy", + 0, + ["aba", "a"] ); + + AddRegExpCases( + /(a*)b\1/, + "cccdaaabaxaabaayy", + 6, + ["aba", "a"] ); + + AddRegExpCases( + /(a*)b\1/, + "cccdaaabqxaabaayy", + 7, + ["b", ""] ); + + AddRegExpCases( + /"(.|[^"\\\\])*"/, + 'xx\"makudonarudo\"yy', + 2, + ["\"makudonarudo\"", "o"] ); + + AddRegExpCases( + /"(.|[^"\\\\])*"/, + "xx\"ma\"yy", + 2, + ["\"ma\"", "a"] ); + + test(); + +function AddRegExpCases( + regexp, pattern, index, matches_array ) { + + // prevent a runtime error + + if ( regexp.exec(pattern) == null || matches_array == null ) { + AddTestCase( + regexp + ".exec(" + pattern +")", + matches_array, + regexp.exec(pattern) ); + + return; + } + AddTestCase( + regexp + ".exec(" + pattern +").length", + matches_array.length, + regexp.exec(pattern).length ); + + AddTestCase( + regexp + ".exec(" + pattern +").index", + index, + regexp.exec(pattern).index ); + + AddTestCase( + regexp + ".exec(" + pattern +").input", + pattern, + regexp.exec(pattern).input ); + + AddTestCase( + regexp + ".exec(" + pattern +").toString()", + matches_array.toString(), + regexp.exec(pattern).toString() ); +/* + var limit = matches_array.length > regexp.exec(pattern).length + ? matches_array.length + : regexp.exec(pattern).length; + + for ( var matches = 0; matches < limit; matches++ ) { + AddTestCase( + regexp + ".exec(" + pattern +")[" + matches +"]", + matches_array[matches], + regexp.exec(pattern)[matches] ); + } +*/ +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/RegExp/function-001.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/RegExp/function-001.js new file mode 100644 index 0000000..67c4f21 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/RegExp/function-001.js @@ -0,0 +1,66 @@ +/** + * File Name: RegExp/function-001.js + * ECMA Section: 15.7.2.1 + * Description: Based on ECMA 2 Draft 7 February 1999 + * + * Author: christine@netscape.com + * Date: 19 February 1999 + */ + var SECTION = "RegExp/function-001"; + var VERSION = "ECMA_2"; + var TITLE = "RegExp( pattern, flags )"; + + startTest(); + + /* + * for each test case, verify: + * - verify that [[Class]] property is RegExp + * - prototype property should be set to RegExp.prototype + * - source is set to the empty string + * - global property is set to false + * - ignoreCase property is set to false + * - multiline property is set to false + * - lastIndex property is set to 0 + */ + + RegExp.prototype.getClassProperty = Object.prototype.toString; + var re = new RegExp(); + + AddTestCase( + "new RegExp().__proto__", + RegExp.prototype, + re.__proto__ + ); + + AddTestCase( + "RegExp.prototype.getClassProperty = Object.prototype.toString; " + + "(new RegExp()).getClassProperty()", + "[object RegExp]", + re.getClassProperty() ); + + AddTestCase( + "(new RegExp()).source", + "", + re.source ); + + AddTestCase( + "(new RegExp()).global", + false, + re.global ); + + AddTestCase( + "(new RegExp()).ignoreCase", + false, + re.ignoreCase ); + + AddTestCase( + "(new RegExp()).multiline", + false, + re.multiline ); + + AddTestCase( + "(new RegExp()).lastIndex", + 0, + re.lastIndex ); + + test() diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/RegExp/hex-001.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/RegExp/hex-001.js new file mode 100644 index 0000000..122d59c --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/RegExp/hex-001.js @@ -0,0 +1,63 @@ +/** + * File Name: RegExp/hex-001.js + * ECMA Section: 15.7.3.1 + * Description: Based on ECMA 2 Draft 7 February 1999 + * Positive test cases for constructing a RegExp object + * Author: christine@netscape.com + * Date: 19 February 1999 + */ + var SECTION = "RegExp/hex-001"; + var VERSION = "ECMA_2"; + var TITLE = "RegExp patterns that contain HexicdecimalEscapeSequences"; + + startTest(); + + // These examples come from 15.7.1, HexidecimalEscapeSequence + + AddRegExpCases( new RegExp("\x41"), "new RegExp('\\x41')", "A", "A", 1, 0, ["A"] ); + AddRegExpCases( new RegExp("\x412"),"new RegExp('\\x412')", "A2", "A2", 1, 0, ["A2"] ); + AddRegExpCases( new RegExp("\x1g"), "new RegExp('\\x1g')", "x1g","x1g", 1, 0, ["x1g"] ); + + AddRegExpCases( new RegExp("A"), "new RegExp('A')", "\x41", "\\x41", 1, 0, ["A"] ); + AddRegExpCases( new RegExp("A"), "new RegExp('A')", "\x412", "\\x412", 1, 0, ["A"] ); + AddRegExpCases( new RegExp("^x"), "new RegExp('^x')", "x412", "x412", 1, 0, ["x"]); + AddRegExpCases( new RegExp("A"), "new RegExp('A')", "A2", "A2", 1, 0, ["A"] ); + + test(); + +function AddRegExpCases( + regexp, str_regexp, pattern, str_pattern, length, index, matches_array ) { + + // prevent a runtime error + + if ( regexp.exec(pattern) == null || matches_array == null ) { + AddTestCase( + str_regexp + ".exec(" + pattern +")", + matches_array, + regexp.exec(pattern) ); + + return; + } + + AddTestCase( + str_regexp + ".exec(" + str_pattern +").length", + length, + regexp.exec(pattern).length ); + + AddTestCase( + str_regexp + ".exec(" + str_pattern +").index", + index, + regexp.exec(pattern).index ); + + AddTestCase( + str_regexp + ".exec(" + str_pattern +").input", + pattern, + regexp.exec(pattern).input ); + + for ( var matches = 0; matches < matches_array.length; matches++ ) { + AddTestCase( + str_regexp + ".exec(" + str_pattern +")[" + matches +"]", + matches_array[matches], + regexp.exec(pattern)[matches] ); + } +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/RegExp/multiline-001.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/RegExp/multiline-001.js new file mode 100644 index 0000000..51a601c --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/RegExp/multiline-001.js @@ -0,0 +1,62 @@ +/** + * File Name: RegExp/multiline-001.js + * ECMA Section: + * Description: Based on ECMA 2 Draft 7 February 1999 + * + * Date: 19 February 1999 + */ + + var SECTION = "RegExp/multiline-001"; + var VERSION = "ECMA_2"; + var TITLE = "RegExp: multiline flag"; + var BUGNUMBER="343901"; + + startTest(); + + var woodpeckers = "ivory-billed\ndowny\nhairy\nacorn\nyellow-bellied sapsucker\n" + + "northern flicker\npileated\n"; + + AddRegExpCases( /.*[y]$/m, woodpeckers, woodpeckers.indexOf("downy"), ["downy"] ); + + AddRegExpCases( /.*[d]$/m, woodpeckers, woodpeckers.indexOf("ivory-billed"), ["ivory-billed"] ); + + test(); + + +function AddRegExpCases + ( regexp, pattern, index, matches_array ) { + + // prevent a runtime error + + if ( regexp.exec(pattern) == null || matches_array == null ) { + AddTestCase( + regexp + ".exec(" + pattern +")", + matches_array, + regexp.exec(pattern) ); + + return; + } + + AddTestCase( + regexp.toString() + ".exec(" + pattern +").length", + matches_array.length, + regexp.exec(pattern).length ); + + AddTestCase( + regexp.toString() + ".exec(" + pattern +").index", + index, + regexp.exec(pattern).index ); + + AddTestCase( + regexp + ".exec(" + pattern +").input", + pattern, + regexp.exec(pattern).input ); + + + for ( var matches = 0; matches < matches_array.length; matches++ ) { + AddTestCase( + regexp + ".exec(" + pattern +")[" + matches +"]", + matches_array[matches], + regexp.exec(pattern)[matches] ); + } +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/RegExp/octal-001.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/RegExp/octal-001.js new file mode 100644 index 0000000..d9d0571 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/RegExp/octal-001.js @@ -0,0 +1,72 @@ +/** + * File Name: RegExp/octal-001.js + * ECMA Section: 15.7.1 + * Description: Based on ECMA 2 Draft 7 February 1999 + * Simple test cases for matching OctalEscapeSequences. + * Author: christine@netscape.com + * Date: 19 February 1999 + */ + var SECTION = "RegExp/octal-001.js"; + var VERSION = "ECMA_2"; + var TITLE = "RegExp patterns that contain OctalEscapeSequences"; + var BUGNUMBER="http://scopus/bugsplat/show_bug.cgi?id=346196"; + + startTest(); + + +// backreference + AddRegExpCases( + /(.)\1/, + "/(.)\\1/", + "HI!!", + "HI!", + 2, + ["!!", "!"] ); + + test(); + +function AddRegExpCases( + regexp, str_regexp, pattern, str_pattern, index, matches_array ) { + + // prevent a runtime error + + if ( regexp.exec(pattern) == null || matches_array == null ) { + AddTestCase( + regexp + ".exec(" + str_pattern +")", + matches_array, + regexp.exec(pattern) ); + + return; + } + AddTestCase( + str_regexp + ".exec(" + str_pattern +").length", + matches_array.length, + regexp.exec(pattern).length ); + + AddTestCase( + str_regexp + ".exec(" + str_pattern +").index", + index, + regexp.exec(pattern).index ); + + AddTestCase( + str_regexp + ".exec(" + str_pattern +").input", + pattern, + regexp.exec(pattern).input ); + + AddTestCase( + str_regexp + ".exec(" + str_pattern +").toString()", + matches_array.toString(), + regexp.exec(pattern).toString() ); +/* + var limit = matches_array.length > regexp.exec(pattern).length + ? matches_array.length + : regexp.exec(pattern).length; + + for ( var matches = 0; matches < limit; matches++ ) { + AddTestCase( + str_regexp + ".exec(" + str_pattern +")[" + matches +"]", + matches_array[matches], + regexp.exec(pattern)[matches] ); + } +*/ +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/RegExp/octal-002.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/RegExp/octal-002.js new file mode 100644 index 0000000..69c8100 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/RegExp/octal-002.js @@ -0,0 +1,87 @@ +/** + * File Name: RegExp/octal-002.js + * ECMA Section: 15.7.1 + * Description: Based on ECMA 2 Draft 7 February 1999 + * Simple test cases for matching OctalEscapeSequences. + * Author: christine@netscape.com + * Date: 19 February 1999 + */ + var SECTION = "RegExp/octal-002.js"; + var VERSION = "ECMA_2"; + var TITLE = "RegExp patterns that contain OctalEscapeSequences"; + var BUGNUMBER="http://scopus/bugsplat/show_bug.cgi?id=346189"; + + startTest(); + +// backreference + AddRegExpCases( + /(.)(.)(.)(.)(.)(.)(.)(.)\8/, + "/(.)(.)(.)(.)(.)(.)(.)(.)\\8", + "aabbccaaabbbccc", + "aabbccaaabbbccc", + 0, + ["aabbccaaa", "a", "a", "b", "b", "c", "c", "a", "a"] ); + + AddRegExpCases( + /(.)(.)(.)(.)(.)(.)(.)(.)(.)\9/, + "/(.)(.)(.)(.)(.)(.)(.)(.)\\9", + "aabbccaabbcc", + "aabbccaabbcc", + 0, + ["aabbccaabb", "a", "a", "b", "b", "c", "c", "a", "a", "b"] ); + + AddRegExpCases( + /(.)(.)(.)(.)(.)(.)(.)(.)(.)\8/, + "/(.)(.)(.)(.)(.)(.)(.)(.)(.)\\8", + "aabbccaababcc", + "aabbccaababcc", + 0, + ["aabbccaaba", "a", "a", "b", "b", "c", "c", "a", "a", "b"] ); + + test(); + +function AddRegExpCases( + regexp, str_regexp, pattern, str_pattern, index, matches_array ) { + + // prevent a runtime error + + if ( regexp.exec(pattern) == null || matches_array == null ) { + AddTestCase( + regexp + ".exec(" + str_pattern +")", + matches_array, + regexp.exec(pattern) ); + + return; + } + AddTestCase( + str_regexp + ".exec(" + str_pattern +").length", + matches_array.length, + regexp.exec(pattern).length ); + + AddTestCase( + str_regexp + ".exec(" + str_pattern +").index", + index, + regexp.exec(pattern).index ); + + AddTestCase( + str_regexp + ".exec(" + str_pattern +").input", + pattern, + regexp.exec(pattern).input ); + + AddTestCase( + str_regexp + ".exec(" + str_pattern +").toString()", + matches_array.toString(), + regexp.exec(pattern).toString() ); +/* + var limit = matches_array.length > regexp.exec(pattern).length + ? matches_array.length + : regexp.exec(pattern).length; + + for ( var matches = 0; matches < limit; matches++ ) { + AddTestCase( + str_regexp + ".exec(" + str_pattern +")[" + matches +"]", + matches_array[matches], + regexp.exec(pattern)[matches] ); + } +*/ +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/RegExp/octal-003.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/RegExp/octal-003.js new file mode 100644 index 0000000..ac6de01 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/RegExp/octal-003.js @@ -0,0 +1,81 @@ +/** + * File Name: RegExp/octal-003.js + * ECMA Section: 15.7.1 + * Description: Based on ECMA 2 Draft 7 February 1999 + * Simple test cases for matching OctalEscapeSequences. + * Author: christine@netscape.com + * Date: 19 February 1999 + * + * Revised: 02 August 2002 + * Author: pschwartau@netscape.com + * + * WHY: the original test expected the regexp /.\011/ + * to match 'a' + String.fromCharCode(0) + '11' + * + * This is incorrect: the string is a 4-character string consisting of + * the characters <'a'>, <nul>, <'1'>, <'1'>. By contrast, the \011 in the + * regexp should be parsed as a single token: it is the octal escape sequence + * for the horizontal tab character '\t' === '\u0009' === '\x09' === '\011'. + * + * So the regexp consists of 2 characters: <any-character>, <'\t'>. + * There is no match between the regexp and the string. + * + * See the testcase ecma_3/RegExp/octal-002.js for an elaboration. + * + */ + var SECTION = "RegExp/octal-003.js"; + var VERSION = "ECMA_2"; + var TITLE = "RegExp patterns that contain OctalEscapeSequences"; + var BUGNUMBER="http://scopus/bugsplat/show_bug.cgi?id=346132"; + + startTest(); + + AddRegExpCases( /.\011/, "/\\011/", "a" + String.fromCharCode(0) + "11", "a\\011", 0, null ); + + test(); + +function AddRegExpCases( + regexp, str_regexp, pattern, str_pattern, index, matches_array ) { + + // prevent a runtime error + + if ( regexp.exec(pattern) == null || matches_array == null ) { + AddTestCase( + regexp + ".exec(" + str_pattern +")", + matches_array, + regexp.exec(pattern) ); + + return; + } + AddTestCase( + str_regexp + ".exec(" + str_pattern +").length", + matches_array.length, + regexp.exec(pattern).length ); + + AddTestCase( + str_regexp + ".exec(" + str_pattern +").index", + index, + regexp.exec(pattern).index ); + + AddTestCase( + str_regexp + ".exec(" + str_pattern +").input", + escape(pattern), + escape(regexp.exec(pattern).input) ); + + AddTestCase( + str_regexp + ".exec(" + str_pattern +").toString()", + matches_array.toString(), + escape(regexp.exec(pattern).toString()) ); + + var limit = matches_array.length > regexp.exec(pattern).length + ? matches_array.length + : regexp.exec(pattern).length; + + for ( var matches = 0; matches < limit; matches++ ) { + AddTestCase( + str_regexp + ".exec(" + str_pattern +")[" + matches +"]", + matches_array[matches], + escape(regexp.exec(pattern)[matches]) ); + } + +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/RegExp/properties-001.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/RegExp/properties-001.js new file mode 100644 index 0000000..3eb51cb --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/RegExp/properties-001.js @@ -0,0 +1,85 @@ +/** + * File Name: RegExp/properties-001.js + * ECMA Section: 15.7.6.js + * Description: Based on ECMA 2 Draft 7 February 1999 + * + * Author: christine@netscape.com + * Date: 19 February 1999 + */ + var SECTION = "RegExp/properties-001.js"; + var VERSION = "ECMA_2"; + var TITLE = "Properties of RegExp Instances"; + var BUGNUMBER ="http://scopus/bugsplat/show_bug.cgi?id=346000"; + + startTest(); + + AddRegExpCases( new RegExp, "", false, false, false, 0 ); + AddRegExpCases( /.*/, ".*", false, false, false, 0 ); + AddRegExpCases( /[\d]{5}/g, "[\\d]{5}", true, false, false, 0 ); + AddRegExpCases( /[\S]?$/i, "[\\S]?$", false, true, false, 0 ); + AddRegExpCases( /^([a-z]*)[^\w\s\f\n\r]+/m, "^([a-z]*)[^\\w\\s\\f\\n\\r]+", false, false, true, 0 ); + AddRegExpCases( /[\D]{1,5}[\ -][\d]/gi, "[\\D]{1,5}[\\ -][\\d]", true, true, false, 0 ); + AddRegExpCases( /[a-zA-Z0-9]*/gm, "[a-zA-Z0-9]*", true, false, true, 0 ); + AddRegExpCases( /x|y|z/gim, "x|y|z", true, true, true, 0 ); + + AddRegExpCases( /\u0051/im, "\\u0051", false, true, true, 0 ); + AddRegExpCases( /\x45/gm, "\\x45", true, false, true, 0 ); + AddRegExpCases( /\097/gi, "\\097", true, true, false, 0 ); + + test(); + +function AddRegExpCases( re, s, g, i, m, l ) { + + AddTestCase( re + ".test == RegExp.prototype.test", + true, + re.test == RegExp.prototype.test ); + + AddTestCase( re + ".toString == RegExp.prototype.toString", + true, + re.toString == RegExp.prototype.toString ); + + AddTestCase( re + ".contructor == RegExp.prototype.constructor", + true, + re.constructor == RegExp.prototype.constructor ); + + AddTestCase( re + ".compile == RegExp.prototype.compile", + true, + re.compile == RegExp.prototype.compile ); + + AddTestCase( re + ".exec == RegExp.prototype.exec", + true, + re.exec == RegExp.prototype.exec ); + + // properties + + AddTestCase( re + ".source", + s, + re.source ); + +/* + * http://bugzilla.mozilla.org/show_bug.cgi?id=225550 changed + * the behavior of toString() and toSource() on empty regexps. + * So branch if |s| is the empty string - + */ + var S = s? s : '(?:)'; + + AddTestCase( re + ".toString()", + "/" + S +"/" + (g?"g":"") + (i?"i":"") +(m?"m":""), + re.toString() ); + + AddTestCase( re + ".global", + g, + re.global ); + + AddTestCase( re + ".ignoreCase", + i, + re.ignoreCase ); + + AddTestCase( re + ".multiline", + m, + re.multiline); + + AddTestCase( re + ".lastIndex", + l, + re.lastIndex ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/RegExp/properties-002.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/RegExp/properties-002.js new file mode 100644 index 0000000..2496d5f --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/RegExp/properties-002.js @@ -0,0 +1,125 @@ +/** + * File Name: RegExp/properties-002.js + * ECMA Section: 15.7.6.js + * Description: Based on ECMA 2 Draft 7 February 1999 + * + * Author: christine@netscape.com + * Date: 19 February 1999 + */ + //----------------------------------------------------------------------------- +var SECTION = "RegExp/properties-002.js"; +var VERSION = "ECMA_2"; +var TITLE = "Properties of RegExp Instances"; +var BUGNUMBER ="http://scopus/bugsplat/show_bug.cgi?id=346032"; +// ALSO SEE http://bugzilla.mozilla.org/show_bug.cgi?id=124339 + + +startTest(); + +re_1 = /\cA?/g; +re_1.lastIndex = Math.pow(2,31); +AddRegExpCases( re_1, "\\cA?", true, false, false, Math.pow(2,31) ); + +re_2 = /\w*/i; +re_2.lastIndex = Math.pow(2,32) -1; +AddRegExpCases( re_2, "\\w*", false, true, false, Math.pow(2,32)-1 ); + +re_3 = /\*{0,80}/m; +re_3.lastIndex = Math.pow(2,31) -1; +AddRegExpCases( re_3, "\\*{0,80}", false, false, true, Math.pow(2,31) -1 ); + +re_4 = /^./gim; +re_4.lastIndex = Math.pow(2,30) -1; +AddRegExpCases( re_4, "^.", true, true, true, Math.pow(2,30) -1 ); + +re_5 = /\B/; +re_5.lastIndex = Math.pow(2,30); +AddRegExpCases( re_5, "\\B", false, false, false, Math.pow(2,30) ); + +/* + * Brendan: "need to test cases Math.pow(2,32) and greater to see + * whether they round-trip." Reason: thanks to the work done in + * http://bugzilla.mozilla.org/show_bug.cgi?id=124339, lastIndex + * is now stored as a double instead of a uint32 (unsigned integer). + * + * Note 2^32 -1 is the upper bound for uint32's, but doubles can go + * all the way up to Number.MAX_VALUE. So that's why we need cases + * between those two numbers. + * + */ +re_6 = /\B/; +re_6.lastIndex = Math.pow(2,32); +AddRegExpCases( re_6, "\\B", false, false, false, Math.pow(2,32) ); + +re_7 = /\B/; +re_7.lastIndex = Math.pow(2,32) + 1; +AddRegExpCases( re_7, "\\B", false, false, false, Math.pow(2,32) + 1 ); + +re_8 = /\B/; +re_8.lastIndex = Math.pow(2,32) * 2; +AddRegExpCases( re_8, "\\B", false, false, false, Math.pow(2,32) * 2 ); + +re_9 = /\B/; +re_9.lastIndex = Math.pow(2,40); +AddRegExpCases( re_9, "\\B", false, false, false, Math.pow(2,40) ); + +re_10 = /\B/; +re_10.lastIndex = Number.MAX_VALUE; +AddRegExpCases( re_10, "\\B", false, false, false, Number.MAX_VALUE ); + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + + +function AddRegExpCases( re, s, g, i, m, l ){ + + AddTestCase( re + ".test == RegExp.prototype.test", + true, + re.test == RegExp.prototype.test ); + + AddTestCase( re + ".toString == RegExp.prototype.toString", + true, + re.toString == RegExp.prototype.toString ); + + AddTestCase( re + ".contructor == RegExp.prototype.constructor", + true, + re.constructor == RegExp.prototype.constructor ); + + AddTestCase( re + ".compile == RegExp.prototype.compile", + true, + re.compile == RegExp.prototype.compile ); + + AddTestCase( re + ".exec == RegExp.prototype.exec", + true, + re.exec == RegExp.prototype.exec ); + + // properties + + AddTestCase( re + ".source", + s, + re.source ); + + AddTestCase( re + ".toString()", + "/" + s +"/" + (g?"g":"") + (i?"i":"") +(m?"m":""), + re.toString() ); + + AddTestCase( re + ".global", + g, + re.global ); + + AddTestCase( re + ".ignoreCase", + i, + re.ignoreCase ); + + AddTestCase( re + ".multiline", + m, + re.multiline); + + AddTestCase( re + ".lastIndex", + l, + re.lastIndex ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/RegExp/regexp-enumerate-001.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/RegExp/regexp-enumerate-001.js new file mode 100644 index 0000000..9752fa1 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/RegExp/regexp-enumerate-001.js @@ -0,0 +1,98 @@ +/** + File Name: regexp-enumerate-001.js + ECMA V2 Section: + Description: Regression Test. + + If instance Native Object have properties that are enumerable, + JavaScript enumerated through the properties twice. This only + happened if objects had been instantiated, but their properties + had not been enumerated. ie, the object inherited properties + from its prototype that are enumerated. + + In the core JavaScript, this is only a problem with RegExp + objects, since the inherited properties of most core JavaScript + objects are not enumerated. + + Author: christine@netscape.com, pschwartau@netscape.com + Date: 12 November 1997 + Modified: 14 July 2002 + Reason: See http://bugzilla.mozilla.org/show_bug.cgi?id=155291 + ECMA-262 Ed.3 Sections 15.10.7.1 through 15.10.7.5 + RegExp properties should be DontEnum +* +*/ +// onerror = err; + + var SECTION = "regexp-enumerate-001"; + var VERSION = "ECMA_2"; + var TITLE = "Regression Test for Enumerating Properties"; + + var BUGNUMBER="339403"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + /* + * This test expects RegExp instances to have four enumerated properties: + * source, global, ignoreCase, and lastIndex + * + * 99.01.25: now they also have a multiLine instance property. + * + */ + + + var r = new RegExp(); + + var e = new Array(); + + var t = new TestRegExp(); + + for ( p in r ) { e[e.length] = { property:p, value:r[p] }; t.addProperty( p, r[p]) }; + + testcases[testcases.length] = new TestCase( SECTION, + "r = new RegExp(); e = new Array(); "+ + "for ( p in r ) { e[e.length] = { property:p, value:r[p] }; e.length", + 0, + e.length ); + + test(); + +function TestRegExp() { + this.addProperty = addProperty; +} +function addProperty(name, value) { + var pass = false; + + if ( eval("this."+name) != void 0 ) { + pass = true; + } else { + eval( "this."+ name+" = "+ false ); + } + + testcases[testcases.length] = new TestCase( SECTION, + "Property: " + name +" already enumerated?", + false, + pass ); + + if ( testcases[ testcases.length-1].passed == false ) { + testcases[testcases.length-1].reason = "property already enumerated"; + + } + +} +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/RegExp/regress-001.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/RegExp/regress-001.js new file mode 100644 index 0000000..afd45fe --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/RegExp/regress-001.js @@ -0,0 +1,39 @@ +/** + * File Name: RegExp/regress-001.js + * ECMA Section: N/A + * Description: Regression test case: + * JS regexp anchoring on empty match bug + * http://bugzilla.mozilla.org/show_bug.cgi?id=2157 + * + * Author: christine@netscape.com + * Date: 19 February 1999 + */ + var SECTION = "RegExp/hex-001.js"; + var VERSION = "ECMA_2"; + var TITLE = "JS regexp anchoring on empty match bug"; + var BUGNUMBER = "http://bugzilla.mozilla.org/show_bug.cgi?id=2157"; + + startTest(); + + AddRegExpCases( /a||b/(''), + "//a||b/('')", + 1, + [''] ); + + test(); + +function AddRegExpCases( regexp, str_regexp, length, matches_array ) { + + AddTestCase( + "( " + str_regexp + " ).length", + regexp.length, + regexp.length ); + + + for ( var matches = 0; matches < matches_array.length; matches++ ) { + AddTestCase( + "( " + str_regexp + " )[" + matches +"]", + matches_array[matches], + regexp[matches] ); + } +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/RegExp/unicode-001.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/RegExp/unicode-001.js new file mode 100644 index 0000000..17d0582 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/RegExp/unicode-001.js @@ -0,0 +1,53 @@ +/** + * File Name: RegExp/unicode-001.js + * ECMA Section: 15.7.3.1 + * Description: Based on ECMA 2 Draft 7 February 1999 + * Positive test cases for constructing a RegExp object + * Author: christine@netscape.com + * Date: 19 February 1999 + */ + var SECTION = "RegExp/unicode-001.js"; + var VERSION = "ECMA_2"; + var TITLE = "new RegExp( pattern, flags )"; + + startTest(); + + // These examples come from 15.7.1, UnicodeEscapeSequence + + AddRegExpCases( /\u0041/, "/\\u0041/", "A", "A", 1, 0, ["A"] ); + AddRegExpCases( /\u00412/, "/\\u00412/", "A2", "A2", 1, 0, ["A2"] ); + AddRegExpCases( /\u00412/, "/\\u00412/", "A2", "A2", 1, 0, ["A2"] ); + AddRegExpCases( /\u001g/, "/\\u001g/", "u001g", "u001g", 1, 0, ["u001g"] ); + + AddRegExpCases( /A/, "/A/", "\u0041", "\\u0041", 1, 0, ["A"] ); + AddRegExpCases( /A/, "/A/", "\u00412", "\\u00412", 1, 0, ["A"] ); + AddRegExpCases( /A2/, "/A2/", "\u00412", "\\u00412", 1, 0, ["A2"]); + AddRegExpCases( /A/, "/A/", "A2", "A2", 1, 0, ["A"] ); + + test(); + +function AddRegExpCases( + regexp, str_regexp, pattern, str_pattern, length, index, matches_array ) { + + AddTestCase( + str_regexp + " .exec(" + str_pattern +").length", + length, + regexp.exec(pattern).length ); + + AddTestCase( + str_regexp + " .exec(" + str_pattern +").index", + index, + regexp.exec(pattern).index ); + + AddTestCase( + str_regexp + " .exec(" + str_pattern +").input", + pattern, + regexp.exec(pattern).input ); + + for ( var matches = 0; matches < matches_array.length; matches++ ) { + AddTestCase( + str_regexp + " .exec(" + str_pattern +")[" + matches +"]", + matches_array[matches], + regexp.exec(pattern)[matches] ); + } +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/dowhile-001.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/dowhile-001.js new file mode 100644 index 0000000..ffd5300 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/dowhile-001.js @@ -0,0 +1,41 @@ +/** + * File Name: dowhile-001 + * ECMA Section: + * Description: do...while statements + * + * + * + * Author: christine@netscape.com + * Date: 11 August 1998 + */ + var SECTION = "dowhile-002"; + var VERSION = "ECMA_2"; + var TITLE = "do...while with a labeled continue statement"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + LabeledContinue( 0, 1 ); + LabeledContinue( 1, 1 ); + LabeledContinue( -1, 1 ); + LabeledContinue( 5, 5 ); + + test(); + +function LabeledContinue( limit, expect ) { + i = 0; + woohoo: + do { + i++; + continue woohoo; + } while ( i < limit ); + + testcases[tc++] = new TestCase( + SECTION, + "do while ( " + i +" < " + limit +" )", + expect, + i ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/dowhile-002.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/dowhile-002.js new file mode 100644 index 0000000..e921b49 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/dowhile-002.js @@ -0,0 +1,68 @@ +/** + * File Name: dowhile-002 + * ECMA Section: + * Description: do...while statements + * + * Verify that code after a labeled break is not executed. Verify that + * a labeled break breaks you out of the whole labeled block, and not + * just the current iteration statement. + * + * Author: christine@netscape.com + * Date: 11 August 1998 + */ + var SECTION = "dowhile-002"; + var VERSION = "ECMA_2"; + var TITLE = "do...while with a labeled continue statement"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + LabeledContinue( 0, 1 ); + LabeledContinue( 1, 1 ); + LabeledContinue( -1, 1 ); + LabeledContinue( 5, 5 ); + + test(); + +// The labeled statment contains statements after the labeled break. +// Verify that the statements after the break are not executed. + +function LabeledContinue( limit, expect ) { + i = 0; + result1 = "pass"; + result2 = "pass"; + + woohoo: { + do { + i++; + if ( ! (i < limit) ) { + break woohoo; + result1 = "fail: evaluated statement after a labeled break"; + } + } while ( true ); + + result2 = "failed: broke out of loop, but not out of labeled block"; + } + + testcases[tc++] = new TestCase( + SECTION, + "do while ( " + i +" < " + limit +" )", + expect, + i ); + + testcases[tc++] = new TestCase( + SECTION, + "breaking out of a do... while loop", + "pass", + result1 ); + + + testcases[tc++] = new TestCase( + SECTION, + "breaking out of a labeled do...while loop", + "pass", + result2 ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/dowhile-003.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/dowhile-003.js new file mode 100644 index 0000000..a1ca517 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/dowhile-003.js @@ -0,0 +1,60 @@ +/** + * File Name: dowhile-003 + * ECMA Section: + * Description: do...while statements + * + * Test do while, when the while expression is a JavaScript Number object. + * + * + * Author: christine@netscape.com + * Date: 11 August 1998 + */ + var SECTION = "dowhile-003"; + var VERSION = "ECMA_2"; + var TITLE = "do...while with a labeled continue statement"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + DoWhile( new DoWhileObject( 1, 1, 0 )); + DoWhile( new DoWhileObject( 1000, 1000, 0 )); + DoWhile( new DoWhileObject( 1001, 1001, 0 )); + DoWhile( new DoWhileObject( 1002, 1001, 1 )); + DoWhile( new DoWhileObject( -1, 1001, -1002 )); + + test(); + +function DoWhileObject( value, iterations, endvalue ) { + this.value = value; + this.iterations = iterations; + this.endvalue = endvalue; +} + +function DoWhile( object ) { + var i = 0; + + do { + object.value = --object.value; + i++; + if ( i > 1000 ) + break; + } while( object.value ); + + testcases[tc++] = new TestCase( + SECTION, + "loop iterations", + object.iterations, + i + ); + + testcases[tc++] = new TestCase( + SECTION, + "object.value", + object.endvalue, + Number( object.value ) + ); + +}
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/dowhile-004.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/dowhile-004.js new file mode 100644 index 0000000..3c96fc4 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/dowhile-004.js @@ -0,0 +1,64 @@ +/** + * File Name: dowhile-004 + * ECMA Section: + * Description: do...while statements + * + * Test a labeled do...while. Break out of the loop with no label + * should break out of the loop, but not out of the label. + * + * Author: christine@netscape.com + * Date: 11 August 1998 + */ + var SECTION = "dowhile-004"; + var VERSION = "ECMA_2"; + var TITLE = "do...while with a labeled continue statement"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + DoWhile( 0, 1 ); + DoWhile( 1, 1 ); + DoWhile( -1, 1 ); + DoWhile( 5, 5 ); + + test(); + +function DoWhile( limit, expect ) { + i = 0; + result1 = "pass"; + result2 = "failed: broke out of labeled statement unexpectedly"; + + foo: { + do { + i++; + if ( ! (i < limit) ) { + break; + result1 = "fail: evaluated statement after a labeled break"; + } + } while ( true ); + + result2 = "pass"; + } + + testcases[tc++] = new TestCase( + SECTION, + "do while ( " + i +" < " + limit +" )", + expect, + i ); + + testcases[tc++] = new TestCase( + SECTION, + "breaking out of a do... while loop", + "pass", + result1 ); + + + testcases[tc++] = new TestCase( + SECTION, + "breaking out of a labeled do...while loop", + "pass", + result2 ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/dowhile-005.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/dowhile-005.js new file mode 100644 index 0000000..ce56cb9 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/dowhile-005.js @@ -0,0 +1,70 @@ +/** + * File Name: dowhile-005 + * ECMA Section: + * Description: do...while statements + * + * Test a labeled do...while. Break out of the loop with no label + * should break out of the loop, but not out of the label. + * + * Currently causes an infinite loop in the monkey. Uncomment the + * print statement below and it works OK. + * + * Author: christine@netscape.com + * Date: 26 August 1998 + */ + var SECTION = "dowhile-005"; + var VERSION = "ECMA_2"; + var TITLE = "do...while with a labeled continue statement"; + var BUGNUMBER = "316293"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + NestedLabel(); + + + test(); + + function NestedLabel() { + i = 0; + result1 = "pass"; + result2 = "fail: did not hit code after inner loop"; + result3 = "pass"; + + outer: { + do { + inner: { +// print( i ); + break inner; + result1 = "fail: did break out of inner label"; + } + result2 = "pass"; + break outer; + print (i); + } while ( i++ < 100 ); + + } + + result3 = "fail: did not break out of outer label"; + + testcases[tc++] = new TestCase( + SECTION, + "number of loop iterations", + 0, + i ); + + testcases[tc++] = new TestCase( + SECTION, + "break out of inner loop", + "pass", + result1 ); + + testcases[tc++] = new TestCase( + SECTION, + "break out of outer loop", + "pass", + result2 ); + }
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/dowhile-006.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/dowhile-006.js new file mode 100644 index 0000000..67dce64 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/dowhile-006.js @@ -0,0 +1,86 @@ +/** + * File Name: dowhile-006 + * ECMA Section: + * Description: do...while statements + * + * A general do...while test. + * + * Author: christine@netscape.com + * Date: 26 August 1998 + */ + var SECTION = "dowhile-006"; + var VERSION = "ECMA_2"; + var TITLE = "do...while"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + DoWhile( new DoWhileObject( false, false, 10 ) ); + DoWhile( new DoWhileObject( true, false, 2 ) ); + DoWhile( new DoWhileObject( false, true, 3 ) ); + DoWhile( new DoWhileObject( true, true, 4 ) ); + + test(); + +function looping( object ) { + object.iterations--; + + if ( object.iterations <= 0 ) { + return false; + } else { + return true; + } +} +function DoWhileObject( breakOut, breakIn, iterations, loops ) { + this.iterations = iterations; + this.loops = loops; + this.breakOut = breakOut; + this.breakIn = breakIn; + this.looping = looping; +} +function DoWhile( object ) { + var result1 = false; + var result2 = false; + + outie: { + innie: { + do { + if ( object.breakOut ) + break outie; + + if ( object.breakIn ) + break innie; + + } while ( looping(object) ); + + // statements should be executed if: + // do...while exits normally + // do...while exits abruptly with no label + + result1 = true; + + } + + // statements should be executed if: + // do...while breaks out with label "innie" + // do...while exits normally + // do...while does not break out with "outie" + + result2 = true; + } + + testcases[tc++] = new TestCase( + SECTION, + "hit code after loop in inner loop", + ( object.breakIn || object.breakOut ) ? false : true , + result1 ); + + testcases[tc++] = new TestCase( + SECTION, + "hit code after loop in outer loop", + ( object.breakOut ) ? false : true, + result2 ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/dowhile-007.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/dowhile-007.js new file mode 100644 index 0000000..849e70e --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/dowhile-007.js @@ -0,0 +1,94 @@ +/** + * File Name: dowhile-007 + * ECMA Section: + * Description: do...while statements + * + * A general do...while test. + * + * Author: christine@netscape.com + * Date: 26 August 1998 + */ + var SECTION = "dowhile-007"; + var VERSION = "ECMA_2"; + var TITLE = "do...while"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + DoWhile( new DoWhileObject( false, false, false, false )); + DoWhile( new DoWhileObject( true, false, false, false )); + DoWhile( new DoWhileObject( true, true, false, false )); + DoWhile( new DoWhileObject( true, true, true, false )); + DoWhile( new DoWhileObject( true, true, true, true )); + DoWhile( new DoWhileObject( false, false, false, true )); + DoWhile( new DoWhileObject( false, false, true, true )); + DoWhile( new DoWhileObject( false, true, true, true )); + DoWhile( new DoWhileObject( false, false, true, false )); + + test(); + +function DoWhileObject( out1, out2, out3, in1 ) { + this.breakOutOne = out1; + this.breakOutTwo = out2; + this.breakOutThree = out3; + this.breakIn = in1; +} +function DoWhile( object ) { + result1 = false; + result2 = false; + result3 = false; + result4 = false; + + outie: + do { + if ( object.breakOutOne ) { + break outie; + } + result1 = true; + + innie: + do { + if ( object.breakOutTwo ) { + break outie; + } + result2 = true; + + if ( object.breakIn ) { + break innie; + } + result3 = true; + + } while ( false ); + if ( object.breakOutThree ) { + break outie; + } + result4 = true; + } while ( false ); + + testcases[tc++] = new TestCase( + SECTION, + "break one: ", + (object.breakOutOne) ? false : true, + result1 ); + + testcases[tc++] = new TestCase( + SECTION, + "break two: ", + (object.breakOutOne||object.breakOutTwo) ? false : true, + result2 ); + + testcases[tc++] = new TestCase( + SECTION, + "break three: ", + (object.breakOutOne||object.breakOutTwo||object.breakIn) ? false : true, + result3 ); + + testcases[tc++] = new TestCase( + SECTION, + "break four: ", + (object.breakOutOne||object.breakOutTwo||object.breakOutThree) ? false: true, + result4 ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/forin-001.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/forin-001.js new file mode 100644 index 0000000..63119af --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/forin-001.js @@ -0,0 +1,294 @@ +/** + * File Name: forin-001.js + * ECMA Section: + * Description: The forin-001 statement + * + * Verify that the property name is assigned to the property on the left + * hand side of the for...in expression. + * + * Author: christine@netscape.com + * Date: 28 August 1998 + */ + var SECTION = "forin-001"; + var VERSION = "ECMA_2"; + var TITLE = "The for...in statement"; + var BUGNUMBER="330890"; + var BUGNUMBER="http://scopus.mcom.com/bugsplat/show_bug.cgi?id=344855"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + ForIn_1( { length:4, company:"netscape", year:2000, 0:"zero" } ); + ForIn_2( { length:4, company:"netscape", year:2000, 0:"zero" } ); + ForIn_3( { length:4, company:"netscape", year:2000, 0:"zero" } ); + +// ForIn_6({ length:4, company:"netscape", year:2000, 0:"zero" }); +// ForIn_7({ length:4, company:"netscape", year:2000, 0:"zero" }); + ForIn_8({ length:4, company:"netscape", year:2000, 0:"zero" }); + + test(); + + /** + * Verify that the left side argument is evaluated with every iteration. + * Verify that the name of each property of the object is assigned to a + * a property. + * + */ + function ForIn_1( object ) { + PropertyArray = new Array(); + ValueArray = new Array(); + + for ( PropertyArray[PropertyArray.length] in object ) { + ValueArray[ValueArray.length] = + object[PropertyArray[PropertyArray.length-1]]; + } + + for ( var i = 0; i < PropertyArray.length; i++ ) { + testcases[tc++] = new TestCase( + SECTION, + "object[" + PropertyArray[i] +"]", + object[PropertyArray[i]], + ValueArray[i] + ); + } + + testcases[tc++] = new TestCase( + SECTION, + "object.length", + PropertyArray.length, + object.length ); + } + + /** + * Similar to ForIn_1, except it should increment the counter variable + * every time the left hand expression is evaluated. + */ + function ForIn_2( object ) { + PropertyArray = new Array(); + ValueArray = new Array(); + var i = 0; + + for ( PropertyArray[i++] in object ) { + ValueArray[ValueArray.length] = + object[PropertyArray[PropertyArray.length-1]]; + } + + for ( i = 0; i < PropertyArray.length; i++ ) { + testcases[tc++] = new TestCase( + SECTION, + "object[" + PropertyArray[i] +"]", + object[PropertyArray[i]], + ValueArray[i] + ); + } + + testcases[tc++] = new TestCase( + SECTION, + "object.length", + PropertyArray.length, + object.length ); + } + + /** + * Break out of a for...in loop + * + * + */ + function ForIn_3( object ) { + var checkBreak = "pass"; + var properties = new Array(); + var values = new Array(); + + for ( properties[properties.length] in object ) { + values[values.length] = object[properties[properties.length-1]]; + break; + checkBreak = "fail"; + } + + testcases[tc++] = new TestCase( + SECTION, + "check break out of for...in", + "pass", + checkBreak ); + + testcases[tc++] = new TestCase( + SECTION, + "properties.length", + 1, + properties.length ); + + testcases[tc++] = new TestCase( + SECTION, + "object["+properties[0]+"]", + values[0], + object[properties[0]] ); + } + + /** + * Break out of a labeled for...in loop. + */ + function ForIn_4( object ) { + var result1 = 0; + var result2 = 0; + var result3 = 0; + var result4 = 0; + var i = 0; + var property = new Array(); + + butterbean: { + result1++; + + for ( property[i++] in object ) { + result2++; + break; + result4++; + } + result3++; + } + + testcases[tc++] = new TestCase( + SECTION, + "verify labeled statement is only executed once", + true, + result1 == 1 ); + + testcases[tc++] = new TestCase( + SECTION, + "verify statements in for loop are evaluated", + true, + result2 == i ); + + testcases[tc++] = new TestCase( + SECTION, + "verify break out of labeled for...in loop", + true, + result4 == 0 ); + + testcases[tc++] = new TestCase( + SECTION, + "verify break out of labeled block", + true, + result3 == 0 ); + } + + /** + * Labeled break out of a labeled for...in loop. + */ + function ForIn_5 (object) { + var result1 = 0; + var result2 = 0; + var result3 = 0; + var result4 = 0; + var i = 0; + var property = new Array(); + + bigredbird: { + result1++; + for ( property[i++] in object ) { + result2++; + break bigredbird; + result4++; + } + result3++; + } + + testcases[tc++] = new TestCase( + SECTION, + "verify labeled statement is only executed once", + true, + result1 == 1 ); + + testcases[tc++] = new TestCase( + SECTION, + "verify statements in for loop are evaluated", + true, + result2 == i ); + + testcases[tc++] = new TestCase( + SECTION, + "verify break out of labeled for...in loop", + true, + result4 == 0 ); + + testcases[tc++] = new TestCase( + SECTION, + "verify break out of labeled block", + true, + result3 == 0 ); + } + + /** + * Labeled continue from a labeled for...in loop + */ + function ForIn_7( object ) { + var result1 = 0; + var result2 = 0; + var result3 = 0; + var result4 = 0; + var i = 0; + var property = new Array(); + + bigredbird: + for ( property[i++] in object ) { + result2++; + continue bigredbird; + result4++; + } + + testcases[tc++] = new TestCase( + SECTION, + "verify statements in for loop are evaluated", + true, + result2 == i ); + + testcases[tc++] = new TestCase( + SECTION, + "verify break out of labeled for...in loop", + true, + result4 == 0 ); + + testcases[tc++] = new TestCase( + SECTION, + "verify break out of labeled block", + true, + result3 == 1 ); + } + + + /** + * continue in a for...in loop + * + */ + function ForIn_8( object ) { + var checkBreak = "pass"; + var properties = new Array(); + var values = new Array(); + + for ( properties[properties.length] in object ) { + values[values.length] = object[properties[properties.length-1]]; + break; + checkBreak = "fail"; + } + + testcases[tc++] = new TestCase( + SECTION, + "check break out of for...in", + "pass", + checkBreak ); + + testcases[tc++] = new TestCase( + SECTION, + "properties.length", + 1, + properties.length ); + + testcases[tc++] = new TestCase( + SECTION, + "object["+properties[0]+"]", + values[0], + object[properties[0]] ); + } + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/forin-002.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/forin-002.js new file mode 100644 index 0000000..1f527a9 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/forin-002.js @@ -0,0 +1,73 @@ +/** + * File Name: forin-002.js + * ECMA Section: + * Description: The forin-001 statement + * + * Verify that the property name is assigned to the property on the left + * hand side of the for...in expression. + * + * Author: christine@netscape.com + * Date: 28 August 1998 + */ + var SECTION = "forin-002"; + var VERSION = "ECMA_2"; + var TITLE = "The for...in statement"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + function MyObject( value ) { + this.value = value; + this.valueOf = new Function ( "return this.value" ); + this.toString = new Function ( "return this.value + \"\"" ); + this.toNumber = new Function ( "return this.value + 0" ); + this.toBoolean = new Function ( "return Boolean( this.value )" ); + } + + ForIn_1(this); + ForIn_2(this); + + ForIn_1(new MyObject(true)); + ForIn_2(new MyObject(new Boolean(true))); + + ForIn_2(3); + + test(); + + /** + * For ... In in a With Block + * + */ + function ForIn_1( object) { + with ( object ) { + for ( property in object ) { + testcases[tc++] = new TestCase( + SECTION, + "with loop in a for...in loop. ("+object+")["+property +"] == "+ + "eval ( " + property +" )", + true, + object[property] == eval(property) ); + } + } + } + + /** + * With block in a For...In loop + * + */ + function ForIn_2(object) { + for ( property in object ) { + with ( object ) { + testcases[tc++] = new TestCase( + SECTION, + "with loop in a for...in loop. ("+object+")["+property +"] == "+ + "eval ( " + property +" )", + true, + object[property] == eval(property) ); + } + } + } + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/if-001.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/if-001.js new file mode 100644 index 0000000..0da212d --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/if-001.js @@ -0,0 +1,39 @@ +/** + * File Name: if-001.js + * ECMA Section: + * Description: The if statement + * + * Verify that assignment in the if expression is evaluated correctly. + * Verifies the fix for bug http://scopus/bugsplat/show_bug.cgi?id=148822. + * + * Author: christine@netscape.com + * Date: 28 August 1998 + */ + var SECTION = "for-001"; + var VERSION = "ECMA_2"; + var TITLE = "The if statement"; + var BUGNUMBER="148822"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var a = 0; + var b = 0; + var result = "passed"; + + if ( a = b ) { + result = "failed: a = b should return 0"; + } + + testcases[tc++] = new TestCase( + SECTION, + "if ( a = b ), where a and b are both equal to 0", + "passed", + result ); + + + test(); + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/label-001.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/label-001.js new file mode 100644 index 0000000..83b51ce --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/label-001.js @@ -0,0 +1,39 @@ +/** + * File Name: label-001.js + * ECMA Section: + * Description: Labeled statements + * + * Labeled break and continue within a for loop. + * + * + * Author: christine@netscape.com + * Date: 11 August 1998 + */ + var SECTION = "label-003"; + var VERSION = "ECMA_2"; + var TITLE = "Labeled statements"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + LabelTest(0, 0); + LabelTest(1, 1) + LabelTest(-1, 1000); + LabelTest(false, 0); + LabelTest(true, 1); + + test(); + + function LabelTest( limit, expect) { + woo: for ( var result = 0; result < 1000; result++ ) { if (result == limit) { break woo; } else { continue woo; } }; + + testcases[tc++] = new TestCase( + SECTION, + "break out of a labeled for loop: "+ limit, + expect, + result ); + } + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/label-002.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/label-002.js new file mode 100644 index 0000000..64b01a8 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/label-002.js @@ -0,0 +1,53 @@ +/** + * File Name: label-002.js + * ECMA Section: + * Description: Labeled statements + * + * Labeled break and continue within a for-in loop. + * + * + * Author: christine@netscape.com + * Date: 11 August 1998 + */ + var SECTION = "label-002"; + var VERSION = "ECMA_2"; + var TITLE = "Labeled statements"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + LabelTest( { p1:"hi,", p2:" norris" }, "hi, norris", " norrishi," ); + LabelTest( { 0:"zero", 1:"one" }, "zeroone", "onezero" ); + + LabelTest2( { p1:"hi,", p2:" norris" }, "hi,", " norris" ); + LabelTest2( { 0:"zero", 1:"one" }, "zero", "one" ); + + test(); + + function LabelTest( object, expect1, expect2 ) { + result = ""; + + yoohoo: { for ( property in object ) { result += object[property]; }; break yoohoo }; + + testcases[tc++] = new TestCase( + SECTION, + "yoohoo: for ( property in object ) { result += object[property]; } break yoohoo }", + true, + result == expect1 || result == expect2 ); + } + + function LabelTest2( object, expect1, expect2 ) { + result = ""; + + yoohoo: { for ( property in object ) { result += object[property]; break yoohoo } }; ; + + testcases[tc++] = new TestCase( + SECTION, + "yoohoo: for ( property in object ) { result += object[property]; break yoohoo }}", + true, + result == expect1 || result == expect2 ); + } + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/switch-001.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/switch-001.js new file mode 100644 index 0000000..6336518 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/switch-001.js @@ -0,0 +1,64 @@ +/** + * File Name: switch-001.js + * ECMA Section: + * Description: The switch Statement + * + * A simple switch test with no abrupt completions. + * + * Author: christine@netscape.com + * Date: 11 August 1998 + * + */ + var SECTION = "switch-001"; + var VERSION = "ECMA_2"; + var TITLE = "The switch statement"; + + var BUGNUMBER="315767"; + + + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + SwitchTest( 0, 126 ); + SwitchTest( 1, 124 ); + SwitchTest( 2, 120 ); + SwitchTest( 3, 112 ); + SwitchTest( 4, 64 ); + SwitchTest( 5, 96 ); + SwitchTest( true, 96 ); + SwitchTest( false, 96 ); + SwitchTest( null, 96 ); + SwitchTest( void 0, 96 ); + SwitchTest( "0", 96 ); + + test(); + + function SwitchTest( input, expect ) { + var result = 0; + + switch ( input ) { + case 0: + result += 2; + case 1: + result += 4; + case 2: + result += 8; + case 3: + result += 16; + default: + result += 32; + case 4: + result +=64; + } + + testcases[tc++] = new TestCase( + SECTION, + "switch with no breaks, case expressions are numbers. input is "+ + input, + expect, + result ); + } diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/switch-002.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/switch-002.js new file mode 100644 index 0000000..20746a8 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/switch-002.js @@ -0,0 +1,60 @@ +/** + * File Name: switch-002.js + * ECMA Section: + * Description: The switch Statement + * + * A simple switch test with no abrupt completions. + * + * Author: christine@netscape.com + * Date: 11 August 1998 + * + */ + var SECTION = "switch-002"; + var VERSION = "ECMA_2"; + var TITLE = "The switch statement"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + SwitchTest( 0, 6 ); + SwitchTest( 1, 4 ); + SwitchTest( 2, 56 ); + SwitchTest( 3, 48 ); + SwitchTest( 4, 64 ); + SwitchTest( true, 32 ); + SwitchTest( false, 32 ); + SwitchTest( null, 32 ); + SwitchTest( void 0, 32 ); + SwitchTest( "0", 32 ); + + test(); + + function SwitchTest( input, expect ) { + var result = 0; + + switch ( input ) { + case 0: + result += 2; + case 1: + result += 4; + break; + case 2: + result += 8; + case 3: + result += 16; + default: + result += 32; + break; + case 4: + result += 64; + } + + testcases[tc++] = new TestCase( + SECTION, + "switch with no breaks: input is " + input, + expect, + result ); + } diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/switch-003.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/switch-003.js new file mode 100644 index 0000000..6a1389c --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/switch-003.js @@ -0,0 +1,54 @@ +/** + * File Name: switch-003.js + * ECMA Section: + * Description: The switch Statement + * + * Attempt to verify that case statements are evaluated in source order + * + * Author: christine@netscape.com + * Date: 11 August 1998 + * + */ + var SECTION = "switch-003"; + var VERSION = "ECMA_2"; + var TITLE = "The switch statement"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + SwitchTest( "a", "abc" ); + SwitchTest( "b", "bc" ); + SwitchTest( "c", "c" ); + SwitchTest( "d", "*abc" ); + SwitchTest( "v", "*abc" ); + SwitchTest( "w", "w*abc" ); + SwitchTest( "x", "xw*abc" ); + SwitchTest( "y", "yxw*abc" ); + SwitchTest( "z", "zyxw*abc" ); +// SwitchTest( new java.lang.String("z"), "*abc" ); + + test(); + + function SwitchTest( input, expect ) { + var result = ""; + + switch ( input ) { + case "z": result += "z"; + case "y": result += "y"; + case "x": result += "x"; + case "w": result += "w"; + default: result += "*"; + case "a": result += "a"; + case "b": result += "b"; + case "c": result += "c"; + } + + testcases[tc++] = new TestCase( + SECTION, + "switch with no breaks: input is " + input, + expect, + result ); + }
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/switch-004.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/switch-004.js new file mode 100644 index 0000000..23da926 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/switch-004.js @@ -0,0 +1,91 @@ +/** + * File Name: switch-003.js + * ECMA Section: + * Description: The switch Statement + * + * This uses variables and objects as case expressions in switch statements. + * This verifies a bunch of bugs: + * + * http://scopus.mcom.com/bugsplat/show_bug.cgi?id=315988 + * http://scopus.mcom.com/bugsplat/show_bug.cgi?id=315975 + * http://scopus.mcom.com/bugsplat/show_bug.cgi?id=315954 + * + * Author: christine@netscape.com + * Date: 11 August 1998 + * + */ + var SECTION = "switch-003"; + var VERSION = "ECMA_2"; + var TITLE = "The switch statement"; + var BUGNUMBER= "315988"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + ONE = new Number(1); + ZERO = new Number(0); + var A = new String("A"); + var B = new String("B"); + TRUE = new Boolean( true ); + FALSE = new Boolean( false ); + UNDEFINED = void 0; + NULL = null; + + SwitchTest( ZERO, "ZERO" ); + SwitchTest( NULL, "NULL" ); + SwitchTest( UNDEFINED, "UNDEFINED" ); + SwitchTest( FALSE, "FALSE" ); + SwitchTest( false, "false" ); + SwitchTest( 0, "0" ); + + SwitchTest ( TRUE, "TRUE" ); + SwitchTest( 1, "1" ); + SwitchTest( ONE, "ONE" ); + SwitchTest( true, "true" ); + + SwitchTest( "a", "a" ); + SwitchTest( A, "A" ); + SwitchTest( "b", "b" ); + SwitchTest( B, "B" ); + + SwitchTest( new Boolean( true ), "default" ); + SwitchTest( new Boolean(false ), "default" ); + SwitchTest( new String( "A" ), "default" ); + SwitchTest( new Number( 0 ), "default" ); + + test(); + + function SwitchTest( input, expect ) { + var result = ""; + + switch ( input ) { + default: result += "default"; break; + case "a": result += "a"; break; + case "b": result += "b"; break; + case A: result += "A"; break; + case B: result += "B"; break; + case new Boolean(true): result += "new TRUE"; break; + case new Boolean(false): result += "new FALSE"; break; + case NULL: result += "NULL"; break; + case UNDEFINED: result += "UNDEFINED"; break; + case true: result += "true"; break; + case false: result += "false"; break; + case TRUE: result += "TRUE"; break; + case FALSE: result += "FALSE"; break; + case 0: result += "0"; break; + case 1: result += "1"; break; + case new Number(0) : result += "new ZERO"; break; + case new Number(1) : result += "new ONE"; break; + case ONE: result += "ONE"; break; + case ZERO: result += "ZERO"; break; + } + + testcases[tc++] = new TestCase( + SECTION, + "switch with no breaks: input is " + input, + expect, + result ); + } diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/try-001.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/try-001.js new file mode 100644 index 0000000..bcd0eac --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/try-001.js @@ -0,0 +1,82 @@ +/** + * File Name: try-001.js + * ECMA Section: + * Description: The try statement + * + * This test contains try, catch, and finally blocks. An exception is + * sometimes thrown by a function called from within the try block. + * + * This test doesn't actually make any LiveConnect calls. + * + * + * Author: christine@netscape.com + * Date: 11 August 1998 + */ + var SECTION = ""; + var VERSION = "ECMA_2"; + var TITLE = "The try statement"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var INVALID_JAVA_INTEGER_VALUE = "Invalid value for java.lang.Integer constructor"; + + TryNewJavaInteger( "3.14159", INVALID_JAVA_INTEGER_VALUE ); + TryNewJavaInteger( NaN, INVALID_JAVA_INTEGER_VALUE ); + TryNewJavaInteger( 0, 0 ); + TryNewJavaInteger( -1, -1 ); + TryNewJavaInteger( 1, 1 ); + TryNewJavaInteger( Infinity, Infinity ); + + test(); + + /** + * Check to see if the input is valid for java.lang.Integer. If it is + * not valid, throw INVALID_JAVA_INTEGER_VALUE. If input is valid, + * return Number( v ) + * + */ + + function newJavaInteger( v ) { + value = Number( v ); + if ( Math.floor(value) != value || isNaN(value) ) { + throw ( INVALID_JAVA_INTEGER_VALUE ); + } else { + return value; + } + } + + /** + * Call newJavaInteger( value ) from within a try block. Catch any + * exception, and store it in result. Verify that we got the right + * return value from newJavaInteger in cases in which we do not expect + * exceptions, and that we got the exception in cases where an exception + * was expected. + */ + function TryNewJavaInteger( value, expect ) { + var finalTest = false; + + try { + result = newJavaInteger( value ); + } catch ( e ) { + result = String( e ); + } finally { + finalTest = true; + } + testcases[tc++] = new TestCase( + SECTION, + "newJavaValue( " + value +" )", + expect, + result); + + testcases[tc++] = new TestCase( + SECTION, + "newJavaValue( " + value +" ) hit finally block", + true, + finalTest); + + } + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/try-003.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/try-003.js new file mode 100644 index 0000000..de1e213 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/try-003.js @@ -0,0 +1,79 @@ +/** + * File Name: try-003.js + * ECMA Section: + * Description: The try statement + * + * This test has a try with no catch, and a finally. + * + * Author: christine@netscape.com + * Date: 11 August 1998 + */ + var SECTION = "try-003"; + var VERSION = "ECMA_2"; + var TITLE = "The try statement"; + var BUGNUMBER="http://scopus.mcom.com/bugsplat/show_bug.cgi?id=313585"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + // Tests start here. + + TrySomething( "x = \"hi\"", false ); + TrySomething( "throw \"boo\"", true ); + TrySomething( "throw 3", true ); + + test(); + + /** + * This function contains a try block with no catch block, + * but it does have a finally block. Try to evaluate expressions + * that do and do not throw exceptions. + */ + + function TrySomething( expression, throwing ) { + innerFinally = "FAIL: DID NOT HIT INNER FINALLY BLOCK"; + if (throwing) { + outerCatch = "FAILED: NO EXCEPTION CAUGHT"; + } else { + outerCatch = "PASS"; + } + outerFinally = "FAIL: DID NOT HIT OUTER FINALLY BLOCK"; + + try { + try { + eval( expression ); + } finally { + innerFinally = "PASS"; + } + } catch ( e ) { + if (throwing) { + outerCatch = "PASS"; + } else { + outerCatch = "FAIL: HIT OUTER CATCH BLOCK"; + } + } finally { + outerFinally = "PASS"; + } + + + testcases[tc++] = new TestCase( + SECTION, + "eval( " + expression +" )", + "PASS", + innerFinally ); + testcases[tc++] = new TestCase( + SECTION, + "eval( " + expression +" )", + "PASS", + outerCatch ); + testcases[tc++] = new TestCase( + SECTION, + "eval( " + expression +" )", + "PASS", + outerFinally ); + + + } diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/try-004.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/try-004.js new file mode 100644 index 0000000..b36dc44 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/try-004.js @@ -0,0 +1,51 @@ +/** + * File Name: try-004.js + * ECMA Section: + * Description: The try statement + * + * This test has a try with one catch block but no finally. + * + * Author: christine@netscape.com + * Date: 11 August 1998 + */ + var SECTION = "try-004"; + var VERSION = "ECMA_2"; + var TITLE = "The try statement"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + TryToCatch( "Math.PI", Math.PI ); + TryToCatch( "Thrower(5)", "Caught 5" ); + TryToCatch( "Thrower(\"some random exception\")", "Caught some random exception" ); + + test(); + + function Thrower( v ) { + throw "Caught " + v; + } + + /** + * Evaluate a string. Catch any exceptions thrown. If no exception is + * expected, verify the result of the evaluation. If an exception is + * expected, verify that we got the right exception. + */ + + function TryToCatch( value, expect ) { + try { + result = eval( value ); + } catch ( e ) { + result = e; + } + + testcases[tc++] = new TestCase( + SECTION, + "eval( " + value +" )", + expect, + result ); + } + + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/try-005.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/try-005.js new file mode 100644 index 0000000..94b5beb --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/try-005.js @@ -0,0 +1,54 @@ +/** + * File Name: try-005.js + * ECMA Section: + * Description: The try statement + * + * This test has a try with one catch block but no finally. Same + * as try-004, but the eval statement is called from a function, not + * directly from within the try block. + * + * Author: christine@netscape.com + * Date: 11 August 1998 + */ + var SECTION = "try-005"; + var VERSION = "ECMA_2"; + var TITLE = "The try statement"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + TryToCatch( "Math.PI", Math.PI ); + TryToCatch( "Thrower(5)", "Caught 5" ); + TryToCatch( "Thrower(\"some random exception\")", "Caught some random exception" ); + + test(); + + function Thrower( v ) { + throw "Caught " + v; + } + function Eval( v ) { + return eval( v ); + } + + /** + * Evaluate a string. Catch any exceptions thrown. If no exception is + * expected, verify the result of the evaluation. If an exception is + * expected, verify that we got the right exception. + */ + + function TryToCatch( value, expect ) { + try { + result = Eval( value ); + } catch ( e ) { + result = e; + } + + testcases[tc++] = new TestCase( + SECTION, + "eval( " + value +" )", + expect, + result ); + } diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/try-006.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/try-006.js new file mode 100644 index 0000000..924f24d --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/try-006.js @@ -0,0 +1,84 @@ +/** + * File Name: try-006.js + * ECMA Section: + * Description: The try statement + * + * Throw an exception from within a With block in a try block. Verify + * that any expected exceptions are caught. + * + * Author: christine@netscape.com + * Date: 11 August 1998 + */ + var SECTION = "try-006"; + var VERSION = "ECMA_2"; + var TITLE = "The try statement"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + /** + * This is the "check" function for test objects that will + * throw an exception. + */ + function throwException() { + throw EXCEPTION_STRING +": " + this.valueOf(); + } + var EXCEPTION_STRING = "Exception thrown:"; + + /** + * This is the "check" function for test objects that do not + * throw an exception + */ + function noException() { + return this.valueOf(); + } + + /** + * Add test cases here + */ + TryWith( new TryObject( "hello", throwException, true )); + TryWith( new TryObject( "hola", noException, false )); + + /** + * Run the test. + */ + + test(); + + /** + * This is the object that will be the "this" in a with block. + */ + function TryObject( value, fun, exception ) { + this.value = value; + this.exception = exception; + + this.valueOf = new Function ( "return this.value" ); + this.check = fun; + } + + /** + * This function has the try block that has a with block within it. + * Test cases are added in this function. Within the with block, the + * object's "check" function is called. If the test object's exception + * property is true, we expect the result to be the exception value. + * If exception is false, then we expect the result to be the value of + * the object. + */ + function TryWith( object ) { + try { + with ( object ) { + result = check(); + } + } catch ( e ) { + result = e; + } + + testcases[tc++] = new TestCase( + SECTION, + "TryWith( " + object.value +" )", + (object.exception ? EXCEPTION_STRING +": " + object.valueOf() : object.valueOf()), + result ); + } diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/try-007.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/try-007.js new file mode 100644 index 0000000..14a960a --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/try-007.js @@ -0,0 +1,89 @@ +/** + * File Name: try-007.js + * ECMA Section: + * Description: The try statement + * + * This test has a for-in statement within a try block. + * + * + * Author: christine@netscape.com + * Date: 11 August 1998 + */ + var SECTION = "try-007"; + var VERSION = "ECMA_2"; + var TITLE = "The try statement: for-in"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + /** + * This is the "check" function for test objects that will + * throw an exception. + */ + function throwException() { + throw EXCEPTION_STRING +": " + this.valueOf(); + } + var EXCEPTION_STRING = "Exception thrown:"; + + /** + * This is the "check" function for test objects that do not + * throw an exception + */ + function noException() { + return this.valueOf(); + } + + /** + * Add test cases here + */ + TryForIn( new TryObject( "hello", throwException, true )); + TryForIn( new TryObject( "hola", noException, false )); + + /** + * Run the test. + */ + + test(); + +/** + * This is the object that will be the "this" in a with block. + * The check function is either throwExeption() or noException(). + * See above. + * + */ +function TryObject( value, fun, exception ) { + this.value = value; + this.exception = exception; + + this.check = fun; + this.valueOf = function () { return this.value; } +} + +/** + * This function has a for-in statement within a try block. Test cases + * are added after the try-catch-finally statement. Within the for-in + * block, call a function that can throw an exception. Verify that any + * exceptions are properly caught. + */ + + function TryForIn( object ) { + try { + for ( p in object ) { + if ( typeof object[p] == "function" ) { + result = object[p](); + } + } + } catch ( e ) { + result = e; + } + + testcases[tc++] = new TestCase( + SECTION, + "TryForIn( " + object+ " )", + (object.exception ? EXCEPTION_STRING +": " + object.value : object.value), + result ); + + } diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/try-008.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/try-008.js new file mode 100644 index 0000000..78092b6 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/try-008.js @@ -0,0 +1,56 @@ +/** + * File Name: try-008.js + * ECMA Section: + * Description: The try statement + * + * This test has a try block in a constructor. + * + * + * Author: christine@netscape.com + * Date: 11 August 1998 + */ + var SECTION = "try-008"; + var VERSION = "ECMA_2"; + var TITLE = "The try statement: try in a constructor"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + function Integer( value, exception ) { + try { + this.value = checkValue( value ); + } catch ( e ) { + this.value = e.toString(); + } + + testcases[tc++] = new TestCase( + SECTION, + "Integer( " + value +" )", + (exception ? INVALID_INTEGER_VALUE +": " + value : this.value), + this.value ); + } + + var INVALID_INTEGER_VALUE = "Invalid value for java.lang.Integer constructor"; + + function checkValue( value ) { + if ( Math.floor(value) != value || isNaN(value) ) { + throw ( INVALID_INTEGER_VALUE +": " + value ); + } else { + return value; + } + } + + // add test cases + + new Integer( 3, false ); + new Integer( NaN, true ); + new Integer( 0, false ); + new Integer( Infinity, false ); + new Integer( -2.12, true ); + new Integer( Math.LN2, true ); + + + test(); diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/try-009.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/try-009.js new file mode 100644 index 0000000..778e647 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/try-009.js @@ -0,0 +1,63 @@ +/** + * File Name: try-009.js + * ECMA Section: + * Description: The try statement + * + * This test has a try block within a while block. Verify that an exception + * breaks out of the while. I don't really know why this is an interesting + * test case but Mike Shaver had two of these so what the hey. + * + * Author: christine@netscape.com + * Date: 11 August 1998 + */ + var SECTION = "try-009"; + var VERSION = "ECMA_2"; + var TITLE = "The try statement: try in a while block"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var EXCEPTION_STRING = "Exception thrown: "; + var NO_EXCEPTION_STRING = "No exception thrown: "; + + + TryInWhile( new TryObject( "hello", ThrowException, true ) ); + TryInWhile( new TryObject( "aloha", NoException, false )); + + test(); + + function TryObject( value, throwFunction, result ) { + this.value = value; + this.thrower = throwFunction; + this.result = result; + } + function ThrowException() { + throw EXCEPTION_STRING + this.value; + } + function NoException() { + return NO_EXCEPTION_STRING + this.value; + } + function TryInWhile( object ) { + result = null; + while ( true ) { + try { + object.thrower(); + result = NO_EXCEPTION_STRING + object.value; + break; + } catch ( e ) { + result = e; + break; + } + } + + testcases[tc++] = new TestCase( + SECTION, + "( "+ object +".thrower() )", + (object.result + ? EXCEPTION_STRING + object.value : + NO_EXCEPTION_STRING + object.value), + result ); + } diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/try-010.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/try-010.js new file mode 100644 index 0000000..eeb7f88 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/try-010.js @@ -0,0 +1,70 @@ +/** + * File Name: try-010.js + * ECMA Section: + * Description: The try statement + * + * This has a try block nested in the try block. Verify that the + * exception is caught by the right try block, and all finally blocks + * are executed. + * + * Author: christine@netscape.com + * Date: 11 August 1998 + */ + var SECTION = "try-010"; + var VERSION = "ECMA_2"; + var TITLE = "The try statement: try in a tryblock"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var EXCEPTION_STRING = "Exception thrown: "; + var NO_EXCEPTION_STRING = "No exception thrown: "; + + + NestedTry( new TryObject( "No Exceptions Thrown", NoException, NoException, 43 ) ); + NestedTry( new TryObject( "Throw Exception in Outer Try", ThrowException, NoException, 48 )); + NestedTry( new TryObject( "Throw Exception in Inner Try", NoException, ThrowException, 45 )); + NestedTry( new TryObject( "Throw Exception in Both Trys", ThrowException, ThrowException, 48 )); + + test(); + + function TryObject( description, tryOne, tryTwo, result ) { + this.description = description; + this.tryOne = tryOne; + this.tryTwo = tryTwo; + this.result = result; + } + function ThrowException() { + throw EXCEPTION_STRING + this.value; + } + function NoException() { + return NO_EXCEPTION_STRING + this.value; + } + function NestedTry( object ) { + result = 0; + try { + object.tryOne(); + result += 1; + try { + object.tryTwo(); + result += 2; + } catch ( e ) { + result +=4; + } finally { + result += 8; + } + } catch ( e ) { + result += 16; + } finally { + result += 32; + } + + testcases[tc++] = new TestCase( + SECTION, + object.description, + object.result, + result ); + } diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/try-012.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/try-012.js new file mode 100644 index 0000000..f8c8e00 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/try-012.js @@ -0,0 +1,92 @@ +/** + * File Name: try-012.js + * ECMA Section: + * Description: The try statement + * + * This test has a try with no catch, and a finally. This is like try-003, + * but throws from a finally block, not the try block. + * + * Author: christine@netscape.com + * Date: 11 August 1998 + */ + var SECTION = "try-012"; + var VERSION = "ECMA_2"; + var TITLE = "The try statement"; + var BUGNUMBER="336872"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + // Tests start here. + + TrySomething( "x = \"hi\"", true ); + TrySomething( "throw \"boo\"", true ); + TrySomething( "throw 3", true ); + + test(); + + /** + * This function contains a try block with no catch block, + * but it does have a finally block. Try to evaluate expressions + * that do and do not throw exceptions. + * + * The productioni TryStatement Block Finally is evaluated as follows: + * 1. Evaluate Block + * 2. Evaluate Finally + * 3. If Result(2).type is normal return result 1 (in the test case, result 1 has + * the completion type throw) + * 4. return result 2 (does not get hit in this case) + * + */ + + function TrySomething( expression, throwing ) { + innerFinally = "FAIL: DID NOT HIT INNER FINALLY BLOCK"; + if (throwing) { + outerCatch = "FAILED: NO EXCEPTION CAUGHT"; + } else { + outerCatch = "PASS"; + } + outerFinally = "FAIL: DID NOT HIT OUTER FINALLY BLOCK"; + + + // If the inner finally does not throw an exception, the result + // of the try block should be returned. (Type of inner return + // value should be throw if finally executes correctly + + try { + try { + throw 0; + } finally { + innerFinally = "PASS"; + eval( expression ); + } + } catch ( e ) { + if (throwing) { + outerCatch = "PASS"; + } else { + outerCatch = "FAIL: HIT OUTER CATCH BLOCK"; + } + } finally { + outerFinally = "PASS"; + } + + + testcases[tc++] = new TestCase( + SECTION, + "eval( " + expression +" ): evaluated inner finally block", + "PASS", + innerFinally ); + testcases[tc++] = new TestCase( + SECTION, + "eval( " + expression +" ): evaluated outer catch block ", + "PASS", + outerCatch ); + testcases[tc++] = new TestCase( + SECTION, + "eval( " + expression +" ): evaluated outer finally block", + "PASS", + outerFinally ); + } diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/while-001.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/while-001.js new file mode 100644 index 0000000..f9c0d64 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/while-001.js @@ -0,0 +1,39 @@ +/** + * File Name: while-001 + * ECMA Section: + * Description: while statement + * + * Verify that the while statement is not executed if the while expression is + * false + * + * Author: christine@netscape.com + * Date: 11 August 1998 + */ + var SECTION = "while-001"; + var VERSION = "ECMA_2"; + var TITLE = "while statement"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + DoWhile(); + test(); + + function DoWhile() { + result = "pass"; + + while (false) { + result = "fail"; + break; + } + + testcases[tc++] = new TestCase( + SECTION, + "while statement: don't evaluate statement is expression is false", + "pass", + result ); + + }
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/while-002.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/while-002.js new file mode 100644 index 0000000..3fda04b --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/while-002.js @@ -0,0 +1,83 @@ +/** + * File Name: while-002 + * ECMA Section: + * Description: while statement + * + * Verify that the while statement is not executed if the while expression is + * false + * + * Author: christine@netscape.com + * Date: 11 August 1998 + */ + var SECTION = "while-002"; + var VERSION = "ECMA_2"; + var TITLE = "while statement"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + DoWhile( new DoWhileObject( + "while expression is null", + null, + "result = \"fail: should not have evaluated statements in while block;break" + ) ); + + DoWhile( new DoWhileObject( + "while expression is undefined", + void 0, + "result = \"fail: should not have evaluated statements in while block; break" + )); + + DoWhile( new DoWhileObject( + "while expression is 0", + 0, + "result = \"fail: should not have evaluated statements in while block; break;" + )); + + DoWhile( new DoWhileObject( + "while expression is eval(\"\")", + eval(""), + "result = \"fail: should not have evaluated statements in while block; break" + )); + + DoWhile( new DoWhileObject( + "while expression is NaN", + NaN, + "result = \"fail: should not have evaluated statements in while block; break" + )); + + test(); + + function DoWhileObject( d, e, s ) { + this.description = d; + this.whileExpression = e; + this.statements = s; + } + + function DoWhile( object ) { + result = "pass"; + + while ( expression = object.whileExpression ) { + eval( object.statements ); + } + + // verify that the while expression was evaluated + + testcases[tc++] = new TestCase( + SECTION, + "verify that while expression was evaluated (should be "+ + object.whileExpression +")", + "pass", + (object.whileExpression == expression || + ( isNaN(object.whileExpression) && isNaN(expression) ) + ) ? "pass" : "fail" ); + + testcases[tc++] = new TestCase( + SECTION, + object.description, + "pass", + result ); + }
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/while-003.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/while-003.js new file mode 100644 index 0000000..0164f05 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/while-003.js @@ -0,0 +1,84 @@ +/** + * File Name: while-003 + * ECMA Section: + * Description: while statement + * + * The while expression evaluates to true, Statement returns abrupt completion. + * + * Author: christine@netscape.com + * Date: 11 August 1998 + */ + var SECTION = "while-003"; + var VERSION = "ECMA_2"; + var TITLE = "while statement"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + DoWhile( new DoWhileObject( + "while expression is true", + true, + "result = \"pass\";" )); + + DoWhile( new DoWhileObject( + "while expression is 1", + 1, + "result = \"pass\";" )); + + DoWhile( new DoWhileObject( + "while expression is new Boolean(false)", + new Boolean(false), + "result = \"pass\";" )); + + DoWhile( new DoWhileObject( + "while expression is new Object()", + new Object(), + "result = \"pass\";" )); + + DoWhile( new DoWhileObject( + "while expression is \"hi\"", + "hi", + "result = \"pass\";" )); +/* + DoWhile( new DoWhileObject( + "while expression has a continue in it", + "true", + "if ( i == void 0 ) i = 0; result=\"pass\"; if ( ++i == 1 ) {continue;} else {break;} result=\"fail\";" + )); +*/ + test(); + + function DoWhileObject( d, e, s ) { + this.description = d; + this.whileExpression = e; + this.statements = s; + } + + function DoWhile( object ) { + result = "fail: statements in while block were not evaluated"; + + while ( expression = object.whileExpression ) { + eval( object.statements ); + break; + } + + // verify that the while expression was evaluated + + testcases[tc++] = new TestCase( + SECTION, + "verify that while expression was evaluated (should be "+ + object.whileExpression +")", + "pass", + (object.whileExpression == expression || + ( isNaN(object.whileExpression) && isNaN(expression) ) + ) ? "pass" : "fail" ); + + testcases[tc++] = new TestCase( + SECTION, + object.description, + "pass", + result ); + }
\ No newline at end of file diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/while-004.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/while-004.js new file mode 100644 index 0000000..48faeb0 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/Statements/while-004.js @@ -0,0 +1,214 @@ +/** + * File Name: while-004 + * ECMA Section: + * Description: while statement + * + * Author: christine@netscape.com + * Date: 11 August 1998 + */ + var SECTION = "while-004"; + var VERSION = "ECMA_2"; + var TITLE = "while statement"; + var BUGNUMBER="316725"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + DoWhile_1(); + DoWhile_2(); + DoWhile_3(); + DoWhile_4(); + DoWhile_5(); + + test(); + + /** + * Break out of a while by calling return. + * + * Tests: 12.6.2 step 6. + */ + function dowhile() { + result = "pass"; + + while (true) { + return result; + result = "fail: hit code after return statement"; + break; + } + } + + function DoWhile_1() { + description = "return statement in a while block"; + + result = dowhile(); + + testcases[tc++] = new TestCase( + SECTION, + "DoWhile_1" + description, + "pass", + result ); + } + + /** + * While with a labeled continue statement. Verify that statements + * after the continue statement are not evaluated. + * + * Tests: 12.6.2 step 8. + * + */ + function DoWhile_2() { + var description = "while with a labeled continue statement"; + var result1 = "pass"; + var result2 = "fail: did not execute code after loop, but inside label"; + var i = 0; + var j = 0; + + theloop: + while( i++ < 10 ) { + j++; + continue theloop; + result1 = "failed: hit code after continue statement"; + } + result2 = "pass"; + + testcases[tc++] = new TestCase( + SECTION, + "DoWhile_2: " +description + " - code inside the loop, before the continue should be executed ("+j+")", + true, + j == 10 ); + + testcases[tc++] = new TestCase( + SECTION, + "DoWhile_2: " +description +" - code after labeled continue should not be executed", + "pass", + result1 ); + + testcases[tc++] = new TestCase( + SECTION, + "DoWhile_2: " +description +" - code after loop but inside label should be executed", + "pass", + result2 ); + } + + /** + * While with a labeled break. + * + */ + function DoWhile_3() { + var description = "while with a labeled break statement"; + var result1 = "pass"; + var result2 = "pass"; + var result3 = "fail: did not get to code after label"; + + woohoo: { + while( true ) { + break woohoo; + result1 = "fail: got to code after a break"; + } + result2 = "fail: got to code outside of loop but inside label"; + } + + result3 = "pass"; + + testcases[tc++] = new TestCase( + SECTION, + "DoWhile_3: " +description +" - verify break out of loop", + "pass", + result1 ); + + + testcases[tc++] = new TestCase( + SECTION, + "DoWhile_3: " +description +" - verify break out of label", + "pass", + result2 ); + + testcases[tc++] = new TestCase( + SECTION, + "DoWhile_3: " +description + " - verify correct exit from label", + "pass", + result3 ); + } + + + /** + * Labled while with an unlabeled break + * + */ + function DoWhile_4() { + var description = "labeled while with an unlabeled break"; + var result1 = "pass"; + var result2 = "pass"; + var result3 = "fail: did not evaluate statement after label"; + + woohooboy: { + while( true ) { + break woohooboy; + result1 = "fail: got to code after the break"; + } + result2 = "fail: broke out of while, but not out of label"; + } + result3 = "pass"; + + testcases[tc++] = new TestCase( + SECTION, + "DoWhile_4: " +description +" - verify break out of while loop", + "pass", + result1 ); + + testcases[tc++] = new TestCase( + SECTION, + "DoWhile_4: " +description + " - verify break out of label", + "pass", + result2 ); + + testcases[tc++] = new TestCase( + SECTION, + "DoWhile_4: " +description +" - verify that statements after label are evaluated", + "pass", + result3 ); + } + + /** + * in this case, should behave the same way as + * + * + */ + function DoWhile_5() { + var description = "while with a labeled continue statement"; + var result1 = "pass"; + var result2 = "fail: did not execute code after loop, but inside label"; + var i = 0; + var j = 0; + + theloop: { + j++; + while( i++ < 10 ) { + continue; + result1 = "failed: hit code after continue statement"; + } + result2 = "pass"; + } + + testcases[tc++] = new TestCase( + SECTION, + "DoWhile_5: " +description + " - continue should not execute statements above the loop", + true, + ( j == 1 ) ); + + testcases[tc++] = new TestCase( + SECTION, + "DoWhile_5: " +description +" - code after labeled continue should not be executed", + "pass", + result1 ); + + testcases[tc++] = new TestCase( + SECTION, + "DoWhile_5: " +description +" - code after loop but inside label should be executed", + "pass", + result2 ); + } + diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/String/match-001.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/String/match-001.js new file mode 100644 index 0000000..738264e --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/String/match-001.js @@ -0,0 +1,100 @@ +/** + * File Name: String/match-001.js + * ECMA Section: 15.6.4.9 + * Description: Based on ECMA 2 Draft 7 February 1999 + * + * Author: christine@netscape.com + * Date: 19 February 1999 + */ + +/* + * String.match( regexp ) + * + * If regexp is not an object of type RegExp, it is replaced with result + * of the expression new RegExp(regexp). Let string denote the result of + * converting the this value to a string. If regexp.global is false, + * return the result obtained by invoking RegExp.prototype.exec (see + * section 15.7.5.3) on regexp with string as parameter. + * + * Otherwise, set the regexp.lastIndex property to 0 and invoke + * RegExp.prototype.exec repeatedly until there is no match. If there is a + * match with an empty string (in other words, if the value of + * regexp.lastIndex is left unchanged) increment regexp.lastIndex by 1. + * The value returned is an array with the properties 0 through n-1 + * corresponding to the first element of the result of each matching + * invocation of RegExp.prototype.exec. + * + * Note that the match function is intentionally generic; it does not + * require that its this value be a string object. Therefore, it can be + * transferred to other kinds of objects for use as a method. + */ + + var SECTION = "String/match-001.js"; + var VERSION = "ECMA_2"; + var TITLE = "String.prototype.match( regexp )"; + + startTest(); + + // the regexp argument is not a RegExp object + // this is not a string object + + // cases in which the regexp global property is false + + AddRegExpCases( 3, "3", "1234567890", 1, 2, ["3"] ); + + // cases in which the regexp object global property is true + + AddGlobalRegExpCases( /34/g, "/34/g", "343443444", 3, ["34", "34", "34"] ); + AddGlobalRegExpCases( /\d{1}/g, "/d{1}/g", "123456abcde7890", 10, + ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"] ); + + AddGlobalRegExpCases( /\d{2}/g, "/d{2}/g", "123456abcde7890", 5, + ["12", "34", "56", "78", "90"] ); + + AddGlobalRegExpCases( /\D{2}/g, "/d{2}/g", "123456abcde7890", 2, + ["ab", "cd"] ); + + test(); + + +function AddRegExpCases( + regexp, str_regexp, string, length, index, matches_array ) { + + AddTestCase( + "( " + string + " ).match(" + str_regexp +").length", + length, + string.match(regexp).length ); + + AddTestCase( + "( " + string + " ).match(" + str_regexp +").index", + index, + string.match(regexp).index ); + + AddTestCase( + "( " + string + " ).match(" + str_regexp +").input", + string, + string.match(regexp).input ); + + for ( var matches = 0; matches < matches_array.length; matches++ ) { + AddTestCase( + "( " + string + " ).match(" + str_regexp +")[" + matches +"]", + matches_array[matches], + string.match(regexp)[matches] ); + } +} + +function AddGlobalRegExpCases( + regexp, str_regexp, string, length, matches_array ) { + + AddTestCase( + "( " + string + " ).match(" + str_regexp +").length", + length, + string.match(regexp).length ); + + for ( var matches = 0; matches < matches_array.length; matches++ ) { + AddTestCase( + "( " + string + " ).match(" + str_regexp +")[" + matches +"]", + matches_array[matches], + string.match(regexp)[matches] ); + } +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/String/match-002.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/String/match-002.js new file mode 100644 index 0000000..83ac2fa --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/String/match-002.js @@ -0,0 +1,168 @@ +/** + * File Name: String/match-002.js + * ECMA Section: 15.6.4.9 + * Description: Based on ECMA 2 Draft 7 February 1999 + * + * Author: christine@netscape.com + * Date: 19 February 1999 + */ + +/* + * String.match( regexp ) + * + * If regexp is not an object of type RegExp, it is replaced with result + * of the expression new RegExp(regexp). Let string denote the result of + * converting the this value to a string. If regexp.global is false, + * return the result obtained by invoking RegExp.prototype.exec (see + * section 15.7.5.3) on regexp with string as parameter. + * + * Otherwise, set the regexp.lastIndex property to 0 and invoke + * RegExp.prototype.exec repeatedly until there is no match. If there is a + * match with an empty string (in other words, if the value of + * regexp.lastIndex is left unchanged) increment regexp.lastIndex by 1. + * The value returned is an array with the properties 0 through n-1 + * corresponding to the first element of the result of each matching + * invocation of RegExp.prototype.exec. + * + * Note that the match function is intentionally generic; it does not + * require that its this value be a string object. Therefore, it can be + * transferred to other kinds of objects for use as a method. + * + * This file tests cases in which regexp.global is false. Therefore, + * results should behave as regexp.exec with string passed as a parameter. + * + */ + + var SECTION = "String/match-002.js"; + var VERSION = "ECMA_2"; + var TITLE = "String.prototype.match( regexp )"; + + startTest(); + + // the regexp argument is not a RegExp object + // this is not a string object + + AddRegExpCases( /([\d]{5})([-\ ]?[\d]{4})?$/, + "/([\d]{5})([-\ ]?[\d]{4})?$/", + "Boston, Mass. 02134", + 14, + ["02134", "02134", undefined]); + + AddGlobalRegExpCases( /([\d]{5})([-\ ]?[\d]{4})?$/g, + "/([\d]{5})([-\ ]?[\d]{4})?$/g", + "Boston, Mass. 02134", + ["02134"]); + + // set the value of lastIndex + re = /([\d]{5})([-\ ]?[\d]{4})?$/; + re.lastIndex = 0; + + s = "Boston, MA 02134"; + + AddRegExpCases( re, + "re = /([\d]{5})([-\ ]?[\d]{4})?$/; re.lastIndex =0", + s, + s.lastIndexOf("0"), + ["02134", "02134", undefined]); + + + re.lastIndex = s.length; + + AddRegExpCases( re, + "re = /([\d]{5})([-\ ]?[\d]{4})?$/; re.lastIndex = " + + s.length, + s, + s.lastIndexOf("0"), + ["02134", "02134", undefined] ); + + re.lastIndex = s.lastIndexOf("0"); + + AddRegExpCases( re, + "re = /([\d]{5})([-\ ]?[\d]{4})?$/; re.lastIndex = " + + s.lastIndexOf("0"), + s, + s.lastIndexOf("0"), + ["02134", "02134", undefined]); + + re.lastIndex = s.lastIndexOf("0") + 1; + + AddRegExpCases( re, + "re = /([\d]{5})([-\ ]?[\d]{4})?$/; re.lastIndex = " + + s.lastIndexOf("0") +1, + s, + s.lastIndexOf("0"), + ["02134", "02134", undefined]); + + test(); + +function AddRegExpCases( + regexp, str_regexp, string, index, matches_array ) { + + // prevent a runtime error + + if ( regexp.exec(string) == null || matches_array == null ) { + AddTestCase( + string + ".match(" + regexp +")", + matches_array, + string.match(regexp) ); + + return; + } + + AddTestCase( + "( " + string + " ).match(" + str_regexp +").length", + matches_array.length, + string.match(regexp).length ); + + AddTestCase( + "( " + string + " ).match(" + str_regexp +").index", + index, + string.match(regexp).index ); + + AddTestCase( + "( " + string + " ).match(" + str_regexp +").input", + string, + string.match(regexp).input ); + + var limit = matches_array.length > string.match(regexp).length ? + matches_array.length : + string.match(regexp).length; + + for ( var matches = 0; matches < limit; matches++ ) { + AddTestCase( + "( " + string + " ).match(" + str_regexp +")[" + matches +"]", + matches_array[matches], + string.match(regexp)[matches] ); + } +} + +function AddGlobalRegExpCases( + regexp, str_regexp, string, matches_array ) { + + // prevent a runtime error + + if ( regexp.exec(string) == null || matches_array == null ) { + AddTestCase( + regexp + ".exec(" + string +")", + matches_array, + regexp.exec(string) ); + + return; + } + + AddTestCase( + "( " + string + " ).match(" + str_regexp +").length", + matches_array.length, + string.match(regexp).length ); + + var limit = matches_array.length > string.match(regexp).length ? + matches_array.length : + string.match(regexp).length; + + for ( var matches = 0; matches < limit; matches++ ) { + AddTestCase( + "( " + string + " ).match(" + str_regexp +")[" + matches +"]", + matches_array[matches], + string.match(regexp)[matches] ); + } +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/String/match-003.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/String/match-003.js new file mode 100644 index 0000000..f63e9e2 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/String/match-003.js @@ -0,0 +1,126 @@ +/** + * File Name: String/match-003.js + * ECMA Section: 15.6.4.9 + * Description: Based on ECMA 2 Draft 7 February 1999 + * + * Author: christine@netscape.com + * Date: 19 February 1999 + */ + +/* + * String.match( regexp ) + * + * If regexp is not an object of type RegExp, it is replaced with result + * of the expression new RegExp(regexp). Let string denote the result of + * converting the this value to a string. If regexp.global is false, + * return the result obtained by invoking RegExp.prototype.exec (see + * section 15.7.5.3) on regexp with string as parameter. + * + * Otherwise, set the regexp.lastIndex property to 0 and invoke + * RegExp.prototype.exec repeatedly until there is no match. If there is a + * match with an empty string (in other words, if the value of + * regexp.lastIndex is left unchanged) increment regexp.lastIndex by 1. + * The value returned is an array with the properties 0 through n-1 + * corresponding to the first element of the result of each matching + * invocation of RegExp.prototype.exec. + * + * Note that the match function is intentionally generic; it does not + * require that its this value be a string object. Therefore, it can be + * transferred to other kinds of objects for use as a method. + */ + + var SECTION = "String/match-003.js"; + var VERSION = "ECMA_2"; + var TITLE = "String.prototype.match( regexp )"; + + startTest(); + + // the regexp argument is not a RegExp object + // this is not a string object + + +// [if regexp.global is true] set the regexp.lastIndex property to 0 and +// invoke RegExp.prototype.exec repeatedly until there is no match. If +// there is a match with an empty string (in other words, if the value of +// regexp.lastIndex is left unchanged) increment regexp.lastIndex by 1. +// The value returned is an array with the properties 0 through n-1 +// corresponding to the first element of the result of each matching invocation +// of RegExp.prototype.exec. + + + // set the value of lastIndex + re = /([\d]{5})([-\ ]?[\d]{4})?$/g; + + + s = "Boston, MA 02134"; + + AddGlobalRegExpCases( re, + "re = " + re, + s, + ["02134" ]); + + re.lastIndex = 0; + + AddGlobalRegExpCases( + re, + "re = " + re + "; re.lastIndex = 0 ", + s, + ["02134"]); + + + re.lastIndex = s.length; + + AddGlobalRegExpCases( + re, + "re = " + re + "; re.lastIndex = " + s.length, + s, + ["02134"] ); + + re.lastIndex = s.lastIndexOf("0"); + + AddGlobalRegExpCases( + re, + "re = "+ re +"; re.lastIndex = " + s.lastIndexOf("0"), + s, + ["02134"]); + + re.lastIndex = s.lastIndexOf("0") + 1; + + AddGlobalRegExpCases( + re, + "re = " +re+ "; re.lastIndex = " + (s.lastIndexOf("0") +1), + s, + ["02134"]); + + test(); + +function AddGlobalRegExpCases( + regexp, str_regexp, string, matches_array ) { + + // prevent a runtime error + + if ( string.match(regexp) == null || matches_array == null ) { + AddTestCase( + string + ".match(" + str_regexp +")", + matches_array, + string.match(regexp) ); + + return; + } + + AddTestCase( + "( " + string + " ).match(" + str_regexp +").length", + matches_array.length, + string.match(regexp).length ); + + var limit = matches_array.length > string.match(regexp).length ? + matches_array.length : + string.match(regexp).length; + + for ( var matches = 0; matches < limit; matches++ ) { + AddTestCase( + "( " + string + " ).match(" + str_regexp +")[" + matches +"]", + matches_array[matches], + string.match(regexp)[matches] ); + } +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/String/match-004.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/String/match-004.js new file mode 100644 index 0000000..c35d988 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/String/match-004.js @@ -0,0 +1,167 @@ +/** + * File Name: String/match-004.js + * ECMA Section: 15.6.4.9 + * Description: Based on ECMA 2 Draft 7 February 1999 + * + * Author: christine@netscape.com + * Date: 19 February 1999 + */ + +/* + * String.match( regexp ) + * + * If regexp is not an object of type RegExp, it is replaced with result + * of the expression new RegExp(regexp). Let string denote the result of + * converting the this value to a string. If regexp.global is false, + * return the result obtained by invoking RegExp.prototype.exec (see + * section 15.7.5.3) on regexp with string as parameter. + * + * Otherwise, set the regexp.lastIndex property to 0 and invoke + * RegExp.prototype.exec repeatedly until there is no match. If there is a + * match with an empty string (in other words, if the value of + * regexp.lastIndex is left unchanged) increment regexp.lastIndex by 1. + * The value returned is an array with the properties 0 through n-1 + * corresponding to the first element of the result of each matching + * invocation of RegExp.prototype.exec. + * + * Note that the match function is intentionally generic; it does not + * require that its this value be a string object. Therefore, it can be + * transferred to other kinds of objects for use as a method. + * + * + * The match function should be intentionally generic, and not require + * this to be a string. + * + */ + + var SECTION = "String/match-004.js"; + var VERSION = "ECMA_2"; + var TITLE = "String.prototype.match( regexp )"; + + var BUGNUMBER="http://scopus/bugsplat/show_bug.cgi?id=345818"; + + startTest(); + + // set the value of lastIndex + re = /0./; + s = 10203040506070809000; + + Number.prototype.match = String.prototype.match; + + AddRegExpCases( re, + "re = " + re , + s, + String(s), + 1, + ["02"]); + + + re.lastIndex = 0; + AddRegExpCases( re, + "re = " + re +" [lastIndex is " + re.lastIndex+"]", + s, + String(s), + 1, + ["02"]); +/* + + re.lastIndex = s.length; + + AddRegExpCases( re, + "re = /([\d]{5})([-\ ]?[\d]{4})?$/; re.lastIndex = " + + s.length, + s, + s.lastIndexOf("0"), + null ); + + re.lastIndex = s.lastIndexOf("0"); + + AddRegExpCases( re, + "re = /([\d]{5})([-\ ]?[\d]{4})?$/; re.lastIndex = " + + s.lastIndexOf("0"), + s, + s.lastIndexOf("0"), + ["02134"]); + + re.lastIndex = s.lastIndexOf("0") + 1; + + AddRegExpCases( re, + "re = /([\d]{5})([-\ ]?[\d]{4})?$/; re.lastIndex = " + + s.lastIndexOf("0") +1, + s, + 0, + null); +*/ + test(); + +function AddRegExpCases( + regexp, str_regexp, string, str_string, index, matches_array ) { + + // prevent a runtime error + + if ( regexp.exec(string) == null || matches_array == null ) { + AddTestCase( + string + ".match(" + regexp +")", + matches_array, + string.match(regexp) ); + + return; + } + + AddTestCase( + "( " + string + " ).match(" + str_regexp +").length", + matches_array.length, + string.match(regexp).length ); + + AddTestCase( + "( " + string + " ).match(" + str_regexp +").index", + index, + string.match(regexp).index ); + + AddTestCase( + "( " + string + " ).match(" + str_regexp +").input", + str_string, + string.match(regexp).input ); + + var limit = matches_array.length > string.match(regexp).length ? + matches_array.length : + string.match(regexp).length; + + for ( var matches = 0; matches < limit; matches++ ) { + AddTestCase( + "( " + string + " ).match(" + str_regexp +")[" + matches +"]", + matches_array[matches], + string.match(regexp)[matches] ); + } +} + +function AddGlobalRegExpCases( + regexp, str_regexp, string, matches_array ) { + + // prevent a runtime error + + if ( regexp.exec(string) == null || matches_array == null ) { + AddTestCase( + regexp + ".exec(" + string +")", + matches_array, + regexp.exec(string) ); + + return; + } + + AddTestCase( + "( " + string + " ).match(" + str_regexp +").length", + matches_array.length, + string.match(regexp).length ); + + var limit = matches_array.length > string.match(regexp).length ? + matches_array.length : + string.match(regexp).length; + + for ( var matches = 0; matches < limit; matches++ ) { + AddTestCase( + "( " + string + " ).match(" + str_regexp +")[" + matches +"]", + matches_array[matches], + string.match(regexp)[matches] ); + } +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/String/replace-001.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/String/replace-001.js new file mode 100644 index 0000000..5ff8dc0 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/String/replace-001.js @@ -0,0 +1,60 @@ +/** + * File Name: String/replace-001.js + * ECMA Section: 15.6.4.10 + * Description: Based on ECMA 2 Draft 7 February 1999 + * + * Author: christine@netscape.com + * Date: 19 February 1999 + */ + + var SECTION = "String/replace-001.js"; + var VERSION = "ECMA_2"; + var TITLE = "String.prototype.replace( regexp, replaceValue )"; + + startTest(); + + /* + * If regexp is not an object of type RegExp, it is replaced with the + * result of the expression new RegExp(regexp). Let string denote the + * result of converting the this value to a string. String is searched + * for the first occurrence of the regular expression pattern regexp if + * regexp.global is false, or all occurrences if regexp.global is true. + * + * The match is performed as in String.prototype.match, including the + * update of regexp.lastIndex. Let m be the number of matched + * parenthesized subexpressions as specified in section 15.7.5.3. + * + * If replaceValue is a function, then for each matched substring, call + * the function with the following m + 3 arguments. Argument 1 is the + * substring that matched. The next m arguments are all of the matched + * subexpressions. Argument m + 2 is the length of the left context, and + * argument m + 3 is string. + * + * The result is a string value derived from the original input by + * replacing each matched substring with the corresponding return value + * of the function call, converted to a string if need be. + * + * Otherwise, let newstring denote the result of converting replaceValue + * to a string. The result is a string value derived from the original + * input string by replacing each matched substring with a string derived + * from newstring by replacing characters in newstring by replacement text + * as specified in the following table: + * + * $& The matched substring. + * $‘ The portion of string that precedes the matched substring. + * $’ The portion of string that follows the matched substring. + * $+ The substring matched by the last parenthesized subexpressions in + * the regular expression. + * $n The corresponding matched parenthesized subexpression n, where n + * is a single digit 0-9. If there are fewer than n subexpressions, “$n + * is left unchanged. + * + * Note that the replace function is intentionally generic; it does not + * require that its this value be a string object. Therefore, it can be + * transferred to other kinds of objects for use as a method. + */ + + + testcases[0] = { expect:"PASSED", actual:"PASSED", description:"NO TESTS EXIST" }; + + test(); diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/String/split-001.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/String/split-001.js new file mode 100644 index 0000000..b2d7c9c --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/String/split-001.js @@ -0,0 +1,106 @@ +/** + * File Name: String/split-001.js + * ECMA Section: 15.6.4.9 + * Description: Based on ECMA 2 Draft 7 February 1999 + * + * Author: christine@netscape.com + * Date: 19 February 1999 + */ + +/* + * Since regular expressions have been part of JavaScript since 1.2, there + * are already tests for regular expressions in the js1_2/regexp folder. + * + * These new tests try to supplement the existing tests, and verify that + * our implementation of RegExp conforms to the ECMA specification, but + * does not try to be as exhaustive as in previous tests. + * + * The [,limit] argument to String.split is new, and not covered in any + * existing tests. + * + * String.split cases are covered in ecma/String/15.5.4.8-*.js. + * String.split where separator is a RegExp are in + * js1_2/regexp/string_split.js + * + */ + + var SECTION = "ecma_2/String/split-001.js"; + var VERSION = "ECMA_2"; + var TITLE = "String.prototype.split( regexp, [,limit] )"; + + startTest(); + + // the separator is not supplied + // separator is undefined + // separator is an empty string + + AddSplitCases( "splitme", "", "''", ["s", "p", "l", "i", "t", "m", "e"] ); + AddSplitCases( "splitme", new RegExp(), "new RegExp()", ["s", "p", "l", "i", "t", "m", "e"] ); + + // separartor is a regexp + // separator regexp value global setting is set + // string is an empty string + // if separator is an empty string, split each by character + + // this is not a String object + + // limit is not a number + // limit is undefined + // limit is larger than 2^32-1 + // limit is a negative number + + test(); + +function AddSplitCases( string, separator, str_sep, split_array ) { + + // verify that the result of split is an object of type Array + AddTestCase( + "( " + string + " ).split(" + str_sep +").constructor == Array", + true, + string.split(separator).constructor == Array ); + + // check the number of items in the array + AddTestCase( + "( " + string + " ).split(" + str_sep +").length", + split_array.length, + string.split(separator).length ); + + // check the value of each array item + var limit = (split_array.length > string.split(separator).length ) + ? split_array.length : string.split(separator).length; + + for ( var matches = 0; matches < split_array.length; matches++ ) { + AddTestCase( + "( " + string + " ).split(" + str_sep +")[" + matches +"]", + split_array[matches], + string.split( separator )[matches] ); + } +} + +function AddLimitedSplitCases( + string, separator, str_sep, limit, str_limit, split_array ) { + + // verify that the result of split is an object of type Array + + AddTestCase( + "( " + string + " ).split(" + str_sep +", " + str_limit + + " ).constructor == Array", + true, + string.split(separator, limit).constructor == Array ); + + // check the length of the array + + AddTestCase( + "( " + string + " ).split(" + str_sep +", " + str_limit + " ).length", + length, + string.split(separator).length ); + + // check the value of each array item + + for ( var matches = 0; matches < split_array.length; matches++ ) { + AddTestCase( + "( " + string + " ).split(" + str_sep +", " + str_limit + " )[" + matches +"]", + split_array[matches], + string.split( separator )[matches] ); + } +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/String/split-002.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/String/split-002.js new file mode 100644 index 0000000..1007a31 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/String/split-002.js @@ -0,0 +1,264 @@ +/** + * File Name: String/split-002.js + * ECMA Section: 15.6.4.9 + * Description: Based on ECMA 2 Draft 7 February 1999 + * + * Author: christine@netscape.com + * Date: 19 February 1999 + */ + +/* + * Since regular expressions have been part of JavaScript since 1.2, there + * are already tests for regular expressions in the js1_2/regexp folder. + * + * These new tests try to supplement the existing tests, and verify that + * our implementation of RegExp conforms to the ECMA specification, but + * does not try to be as exhaustive as in previous tests. + * + * The [,limit] argument to String.split is new, and not covered in any + * existing tests. + * + * String.split cases are covered in ecma/String/15.5.4.8-*.js. + * String.split where separator is a RegExp are in + * js1_2/regexp/string_split.js + * + */ + + var SECTION = "ecma_2/String/split-002.js"; + var VERSION = "ECMA_2"; + var TITLE = "String.prototype.split( regexp, [,limit] )"; + + startTest(); + + // the separator is not supplied + // separator is undefined + // separator is an empty string + +// AddSplitCases( "splitme", "", "''", ["s", "p", "l", "i", "t", "m", "e"] ); +// AddSplitCases( "splitme", new RegExp(), "new RegExp()", ["s", "p", "l", "i", "t", "m", "e"] ); + + // separator is an empty regexp + // separator is not supplied + + CompareSplit( "hello", "ll" ); + + CompareSplit( "hello", "l" ); + CompareSplit( "hello", "x" ); + CompareSplit( "hello", "h" ); + CompareSplit( "hello", "o" ); + CompareSplit( "hello", "hello" ); + CompareSplit( "hello", undefined ); + + CompareSplit( "hello", ""); + CompareSplit( "hello", "hellothere" ); + + CompareSplit( new String("hello" ) ); + + + Number.prototype.split = String.prototype.split; + + CompareSplit( new Number(100111122133144155), 1 ); + CompareSplitWithLimit(new Number(100111122133144155), 1, 1 ); + + CompareSplitWithLimit(new Number(100111122133144155), 1, 2 ); + CompareSplitWithLimit(new Number(100111122133144155), 1, 0 ); + CompareSplitWithLimit(new Number(100111122133144155), 1, 100 ); + CompareSplitWithLimit(new Number(100111122133144155), 1, void 0 ); + CompareSplitWithLimit(new Number(100111122133144155), 1, Math.pow(2,32)-1 ); + CompareSplitWithLimit(new Number(100111122133144155), 1, "boo" ); + CompareSplitWithLimit(new Number(100111122133144155), 1, -(Math.pow(2,32)-1) ); + CompareSplitWithLimit( "hello", "l", NaN ); + CompareSplitWithLimit( "hello", "l", 0 ); + CompareSplitWithLimit( "hello", "l", 1 ); + CompareSplitWithLimit( "hello", "l", 2 ); + CompareSplitWithLimit( "hello", "l", 3 ); + CompareSplitWithLimit( "hello", "l", 4 ); + + +/* + CompareSplitWithLimit( "hello", "ll", 0 ); + CompareSplitWithLimit( "hello", "ll", 1 ); + CompareSplitWithLimit( "hello", "ll", 2 ); + CompareSplit( "", " " ); + CompareSplit( "" ); +*/ + + // separartor is a regexp + // separator regexp value global setting is set + // string is an empty string + // if separator is an empty string, split each by character + + // this is not a String object + + // limit is not a number + // limit is undefined + // limit is larger than 2^32-1 + // limit is a negative number + + test(); + +function CompareSplit( string, separator ) { + split_1 = string.split( separator ); + split_2 = string_split( string, separator ); + + AddTestCase( + "( " + string +".split(" + separator + ") ).length" , + split_2.length, + split_1.length ); + + var limit = split_1.length > split_2.length ? + split_1.length : split_2.length; + + for ( var split_item = 0; split_item < limit; split_item++ ) { + AddTestCase( + string + ".split(" + separator + ")["+split_item+"]", + split_2[split_item], + split_1[split_item] ); + } +} + +function CompareSplitWithLimit( string, separator, splitlimit ) { + split_1 = string.split( separator, splitlimit ); + split_2 = string_split( string, separator, splitlimit ); + + AddTestCase( + "( " + string +".split(" + separator + ", " + splitlimit+") ).length" , + split_2.length, + split_1.length ); + + var limit = split_1.length > split_2.length ? + split_1.length : split_2.length; + + for ( var split_item = 0; split_item < limit; split_item++ ) { + AddTestCase( + string + ".split(" + separator + ", " + splitlimit+")["+split_item+"]", + split_2[split_item], + split_1[split_item] ); + } +} + +function string_split ( __this, separator, limit ) { + var S = String(__this ); // 1 + + var A = new Array(); // 2 + + if ( limit == undefined ) { // 3 + lim = Math.pow(2, 31 ) -1; + } else { + lim = ToUint32( limit ); + } + + var s = S.length; // 4 + var p = 0; // 5 + + if ( separator == undefined ) { // 8 + A[0] = S; + return A; + } + + if ( separator.constructor == RegExp ) // 6 + R = separator; + else + R = separator.toString(); + + if (lim == 0) return A; // 7 + + if ( separator == undefined ) { // 8 + A[0] = S; + return A; + } + + if (s == 0) { // 9 + z = SplitMatch(R, S, 0); + if (z != false) return A; + A[0] = S; + return A; + } + + var q = p; // 10 +loop: + while (true ) { + + if ( q == s ) break; // 11 + + z = SplitMatch(R, S, q); // 12 + +//print("Returned ", z); + + if (z != false) { // 13 + e = z.endIndex; // 14 + cap = z.captures; // 14 + if (e != p) { // 15 +//print("S = ", S, ", p = ", p, ", q = ", q); + T = S.slice(p, q); // 16 +//print("T = ", T); + A[A.length] = T; // 17 + if (A.length == lim) return A; // 18 + p = e; // 19 + i = 0; // 20 + while (true) { // 25 + if (i == cap.length) { // 21 + q = p; // 10 + continue loop; + } + i = i + 1; // 22 + A[A.length] = cap[i] // 23 + if (A.length == lim) return A; // 24 + } + } + } + + q = q + 1; // 26 + } + + T = S.slice(p, q); + A[A.length] = T; + return A; +} + +function SplitMatch(R, S, q) +{ + if (R.constructor == RegExp) { // 1 + var reResult = R.match(S, q); // 8 + if (reResult == undefined) + return false; + else { + a = new Array(reResult.length - 1); + for (var i = 1; i < reResult.length; i++) + a[a.length] = reResult[i]; + return { endIndex : reResult.index + reResult[0].length, captures : cap }; + } + } + else { + var r = R.length; // 2 + s = S.length; // 3 + if ((q + r) > s) return false; // 4 + for (var i = 0; i < r; i++) { +//print("S.charAt(", q + i, ") = ", S.charAt(q + i), ", R.charAt(", i, ") = ", R.charAt(i)); + if (S.charAt(q + i) != R.charAt(i)) // 5 + return false; + } + cap = new Array(); // 6 + return { endIndex : q + r, captures : cap }; // 7 + } +} + +function ToUint32( n ) { + n = Number( n ); + var sign = ( n < 0 ) ? -1 : 1; + + if ( Math.abs( n ) == 0 + || Math.abs( n ) == Number.POSITIVE_INFINITY + || n != n) { + return 0; + } + n = sign * Math.floor( Math.abs(n) ) + + n = n % Math.pow(2,32); + + if ( n < 0 ){ + n += Math.pow(2,32); + } + + return ( n ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/String/split-003.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/String/split-003.js new file mode 100644 index 0000000..e2f2b92 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/String/split-003.js @@ -0,0 +1,117 @@ +/** + * File Name: String/split-003.js + * ECMA Section: 15.6.4.9 + * Description: Based on ECMA 2 Draft 7 February 1999 + * + * Author: christine@netscape.com + * Date: 19 February 1999 + */ + +/* + * Since regular expressions have been part of JavaScript since 1.2, there + * are already tests for regular expressions in the js1_2/regexp folder. + * + * These new tests try to supplement the existing tests, and verify that + * our implementation of RegExp conforms to the ECMA specification, but + * does not try to be as exhaustive as in previous tests. + * + * The [,limit] argument to String.split is new, and not covered in any + * existing tests. + * + * String.split cases are covered in ecma/String/15.5.4.8-*.js. + * String.split where separator is a RegExp are in + * js1_2/regexp/string_split.js + * + */ + + var SECTION = "ecma_2/String/split-003.js"; + var VERSION = "ECMA_2"; + var TITLE = "String.prototype.split( regexp, [,limit] )"; + + startTest(); + + // separartor is a regexp + // separator regexp value global setting is set + // string is an empty string + // if separator is an empty string, split each by character + + + AddSplitCases( "hello", new RegExp, "new RegExp", ["h","e","l","l","o"] ); + + AddSplitCases( "hello", /l/, "/l/", ["he","","o"] ); + AddLimitedSplitCases( "hello", /l/, "/l/", 0, [] ); + AddLimitedSplitCases( "hello", /l/, "/l/", 1, ["he"] ); + AddLimitedSplitCases( "hello", /l/, "/l/", 2, ["he",""] ); + AddLimitedSplitCases( "hello", /l/, "/l/", 3, ["he","","o"] ); + AddLimitedSplitCases( "hello", /l/, "/l/", 4, ["he","","o"] ); + AddLimitedSplitCases( "hello", /l/, "/l/", void 0, ["he","","o"] ); + AddLimitedSplitCases( "hello", /l/, "/l/", "hi", [] ); + AddLimitedSplitCases( "hello", /l/, "/l/", undefined, ["he","","o"] ); + + AddSplitCases( "hello", new RegExp, "new RegExp", ["h","e","l","l","o"] ); + AddLimitedSplitCases( "hello", new RegExp, "new RegExp", 0, [] ); + AddLimitedSplitCases( "hello", new RegExp, "new RegExp", 1, ["h"] ); + AddLimitedSplitCases( "hello", new RegExp, "new RegExp", 2, ["h","e"] ); + AddLimitedSplitCases( "hello", new RegExp, "new RegExp", 3, ["h","e","l"] ); + AddLimitedSplitCases( "hello", new RegExp, "new RegExp", 4, ["h","e","l","l"] ); + AddLimitedSplitCases( "hello", new RegExp, "new RegExp", void 0, ["h","e","l","l","o"] ); + AddLimitedSplitCases( "hello", new RegExp, "new RegExp", "hi", [] ); + AddLimitedSplitCases( "hello", new RegExp, "new RegExp", undefined, ["h","e","l","l","o"] ); + + test(); + +function AddSplitCases( string, separator, str_sep, split_array ) { + // verify that the result of split is an object of type Array + AddTestCase( + "( " + string + " ).split(" + str_sep +").constructor == Array", + true, + string.split(separator).constructor == Array ); + + // check the number of items in the array + AddTestCase( + "( " + string + " ).split(" + str_sep +").length", + split_array.length, + string.split(separator).length ); + + // check the value of each array item + var limit = (split_array.length > string.split(separator).length ) + ? split_array.length : string.split(separator).length; + + for ( var matches = 0; matches < split_array.length; matches++ ) { + AddTestCase( + "( " + string + " ).split(" + str_sep +")[" + matches +"]", + split_array[matches], + string.split( separator )[matches] ); + } +} + +function AddLimitedSplitCases( + string, separator, str_sep, limit, split_array ) { + + // verify that the result of split is an object of type Array + + AddTestCase( + "( " + string + " ).split(" + str_sep +", " + limit + + " ).constructor == Array", + true, + string.split(separator, limit).constructor == Array ); + + // check the length of the array + + AddTestCase( + "( " + string + " ).split(" + str_sep +", " + limit + " ).length", + split_array.length, + string.split(separator, limit).length ); + + // check the value of each array item + + var slimit = (split_array.length > string.split(separator).length ) + ? split_array.length : string.split(separator, limit).length; + + for ( var matches = 0; matches < slimit; matches++ ) { + AddTestCase( + "( " + string + " ).split(" + str_sep +", " + limit + " )[" + matches +"]", + split_array[matches], + string.split( separator, limit )[matches] ); + } +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/browser.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/browser.js new file mode 100644 index 0000000..ccc1bb4 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/browser.js @@ -0,0 +1,83 @@ +/* +* The contents of this file are subject to the Netscape Public +* License Version 1.1 (the "License"); you may not use this file +* except in compliance with the License. You may obtain a copy of +* the License at http://www.mozilla.org/NPL/ +* +* Software distributed under the License is distributed on an "AS +* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or +* implied. See the License for the specific language governing +* rights and limitations under the License. +* +* The Original Code is mozilla.org code. +* +* The Initial Developer of the Original Code is Netscape +* Communications Corporation. Portions created by Netscape are +* Copyright (C) 1998 Netscape Communications Corporation. All +* Rights Reserved. +* +* Contributor(s): +*/ + +/* + * JavaScript test library shared functions file for running the tests + * in the browser. Overrides the shell's print function with document.write + * and make everything HTML pretty. + * + * To run the tests in the browser, use the mkhtml.pl script to generate + * html pages that include the shell.js, browser.js (this file), and the + * test js file in script tags. + * + * The source of the page that is generated should look something like this: + * <script src="./../shell.js"></script> + * <script src="./../browser.js"></script> + * <script src="./mytest.js"></script> + */ + +onerror = err; + +var GLOBAL = "[object Window]"; + +function startTest() { + writeHeaderToLog( SECTION + " "+ TITLE); + if ( BUGNUMBER ) { + writeLineToLog ("BUGNUMBER: " + BUGNUMBER ); + } + + testcases = new Array(); + tc = 0; +} + +function writeLineToLog( string ) { + document.write( string + "<br>\n"); +} +function writeHeaderToLog( string ) { + document.write( "<h2>" + string + "</h2>" ); +} +function stopTest() { + var gc; + if ( gc != undefined ) { + gc(); + } + document.write( "<hr>" ); +} +function writeFormattedResult( expect, actual, string, passed ) { + var s = "<tt>"+ string ; + s += "<b>" ; + s += ( passed ) ? "<font color=#009900> " + PASSED + : "<font color=#aa0000> " + FAILED + expect + "</tt>"; + writeLineToLog( s + "</font></b></tt>" ); + return passed; +} +function err( msg, page, line ) { + writeLineToLog( "Test failed on line " + line + " with the message: " + msg ); + + testcases[tc].actual = "error"; + testcases[tc].reason = msg; + writeTestCaseResult( testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual + + ": " + testcases[tc].reason ); + stopTest(); + return true; +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/instanceof/instanceof-001.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/instanceof/instanceof-001.js new file mode 100644 index 0000000..897c2e3 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/instanceof/instanceof-001.js @@ -0,0 +1,31 @@ +/** + File Name: instanceof-1.js + ECMA Section: + Description: instanceof operator + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = ""; + var VERSION = "ECMA_2"; + var TITLE = "instanceof operator"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var b = new Boolean(); + + testcases[tc++] = new TestCase( SECTION, + "var b = new Boolean(); b instanceof Boolean", + true, + b instanceof Boolean ); + + testcases[tc++] = new TestCase( SECTION, + "b instanceof Object", + true, + b instanceof Object ); + + test(); diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/instanceof/instanceof-002.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/instanceof/instanceof-002.js new file mode 100644 index 0000000..d07292d --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/instanceof/instanceof-002.js @@ -0,0 +1,61 @@ +/** + File Name: + ECMA Section: + Description: Call Objects + + + + Author: christine@netscape.com + Date: 12 november 1997 +*/ + var SECTION = ""; + var VERSION = "ECMA_2"; + var TITLE = "The Call Constructor"; + + startTest(); + writeHeaderToLog( SECTION + " "+ TITLE); + + var tc = 0; + var testcases = new Array(); + + var b = new Boolean(); + + testcases[tc++] = new TestCase( SECTION, + "var b = new Boolean(); b instanceof Boolean", + true, + b instanceof Boolean ); + + testcases[tc++] = new TestCase( SECTION, + "b instanceof Object", + true, + b instanceof Object ); + + testcases[tc++] = new TestCase( SECTION, + "b instanceof Array", + false, + b instanceof Array ); + + testcases[tc++] = new TestCase( SECTION, + "true instanceof Boolean", + false, + true instanceof Boolean ); + + testcases[tc++] = new TestCase( SECTION, + "Boolean instanceof Object", + true, + Boolean instanceof Object ); + test(); + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/instanceof/instanceof-003.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/instanceof/instanceof-003.js new file mode 100644 index 0000000..c8f84ba --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/instanceof/instanceof-003.js @@ -0,0 +1,57 @@ +/** + File Name: instanceof-003.js + ECMA Section: + Description: http://bugzilla.mozilla.org/show_bug.cgi?id=7635 + +js> function Foo() {} +js> theproto = {}; +[object Object] +js> Foo.prototype = theproto +[object Object] +js> theproto instanceof Foo +true + +I think this should be 'false' + + + Author: christine@netscape.com + Date: 12 november 1997 + + +The test case described above is correct, however the second test case in this file is not, +'o instanceof o' should thow an exception. According to ECMA-262: + + 8.6.2 Internal Properties and Methods: + "... only Function objects implement [[HasInstance]]" + 11.8.6 The instanceof operator: + "6.If Result(4) does not have a [[HasInstance]] method, throw a TypeError exception." + +{} does not implement [[HasInstance]] (since it is not a function), so passing it as the +constructor to be tested to instanceof should result in a TypeError being thrown. + +*/ + var SECTION = "instanceof-003"; + var VERSION = "ECMA_2"; + var TITLE = "instanceof operator"; + var BUGNUMBER ="http://bugzilla.mozilla.org/show_bug.cgi?id=7635"; + + startTest(); + + function Foo() {}; + theproto = {}; + Foo.prototype = theproto; + + AddTestCase( + "function Foo() = {}; theproto = {}; Foo.prototype = theproto; " + + "theproto instanceof Foo", + false, + theproto instanceof Foo ); + + + AddTestCase( + "o = {}; o instanceof o", + "EXCEPTION", + (function(){ try { var o = {}; o instanceof o; return "no exception"; } catch (e) { return "EXCEPTION"; } } )() ); + + + test(); diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/instanceof/regress-7635.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/instanceof/regress-7635.js new file mode 100644 index 0000000..cab6ed9 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/instanceof/regress-7635.js @@ -0,0 +1,70 @@ +/* +* The contents of this file are subject to the Netscape Public +* License Version 1.1 (the "License"); you may not use this file +* except in compliance with the License. You may obtain a copy of +* the License at http://www.mozilla.org/NPL/ +* +* Software distributed under the License is distributed on an "AS +* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or +* implied. See the License for the specific language governing +* rights and limitations under the License. +* +* The Original Code is mozilla.org code. +* +* The Initial Developer of the Original Code is Netscape +* Communications Corporation. Portions created by Netscape are +* Copyright (C) 1998 Netscape Communications Corporation. All +* Rights Reserved. +* +* Contributor(s): +*/ + +/** + * File Name: regress-7635.js + * Reference: http://bugzilla.mozilla.org/show_bug.cgi?id=7635 + * Description: instanceof tweaks + * Author: + */ + +var SECTION = "instanceof"; // provide a document reference (ie, ECMA section) +var VERSION = "ECMA_2"; // Version of JavaScript or ECMA +var TITLE = "Regression test for Bugzilla #7635"; // Provide ECMA section title or a description +var BUGNUMBER = "http://bugzilla.mozilla.org/show_bug.cgi?id=7635"; // Provide URL to bugsplat or bugzilla report + +startTest(); // leave this alone + +/* + * Calls to AddTestCase here. AddTestCase is a function that is defined + * in shell.js and takes three arguments: + * - a string representation of what is being tested + * - the expected result + * - the actual result + * + * For example, a test might look like this: + * + * var zip = /[\d]{5}$/; + * + * AddTestCase( + * "zip = /[\d]{5}$/; \"PO Box 12345 Boston, MA 02134\".match(zip)", // description of the test + * "02134", // expected result + * "PO Box 12345 Boston, MA 02134".match(zip) ); // actual result + * + */ + +function Foo() {} +theproto = {}; +Foo.prototype = theproto +theproto instanceof Foo + + +AddTestCase( "function Foo() {}; theproto = {}; Foo.prototype = theproto; theproto instanceof Foo", + false, + theproto instanceof Foo ); + +var f = new Function(); + +AddTestCase( "var f = new Function(); f instanceof f", false, f instanceof f ); + + +test(); // leave this alone. this executes the test cases and + // displays results. diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/jsref.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/jsref.js new file mode 100644 index 0000000..7dc729d --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/jsref.js @@ -0,0 +1,629 @@ +var completed = false; +var testcases; +var tc = 0; + +SECTION = ""; +VERSION = ""; +BUGNUMBER = ""; +EXCLUDE = ""; +BUGNUMBER = ""; + + +TZ_DIFF = -8; + +var TT = ""; +var TT_ = ""; +var BR = ""; +var NBSP = " "; +var CR = "\n"; +var FONT = ""; +var FONT_ = ""; +var FONT_RED = ""; +var FONT_GREEN = ""; +var B = ""; +var B_ = "" +var H2 = ""; +var H2_ = ""; +var HR = ""; +var DEBUG = false; + + +var PASSED = " PASSED!" +var FAILED = " FAILED! expected: "; +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} + +function TestCase( n, d, e, a ) { + this.name = n; + this.description = d; + this.expect = e; + this.actual = a; + this.passed = true; + this.reason = ""; + this.bugnumber = BUGNUMBER; + + this.passed = getTestCaseResult( this.expect, this.actual ); + if ( DEBUG ) { + writeLineToLog( "added " + this.description ); + } +} +function startTest() { + // JavaScript 1.3 is supposed to be compliant ecma version 1.0 + if ( VERSION == "ECMA_1" ) { + version ( "130" ); + } + if ( VERSION == "JS_13" ) { + version ( "130" ); + } + if ( VERSION == "JS_12" ) { + version ( "120" ); + } + if ( VERSION == "JS_11" ) { + version ( "110" ); + } + // for ecma version 2.0, we will leave the javascript version to + // the default ( for now ). + writeHeaderToLog( SECTION + " "+ TITLE); + testcases = new Array(); + tc = 0; + +} +function getTestCaseResult( expect, actual ) { + // because ( NaN == NaN ) always returns false, need to do + // a special compare to see if we got the right result. + if ( actual != actual ) { + if ( typeof actual == "object" ) { + actual = "NaN object"; + } else { + actual = "NaN number"; + } + } + if ( expect != expect ) { + if ( typeof expect == "object" ) { + expect = "NaN object"; + } else { + expect = "NaN number"; + } + } + + var passed = ( expect == actual ) ? true : false; + + // if both objects are numbers + // need to replace w/ IEEE standard for rounding + if ( !passed + && typeof(actual) == "number" + && typeof(expect) == "number" + ) { + if ( Math.abs(actual-expect) < 0.0000001 ) { + passed = true; + } + } + + // verify type is the same + if ( typeof(expect) != typeof(actual) ) { + passed = false; + } + + return passed; +} +function writeTestCaseResult( expect, actual, string ) { + var passed = getTestCaseResult( expect, actual ); + writeFormattedResult( expect, actual, string, passed ); + return passed; +} +function writeFormattedResult( expect, actual, string, passed ) { + var s = TT + string ; + + for ( k = 0; + k < (60 - string.length >= 0 ? 60 - string.length : 5) ; + k++ ) { + } + + s += B ; + s += ( passed ) ? FONT_GREEN + NBSP + PASSED : FONT_RED + NBSP + FAILED + expect + TT_ ; + + writeLineToLog( s + FONT_ + B_ + TT_ ); + + return passed; +} + +function writeLineToLog( string ) { + print( string + BR + CR ); +} +function writeHeaderToLog( string ) { + print( H2 + string + H2_ ); +} +function stopTest() +{ + var sizeTag = "<#TEST CASES SIZE>"; + var doneTag = "<#TEST CASES DONE>"; + var beginTag = "<#TEST CASE "; + var endTag = ">"; + + print(sizeTag); + print(testcases.length); + for (tc = 0; tc < testcases.length; tc++) + { + print(beginTag + 'PASSED' + endTag); + print(testcases[tc].passed); + print(beginTag + 'NAME' + endTag); + print(testcases[tc].name); + print(beginTag + 'EXPECTED' + endTag); + print(testcases[tc].expect); + print(beginTag + 'ACTUAL' + endTag); + print(testcases[tc].actual); + print(beginTag + 'DESCRIPTION' + endTag); + print(testcases[tc].description); + print(beginTag + 'REASON' + endTag); + print(( testcases[tc].passed ) ? "" : "wrong value "); + print(beginTag + 'BUGNUMBER' + endTag); + print( BUGNUMBER ); + } + print(doneTag); + print( HR ); + gc(); +} +function getFailedCases() { + for ( var i = 0; i < testcases.length; i++ ) { + if ( ! testcases[i].passed ) { + print( testcases[i].description +" = " +testcases[i].actual +" expected: "+ testcases[i].expect ); + } + } +} +function err( msg, page, line ) { + testcases[tc].actual = "error"; + testcases[tc].reason = msg; + writeTestCaseResult( testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual + + ": " + testcases[tc].reason ); + stopTest(); + return true; +} + +/** + * Type Conversion functions used by Type Conversion + * + */ + + + + /* + * Date functions used by tests in Date suite + * + */ +var msPerDay = 86400000; +var HoursPerDay = 24; +var MinutesPerHour = 60; +var SecondsPerMinute = 60; +var msPerSecond = 1000; +var msPerMinute = 60000; // msPerSecond * SecondsPerMinute +var msPerHour = 3600000; // msPerMinute * MinutesPerHour + +var TIME_1970 = 0; +var TIME_2000 = 946684800000; +var TIME_1900 = -2208988800000; + +function Day( t ) { + return ( Math.floor(t/msPerDay ) ); +} +function DaysInYear( y ) { + if ( y % 4 != 0 ) { + return 365; + } + if ( (y % 4 == 0) && (y % 100 != 0) ) { + return 366; + } + if ( (y % 100 == 0) && (y % 400 != 0) ) { + return 365; + } + if ( (y % 400 == 0) ){ + return 366; + } else { + return "ERROR: DaysInYear(" + y + ") case not covered"; + } +} +function TimeInYear( y ) { + return ( DaysInYear(y) * msPerDay ); +} +function DayNumber( t ) { + return ( Math.floor( t / msPerDay ) ); +} +function TimeWithinDay( t ) { + if ( t < 0 ) { + return ( (t % msPerDay) + msPerDay ); + } else { + return ( t % msPerDay ); + } +} +function YearNumber( t ) { +} +function TimeFromYear( y ) { + return ( msPerDay * DayFromYear(y) ); +} +function DayFromYear( y ) { + return ( 365*(y-1970) + + Math.floor((y-1969)/4) - + Math.floor((y-1901)/100) + + Math.floor((y-1601)/400) ); +} +function InLeapYear( t ) { + if ( DaysInYear(YearFromTime(t)) == 365 ) { + return 0; + } + if ( DaysInYear(YearFromTime(t)) == 366 ) { + return 1; + } else { + return "ERROR: InLeapYear("+t+") case not covered"; + } +} +function YearFromTime( t ) { + t = Number( t ); + var sign = ( t < 0 ) ? -1 : 1; + var year = ( sign < 0 ) ? 1969 : 1970; + for ( var timeToTimeZero = t; ; ) { + // subtract the current year's time from the time that's left. + timeToTimeZero -= sign * TimeInYear(year) + + // if there's less than the current year's worth of time left, then break. + if ( sign < 0 ) { + if ( sign * timeToTimeZero <= 0 ) { + break; + } else { + year += sign; + } + } else { + if ( sign * timeToTimeZero < 0 ) { + break; + } else { + year += sign; + } + } + } + return ( year ); +} +function MonthFromTime( t ) { + // i know i could use switch but i'd rather not until it's part of ECMA + var day = DayWithinYear( t ); + var leap = InLeapYear(t); + + if ( (0 <= day) && (day < 31) ) { + return 0; + } + if ( (31 <= day) && (day < (59+leap)) ) { + return 1; + } + if ( ((59+leap) <= day) && (day < (90+leap)) ) { + return 2; + } + if ( ((90+leap) <= day) && (day < (120+leap)) ) { + return 3; + } + if ( ((120+leap) <= day) && (day < (151+leap)) ) { + return 4; + } + if ( ((151+leap) <= day) && (day < (181+leap)) ) { + return 5; + } + if ( ((181+leap) <= day) && (day < (212+leap)) ) { + return 6; + } + if ( ((212+leap) <= day) && (day < (243+leap)) ) { + return 7; + } + if ( ((243+leap) <= day) && (day < (273+leap)) ) { + return 8; + } + if ( ((273+leap) <= day) && (day < (304+leap)) ) { + return 9; + } + if ( ((304+leap) <= day) && (day < (334+leap)) ) { + return 10; + } + if ( ((334+leap) <= day) && (day < (365+leap)) ) { + return 11; + } else { + return "ERROR: MonthFromTime("+t+") not known"; + } +} +function DayWithinYear( t ) { + return( Day(t) - DayFromYear(YearFromTime(t))); +} +function DateFromTime( t ) { + var day = DayWithinYear(t); + var month = MonthFromTime(t); + + if ( month == 0 ) { + return ( day + 1 ); + } + if ( month == 1 ) { + return ( day - 30 ); + } + if ( month == 2 ) { + return ( day - 58 - InLeapYear(t) ); + } + if ( month == 3 ) { + return ( day - 89 - InLeapYear(t)); + } + if ( month == 4 ) { + return ( day - 119 - InLeapYear(t)); + } + if ( month == 5 ) { + return ( day - 150- InLeapYear(t)); + } + if ( month == 6 ) { + return ( day - 180- InLeapYear(t)); + } + if ( month == 7 ) { + return ( day - 211- InLeapYear(t)); + } + if ( month == 8 ) { + return ( day - 242- InLeapYear(t)); + } + if ( month == 9 ) { + return ( day - 272- InLeapYear(t)); + } + if ( month == 10 ) { + return ( day - 303- InLeapYear(t)); + } + if ( month == 11 ) { + return ( day - 333- InLeapYear(t)); + } + + return ("ERROR: DateFromTime("+t+") not known" ); +} +function WeekDay( t ) { + var weekday = (Day(t)+4) % 7; + return( weekday < 0 ? 7 + weekday : weekday ); +} + +// missing daylight savins time adjustment + +function HourFromTime( t ) { + var h = Math.floor( t / msPerHour ) % HoursPerDay; + return ( (h<0) ? HoursPerDay + h : h ); +} +function MinFromTime( t ) { + var min = Math.floor( t / msPerMinute ) % MinutesPerHour; + return( ( min < 0 ) ? MinutesPerHour + min : min ); +} +function SecFromTime( t ) { + var sec = Math.floor( t / msPerSecond ) % SecondsPerMinute; + return ( (sec < 0 ) ? SecondsPerMinute + sec : sec ); +} +function msFromTime( t ) { + var ms = t % msPerSecond; + return ( (ms < 0 ) ? msPerSecond + ms : ms ); +} +function LocalTZA() { + return ( TZ_DIFF * msPerHour ); +} +function UTC( t ) { + return ( t - LocalTZA() - DaylightSavingTA(t - LocalTZA()) ); +} +function DaylightSavingTA( t ) { + t = t - LocalTZA(); + + var dst_start = GetSecondSundayInMarch(t) + 2*msPerHour; + var dst_end = GetFirstSundayInNovember(t)+ 2*msPerHour; + + if ( t >= dst_start && t < dst_end ) { + return msPerHour; + } else { + return 0; + } + + // Daylight Savings Time starts on the first Sunday in April at 2:00AM in + // PST. Other time zones will need to override this function. + + print( new Date( UTC(dst_start + LocalTZA())) ); + + return UTC(dst_start + LocalTZA()); +} + +function GetFirstSundayInApril( t ) { + var year = YearFromTime(t); + var leap = InLeapYear(t); + + var april = TimeFromYear(year) + TimeInMonth(0, leap) + TimeInMonth(1,leap) + + TimeInMonth(2,leap); + + for ( var first_sunday = april; WeekDay(first_sunday) > 0; + first_sunday += msPerDay ) + { + ; + } + + return first_sunday; +} +function GetLastSundayInOctober( t ) { + var year = YearFromTime(t); + var leap = InLeapYear(t); + + for ( var oct = TimeFromYear(year), m = 0; m < 9; m++ ) { + oct += TimeInMonth(m, leap); + } + for ( var last_sunday = oct + 30*msPerDay; WeekDay(last_sunday) > 0; + last_sunday -= msPerDay ) + { + ; + } + return last_sunday; +} + +// Added these two functions because DST rules changed for the US. +function GetSecondSundayInMarch( t ) { + var year = YearFromTime(t); + var leap = InLeapYear(t); + + var march = TimeFromYear(year) + TimeInMonth(0, leap) + TimeInMonth(1,leap); + + var sundayCount = 0; + var flag = true; + for ( var second_sunday = march; flag; second_sunday += msPerDay ) + { + if (WeekDay(second_sunday) == 0) { + if(++sundayCount == 2) + flag = false; + } + } + + return second_sunday; +} +function GetFirstSundayInNovember( t ) { + var year = YearFromTime(t); + var leap = InLeapYear(t); + + for ( var nov = TimeFromYear(year), m = 0; m < 10; m++ ) { + nov += TimeInMonth(m, leap); + } + for ( var first_sunday = nov; WeekDay(first_sunday) > 0; + first_sunday += msPerDay ) + { + ; + } + return first_sunday; +} +function LocalTime( t ) { + return ( t + LocalTZA() + DaylightSavingTA(t) ); +} +function MakeTime( hour, min, sec, ms ) { + if ( isNaN( hour ) || isNaN( min ) || isNaN( sec ) || isNaN( ms ) ) { + return Number.NaN; + } + + hour = ToInteger(hour); + min = ToInteger( min); + sec = ToInteger( sec); + ms = ToInteger( ms ); + + return( (hour*msPerHour) + (min*msPerMinute) + + (sec*msPerSecond) + ms ); +} +function MakeDay( year, month, date ) { + if ( isNaN(year) || isNaN(month) || isNaN(date) ) { + return Number.NaN; + } + year = ToInteger(year); + month = ToInteger(month); + date = ToInteger(date ); + + var sign = ( year < 1970 ) ? -1 : 1; + var t = ( year < 1970 ) ? 1 : 0; + var y = ( year < 1970 ) ? 1969 : 1970; + + var result5 = year + Math.floor( month/12 ); + var result6 = month % 12; + + if ( year < 1970 ) { + for ( y = 1969; y >= year; y += sign ) { + t += sign * TimeInYear(y); + } + } else { + for ( y = 1970 ; y < year; y += sign ) { + t += sign * TimeInYear(y); + } + } + + var leap = InLeapYear( t ); + + for ( var m = 0; m < month; m++ ) { + t += TimeInMonth( m, leap ); + } + + if ( YearFromTime(t) != result5 ) { + return Number.NaN; + } + if ( MonthFromTime(t) != result6 ) { + return Number.NaN; + } + if ( DateFromTime(t) != 1 ) { + return Number.NaN; + } + + return ( (Day(t)) + date - 1 ); +} +function TimeInMonth( month, leap ) { + // september april june november + // jan 0 feb 1 mar 2 apr 3 may 4 june 5 jul 6 + // aug 7 sep 8 oct 9 nov 10 dec 11 + + if ( month == 3 || month == 5 || month == 8 || month == 10 ) { + return ( 30*msPerDay ); + } + + // all the rest + if ( month == 0 || month == 2 || month == 4 || month == 6 || + month == 7 || month == 9 || month == 11 ) { + return ( 31*msPerDay ); + } + + // save february + return ( (leap == 0) ? 28*msPerDay : 29*msPerDay ); +} +function MakeDate( day, time ) { + if ( day == Number.POSITIVE_INFINITY || + day == Number.NEGATIVE_INFINITY || + day == Number.NaN ) { + return Number.NaN; + } + if ( time == Number.POSITIVE_INFINITY || + time == Number.POSITIVE_INFINITY || + day == Number.NaN) { + return Number.NaN; + } + return ( day * msPerDay ) + time; +} +function TimeClip( t ) { + if ( isNaN( t ) ) { + return ( Number.NaN ); + } + if ( Math.abs( t ) > 8.64e15 ) { + return ( Number.NaN ); + } + + return ( ToInteger( t ) ); +} +function ToInteger( t ) { + t = Number( t ); + + if ( isNaN( t ) ){ + return ( Number.NaN ); + } + if ( t == 0 || t == -0 || + t == Number.POSITIVE_INFINITY || t == Number.NEGATIVE_INFINITY ) { + return 0; + } + + var sign = ( t < 0 ) ? -1 : 1; + + return ( sign * Math.floor( Math.abs( t ) ) ); +} +function Enumerate ( o ) { + var properties = new Array(); + for ( p in o ) { + properties[ properties.length ] = new Array( p, o[p] ); + } + return properties; +} +function AddTestCase( description, expect, actual ) { + testcases[tc++] = new TestCase( SECTION, description, expect, actual ); +} +function getFailedCases() { + for ( var i = 0; i < testcases.length; i++ ) { + if ( ! testcases[i].passed ) { + print( testcases[i].description +" = " +testcases[i].actual +" expected: "+ testcases[i].expect ); + } + } +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/shell.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/shell.js new file mode 100644 index 0000000..eb70069 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/shell.js @@ -0,0 +1,216 @@ +/* +* The contents of this file are subject to the Netscape Public +* License Version 1.1 (the "License"); you may not use this file +* except in compliance with the License. You may obtain a copy of +* the License at http://www.mozilla.org/NPL/ +* +* Software distributed under the License is distributed on an "AS +* IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or +* implied. See the License for the specific language governing +* rights and limitations under the License. +* +* The Original Code is mozilla.org code. +* +* The Initial Developer of the Original Code is Netscape +* Communications Corporation. Portions created by Netscape are +* Copyright (C) 1998 Netscape Communications Corporation. All +* Rights Reserved. +* +* Contributor(s): +*/ + + +/* + * JavaScript shared functions file for running the tests in either + * stand-alone JavaScript engine. To run a test, first load this file, + * then load the test script. + */ + +var completed = false; +var testcases; +var tc = 0; + +SECTION = ""; +VERSION = ""; +BUGNUMBER=""; + +var TZ_DIFF = getTimeZoneDiff(); + +var DEBUG = false; + +var GLOBAL = "[object global]"; +var PASSED = " PASSED!" +var FAILED = " FAILED! expected: "; + +function test() { + for ( tc=0; tc < testcases.length; tc++ ) { + testcases[tc].passed = writeTestCaseResult( + testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ + testcases[tc].actual ); + + testcases[tc].reason += ( testcases[tc].passed ) ? "" : "wrong value "; + } + stopTest(); + return ( testcases ); +} + +function TestCase( n, d, e, a ) { + this.name = n; + this.description = d; + this.expect = e; + this.actual = a; + this.passed = true; + this.reason = ""; + this.bugnumber = BUGNUMBER; + + this.passed = getTestCaseResult( this.expect, this.actual ); + if ( DEBUG ) { + writeLineToLog( "added " + this.description ); + } +} +function startTest() { + if ( version ) { + // JavaScript 1.3 is supposed to be compliant ecma version 1.0 + if ( VERSION == "ECMA_1" ) { + version ( 130 ); + } + if ( VERSION == "JS_13" ) { + version ( 130 ); + } + if ( VERSION == "JS_12" ) { + version ( 120 ); + } + if ( VERSION == "JS_11" ) { + version ( 110 ); + } + } + + + // for ecma version 2.0, we will leave the javascript version to + // the default ( for now ). + + writeHeaderToLog( SECTION + " "+ TITLE); + if ( BUGNUMBER ) { + writeLineToLog ("BUGNUMBER: " + BUGNUMBER ); + } + + testcases = new Array(); + tc = 0; +} + +function getTestCaseResult( expect, actual ) { + // because ( NaN == NaN ) always returns false, need to do + // a special compare to see if we got the right result. + if ( actual != actual ) { + if ( typeof actual == "object" ) { + actual = "NaN object"; + } else { + actual = "NaN number"; + } + } + if ( expect != expect ) { + if ( typeof expect == "object" ) { + expect = "NaN object"; + } else { + expect = "NaN number"; + } + } + + var passed = ( expect == actual ) ? true : false; + + // if both objects are numbers + // need to replace w/ IEEE standard for rounding + if ( !passed + && typeof(actual) == "number" + && typeof(expect) == "number" + ) { + if ( Math.abs(actual-expect) < 0.0000001 ) { + passed = true; + } + } + + // verify type is the same + if ( typeof(expect) != typeof(actual) ) { + passed = false; + } + + return passed; +} + +function writeTestCaseResult( expect, actual, string ) { + var passed = getTestCaseResult( expect, actual ); + writeFormattedResult( expect, actual, string, passed ); + return passed; +} + +function writeFormattedResult( expect, actual, string, passed ) { + var s = string ; + s += ( passed ) ? PASSED : FAILED + expect; + writeLineToLog( s); + return passed; +} + +function writeLineToLog( string ) { + print( string ); +} +function writeHeaderToLog( string ) { + print( string ); +} +function stopTest() { + var gc; + if ( gc != undefined ) { + gc(); + } +} +function getFailedCases() { + for ( var i = 0; i < testcases.length; i++ ) { + if ( ! testcases[i].passed ) { + print( testcases[i].description +" = " +testcases[i].actual +" expected: "+ testcases[i].expect ); + } + } +} +function err( msg, page, line ) { + writeLineToLog( page + " failed with error: " + msg + " on line " + line ); + testcases[tc].actual = "error"; + testcases[tc].reason = msg; + writeTestCaseResult( testcases[tc].expect, + testcases[tc].actual, + testcases[tc].description +" = "+ testcases[tc].actual + + ": " + testcases[tc].reason ); + stopTest(); + return true; +} + +function Enumerate ( o ) { + var properties = new Array(); + for ( p in o ) { + properties[ properties.length ] = new Array( p, o[p] ); + } + return properties; +} + +function getFailedCases() { + for ( var i = 0; i < testcases.length; i++ ) { + if ( ! testcases[i].passed ) { + writeLineToLog( testcases[i].description +" = " +testcases[i].actual + + " expected: "+ testcases[i].expect ); + } + } +} +function AddTestCase( description, expect, actual ) { + testcases[tc++] = new TestCase( SECTION, description, expect, actual ); +} + + +/* + * Originally, the test suite used a hard-coded value TZ_DIFF = -8. + * But that was only valid for testers in the Pacific Standard Time Zone! + * We calculate the proper number dynamically for any tester. We just + * have to be careful to use a date not subject to Daylight Savings Time... +*/ +function getTimeZoneDiff() +{ + return -((new Date(2000, 1, 1)).getTimezoneOffset())/60; +} diff --git a/Source/JavaScriptCore/tests/mozilla/ecma_2/template.js b/Source/JavaScriptCore/tests/mozilla/ecma_2/template.js new file mode 100644 index 0000000..a30cb77 --- /dev/null +++ b/Source/JavaScriptCore/tests/mozilla/ecma_2/template.js @@ -0,0 +1,39 @@ +/* + * The contents of this file are subject to the Netscape Public + * License Version 1.1 (the "License"); you may not use this file + * except in compliance with the License. You may obtain a copy of + * the License at http://www.mozilla.org/NPL/ + * + * Software distributed under the License is distributed on an "AS + * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or + * implied. See the License for the specific language governing + * rights and limitations under the License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is Netscape + * Communications Corporation. Portions created by Netscape are + * Copyright (C) 1998 Netscape Communications Corporation. All + * Rights Reserved. + * + * Contributor(s): + */ + +/** + * File Name: template.js + * Reference: ** replace with bugzilla URL or document reference ** + * Description: ** replace with description of test ** + * Author: ** replace with your e-mail address ** + */ + + var SECTION = ""; // if ECMA test, provide section number + var VERSION = "ECMA_2"; // Version of JavaScript or ECMA + var TITLE = ""; // Provide ECMA section title or description + var BUGNUMBER = ""; // Provide URL to bugsplat or bugzilla report + + startTest(); // leave this alone + + + /* Calls to AddTestCase here */ + + test(); // leave this alone |