diff options
Diffstat (limited to 'tests/auto/qml/parserstress/tests/ecma_3/Object')
13 files changed, 1352 insertions, 0 deletions
diff --git a/tests/auto/qml/parserstress/tests/ecma_3/Object/8.6.1-01.js b/tests/auto/qml/parserstress/tests/ecma_3/Object/8.6.1-01.js new file mode 100755 index 0000000000..2897ece555 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/Object/8.6.1-01.js @@ -0,0 +1,113 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla 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/MPL/ + * + * 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 JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Mozilla Foundation. + * Portions created by the Initial Developer are Copyright (C) 2005 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): Michael Daumling <daumling@adobe.com> + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +var gTestfile = '8.6.1-01.js'; +//----------------------------------------------------------------------------- + +var BUGNUMBER = 315436; +var summary = 'In strict mode, setting a read-only property should generate a warning'; + +printBugNumber(BUGNUMBER); +printStatus (summary); + +enterFunc (String (BUGNUMBER)); + +// should throw an error in strict mode +var actual = ''; +var expect = 's.length is read-only'; +var status = summary + ': Throw if STRICT and WERROR is enabled'; + +if (!options().match(/strict/)) +{ + options('strict'); +} +if (!options().match(/werror/)) +{ + options('werror'); +} + +try +{ + var s = new String ('abc'); + s.length = 0; +} +catch (e) +{ + actual = e.message; +} + +reportCompare(expect, actual, status); + +// should not throw an error if in strict mode and WERROR is false + +actual = 'did not throw'; +expect = 'did not throw'; +var status = summary + ': Do not throw if STRICT is enabled and WERROR is disabled'; + +// toggle werror off +options('werror'); + +try +{ + s.length = 0; +} +catch (e) +{ + actual = e.message; +} + +reportCompare(expect, actual, status); + +// should not throw an error if not in strict mode + +actual = 'did not throw'; +expect = 'did not throw'; +var status = summary + ': Do not throw if not in strict mode'; + +// toggle strict off +options('strict'); + +try +{ + s.length = 0; +} +catch (e) +{ + actual = e.message; +} + +reportCompare(expect, actual, status); diff --git a/tests/auto/qml/parserstress/tests/ecma_3/Object/8.6.2.6-001.js b/tests/auto/qml/parserstress/tests/ecma_3/Object/8.6.2.6-001.js new file mode 100644 index 0000000000..8fe2b23f4a --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/Object/8.6.2.6-001.js @@ -0,0 +1,113 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla 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/MPL/ + * + * 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 JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Netscape Communications Corp. + * Portions created by the Initial Developer are Copyright (C) 2002 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * pschwartau@netscape.com + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* + * + * Date: 09 September 2002 + * SUMMARY: Test for TypeError on invalid default string value of object + * See ECMA reference at http://bugzilla.mozilla.org/show_bug.cgi?id=167325 + * + */ +//----------------------------------------------------------------------------- +var gTestfile = '8.6.2.6-001.js'; +var UBound = 0; +var BUGNUMBER = 167325; +var summary = "Test for TypeError on invalid default string value of object"; +var TEST_PASSED = 'TypeError'; +var TEST_FAILED = 'Generated an error, but NOT a TypeError!'; +var TEST_FAILED_BADLY = 'Did not generate ANY error!!!'; +var status = ''; +var statusitems = []; +var actual = ''; +var actualvalues = []; +var expect= ''; +var expectedvalues = []; + + +status = inSection(1); +expect = TEST_PASSED; +actual = TEST_FAILED_BADLY; +/* + * This should generate a TypeError. See ECMA reference + * at http://bugzilla.mozilla.org/show_bug.cgi?id=167325 + */ +try +{ + var obj = {toString: function() {return new Object();}} + obj == 'abc'; +} +catch(e) +{ + if (e instanceof TypeError) + actual = TEST_PASSED; + else + actual = TEST_FAILED; +} +addThis(); + + + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + + +function addThis() +{ + statusitems[UBound] = status; + actualvalues[UBound] = actual; + expectedvalues[UBound] = expect; + UBound++; +} + + +function test() +{ + enterFunc('test'); + printBugNumber(BUGNUMBER); + printStatus(summary); + + for (var i=0; i<UBound; i++) + { + reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); + } + + exitFunc ('test'); +} diff --git a/tests/auto/qml/parserstress/tests/ecma_3/Object/browser.js b/tests/auto/qml/parserstress/tests/ecma_3/Object/browser.js new file mode 100644 index 0000000000..0e57d1fcd0 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/Object/browser.js @@ -0,0 +1,7 @@ +var GLOBAL = 'Window'; + +function isObject(obj) +{ + return obj instanceof Object || obj == window; +} + diff --git a/tests/auto/qml/parserstress/tests/ecma_3/Object/class-001.js b/tests/auto/qml/parserstress/tests/ecma_3/Object/class-001.js new file mode 100644 index 0000000000..faa2f4fceb --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/Object/class-001.js @@ -0,0 +1,156 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla 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/MPL/ + * + * 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 the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * pschwartau@netscape.com + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* + * Date: 14 Mar 2001 + * + * SUMMARY: Testing the internal [[Class]] property of objects + * See ECMA-262 Edition 3 13-Oct-1999, Section 8.6.2 + * + * The getJSClass() function we use is in a utility file, e.g. "shell.js". + */ +//----------------------------------------------------------------------------- +var gTestfile = 'class-001.js'; +var i = 0; +var UBound = 0; +var BUGNUMBER = '(none)'; +var summary = 'Testing the internal [[Class]] property of objects'; +var statprefix = 'Current object is: '; +var status = ''; var statusList = [ ]; +var actual = ''; var actualvalue = [ ]; +var expect= ''; var expectedvalue = [ ]; + + +status = 'the global object'; +actual = getJSClass(this); +expect = GLOBAL; +if (expect == 'Window' && actual == 'XPCCrossOriginWrapper') +{ + print('Skipping global object due to XPCCrossOriginWrapper. See bug 390946'); +} +else +{ + addThis(); +} + +status = 'new Object()'; +actual = getJSClass(new Object()); +expect = 'Object'; +addThis(); + +status = 'new Function()'; +actual = getJSClass(new Function()); +expect = 'Function'; +addThis(); + +status = 'new Array()'; +actual = getJSClass(new Array()); +expect = 'Array'; +addThis(); + +status = 'new String()'; +actual = getJSClass(new String()); +expect = 'String'; +addThis(); + +status = 'new Boolean()'; +actual = getJSClass(new Boolean()); +expect = 'Boolean'; +addThis(); + +status = 'new Number()'; +actual = getJSClass(new Number()); +expect = 'Number'; +addThis(); + +status = 'Math'; +actual = getJSClass(Math); // can't use 'new' with the Math object (EMCA3, 15.8) +expect = 'Math'; +addThis(); + +status = 'new Date()'; +actual = getJSClass(new Date()); +expect = 'Date'; +addThis(); + +status = 'new RegExp()'; +actual = getJSClass(new RegExp()); +expect = 'RegExp'; +addThis(); + +status = 'new Error()'; +actual = getJSClass(new Error()); +expect = 'Error'; +addThis(); + + + +//--------------------------------------------------------------------------------- +test(); +//--------------------------------------------------------------------------------- + + + +function addThis() +{ + statusList[UBound] = status; + actualvalue[UBound] = actual; + expectedvalue[UBound] = expect; + UBound++; +} + + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + for (i = 0; i < UBound; i++) + { + reportCompare(expectedvalue[i], actualvalue[i], getStatus(i)); + } + + exitFunc ('test'); +} + + +function getStatus(i) +{ + return statprefix + statusList[i]; +} diff --git a/tests/auto/qml/parserstress/tests/ecma_3/Object/class-002.js b/tests/auto/qml/parserstress/tests/ecma_3/Object/class-002.js new file mode 100644 index 0000000000..0b49ffd9db --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/Object/class-002.js @@ -0,0 +1,146 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla 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/MPL/ + * + * 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 the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * pschwartau@netscape.com + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* + * Date: 14 Mar 2001 + * + * SUMMARY: Testing the [[Class]] property of native constructors. + * See ECMA-262 Edition 3 13-Oct-1999, Section 8.6.2 re [[Class]] property. + * + * Same as class-001.js - but testing the constructors here, not + * object instances. Therefore we expect the [[Class]] property to + * equal 'Function' in each case. + * + * The getJSClass() function we use is in a utility file, e.g. "shell.js" + */ +//----------------------------------------------------------------------------- +var gTestfile = 'class-002.js'; +var i = 0; +var UBound = 0; +var BUGNUMBER = '(none)'; +var summary = 'Testing the internal [[Class]] property of native constructors'; +var statprefix = 'Current constructor is: '; +var status = ''; var statusList = [ ]; +var actual = ''; var actualvalue = [ ]; +var expect= ''; var expectedvalue = [ ]; + +/* + * We set the expect variable each time only for readability. + * We expect 'Function' every time; see discussion above - + */ +status = 'Object'; +actual = getJSClass(Object); +expect = 'Function'; +addThis(); + +status = 'Function'; +actual = getJSClass(Function); +expect = 'Function'; +addThis(); + +status = 'Array'; +actual = getJSClass(Array); +expect = 'Function'; +addThis(); + +status = 'String'; +actual = getJSClass(String); +expect = 'Function'; +addThis(); + +status = 'Boolean'; +actual = getJSClass(Boolean); +expect = 'Function'; +addThis(); + +status = 'Number'; +actual = getJSClass(Number); +expect = 'Function'; +addThis(); + +status = 'Date'; +actual = getJSClass(Date); +expect = 'Function'; +addThis(); + +status = 'RegExp'; +actual = getJSClass(RegExp); +expect = 'Function'; +addThis(); + +status = 'Error'; +actual = getJSClass(Error); +expect = 'Function'; +addThis(); + + + +//--------------------------------------------------------------------------------- +test(); +//--------------------------------------------------------------------------------- + + + +function addThis() +{ + statusList[UBound] = status; + actualvalue[UBound] = actual; + expectedvalue[UBound] = expect; + UBound++; +} + + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + for (i = 0; i < UBound; i++) + { + reportCompare(expectedvalue[i], actualvalue[i], getStatus(i)); + } + + exitFunc ('test'); +} + + +function getStatus(i) +{ + return statprefix + statusList[i]; +} diff --git a/tests/auto/qml/parserstress/tests/ecma_3/Object/class-003.js b/tests/auto/qml/parserstress/tests/ecma_3/Object/class-003.js new file mode 100644 index 0000000000..7afedb2985 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/Object/class-003.js @@ -0,0 +1,139 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla 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/MPL/ + * + * 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 the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * pschwartau@netscape.com + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* + * Date: 14 Mar 2001 + * + * SUMMARY: Testing the [[Class]] property of native error types. + * See ECMA-262 Edition 3, Section 8.6.2 for the [[Class]] property. + * + * Same as class-001.js - but testing only the native error types here. + * See ECMA-262 Edition 3, Section 15.11.6 for a list of these types. + * + * ECMA expects the [[Class]] property to equal 'Error' in each case. + * See ECMA-262 Edition 3, Sections 15.11.1.1 and 15.11.7.2 for this. + * See http://bugzilla.mozilla.org/show_bug.cgi?id=56868 + * + * The getJSClass() function we use is in a utility file, e.g. "shell.js" + */ +//----------------------------------------------------------------------------- +var gTestfile = 'class-003.js'; +var i = 0; +var UBound = 0; +var BUGNUMBER = 56868; +var summary = 'Testing the internal [[Class]] property of native error types'; +var statprefix = 'Current object is: '; +var status = ''; var statusList = [ ]; +var actual = ''; var actualvalue = [ ]; +var expect= ''; var expectedvalue = [ ]; + +/* + * We set the expect variable each time only for readability. + * We expect 'Error' every time; see discussion above - + */ +status = 'new Error()'; +actual = getJSClass(new Error()); +expect = 'Error'; +addThis(); + +status = 'new EvalError()'; +actual = getJSClass(new EvalError()); +expect = 'Error'; +addThis(); + +status = 'new RangeError()'; +actual = getJSClass(new RangeError()); +expect = 'Error'; +addThis(); + +status = 'new ReferenceError()'; +actual = getJSClass(new ReferenceError()); +expect = 'Error'; +addThis(); + +status = 'new SyntaxError()'; +actual = getJSClass(new SyntaxError()); +expect = 'Error'; +addThis(); + +status = 'new TypeError()'; +actual = getJSClass(new TypeError()); +expect = 'Error'; +addThis(); + +status = 'new URIError()'; +actual = getJSClass(new URIError()); +expect = 'Error'; +addThis(); + + + +//--------------------------------------------------------------------------------- +test(); +//--------------------------------------------------------------------------------- + + + +function addThis() +{ + statusList[UBound] = status; + actualvalue[UBound] = actual; + expectedvalue[UBound] = expect; + UBound++; +} + + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + for (i = 0; i < UBound; i++) + { + reportCompare(expectedvalue[i], actualvalue[i], getStatus(i)); + } + + exitFunc ('test'); +} + + +function getStatus(i) +{ + return statprefix + statusList[i]; +} diff --git a/tests/auto/qml/parserstress/tests/ecma_3/Object/class-004.js b/tests/auto/qml/parserstress/tests/ecma_3/Object/class-004.js new file mode 100644 index 0000000000..729b041086 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/Object/class-004.js @@ -0,0 +1,139 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla 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/MPL/ + * + * 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 the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * pschwartau@netscape.com + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* + * Date: 14 Mar 2001 + * + * SUMMARY: Testing [[Class]] property of native error constructors. + * See ECMA-262 Edition 3, Section 8.6.2 for the [[Class]] property. + * + * See ECMA-262 Edition 3, Section 15.11.6 for the native error types. + * See http://bugzilla.mozilla.org/show_bug.cgi?id=56868 + * + * Same as class-003.js - but testing the constructors here, not + * object instances. Therefore we expect the [[Class]] property to + * equal 'Function' in each case. + * + * The getJSClass() function we use is in a utility file, e.g. "shell.js" + */ +//----------------------------------------------------------------------------- +var gTestfile = 'class-004.js'; +var i = 0; +var UBound = 0; +var BUGNUMBER = 56868; +var summary = 'Testing the internal [[Class]] property of native error constructors'; +var statprefix = 'Current constructor is: '; +var status = ''; var statusList = [ ]; +var actual = ''; var actualvalue = [ ]; +var expect= ''; var expectedvalue = [ ]; + +/* + * We set the expect variable each time only for readability. + * We expect 'Function' every time; see discussion above - + */ +status = 'Error'; +actual = getJSClass(Error); +expect = 'Function'; +addThis(); + +status = 'EvalError'; +actual = getJSClass(EvalError); +expect = 'Function'; +addThis(); + +status = 'RangeError'; +actual = getJSClass(RangeError); +expect = 'Function'; +addThis(); + +status = 'ReferenceError'; +actual = getJSClass(ReferenceError); +expect = 'Function'; +addThis(); + +status = 'SyntaxError'; +actual = getJSClass(SyntaxError); +expect = 'Function'; +addThis(); + +status = 'TypeError'; +actual = getJSClass(TypeError); +expect = 'Function'; +addThis(); + +status = 'URIError'; +actual = getJSClass(URIError); +expect = 'Function'; +addThis(); + + + +//--------------------------------------------------------------------------------- +test(); +//--------------------------------------------------------------------------------- + + + +function addThis() +{ + statusList[UBound] = status; + actualvalue[UBound] = actual; + expectedvalue[UBound] = expect; + UBound++; +} + + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + for (i = 0; i < UBound; i++) + { + reportCompare(expectedvalue[i], actualvalue[i], getStatus(i)); + } + + exitFunc ('test'); +} + + +function getStatus(i) +{ + return statprefix + statusList[i]; +} diff --git a/tests/auto/qml/parserstress/tests/ecma_3/Object/class-005.js b/tests/auto/qml/parserstress/tests/ecma_3/Object/class-005.js new file mode 100644 index 0000000000..f57d0681cf --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/Object/class-005.js @@ -0,0 +1,124 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla 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/MPL/ + * + * 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 the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * pschwartau@netscape.com + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* + * Date: 14 Mar 2001 + * + * SUMMARY: Testing the internal [[Class]] property of user-defined types. + * See ECMA-262 Edition 3 13-Oct-1999, Section 8.6.2 re [[Class]] property. + * + * Same as class-001.js - but testing user-defined types here, not + * native types. Therefore we expect the [[Class]] property to equal + * 'Object' in each case - + * + * The getJSClass() function we use is in a utility file, e.g. "shell.js" + */ +//----------------------------------------------------------------------------- +var gTestfile = 'class-005.js'; +var i = 0; +var UBound = 0; +var BUGNUMBER = '(none)'; +var summary = 'Testing the internal [[Class]] property of user-defined types'; +var statprefix = 'Current user-defined type is: '; +var status = ''; var statusList = [ ]; +var actual = ''; var actualvalue = [ ]; +var expect= ''; var expectedvalue = [ ]; + + +Calf.prototype= new Cow(); + +/* + * We set the expect variable each time only for readability. + * We expect 'Object' every time; see discussion above - + */ +status = 'new Cow()'; +actual = getJSClass(new Cow()); +expect = 'Object'; +addThis(); + +status = 'new Calf()'; +actual = getJSClass(new Calf()); +expect = 'Object'; +addThis(); + + +//--------------------------------------------------------------------------------- +test(); +//--------------------------------------------------------------------------------- + + +function addThis() +{ + statusList[UBound] = status; + actualvalue[UBound] = actual; + expectedvalue[UBound] = expect; + UBound++; +} + + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + for (i = 0; i < UBound; i++) + { + reportCompare(expectedvalue[i], actualvalue[i], getStatus(i)); + } + + exitFunc ('test'); +} + + +function getStatus(i) +{ + return statprefix + statusList[i]; +} + + +function Cow(name) +{ + this.name=name; +} + + +function Calf(name) +{ + this.name=name; +} diff --git a/tests/auto/qml/parserstress/tests/ecma_3/Object/regress-361274.js b/tests/auto/qml/parserstress/tests/ecma_3/Object/regress-361274.js new file mode 100755 index 0000000000..d3962004e3 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/Object/regress-361274.js @@ -0,0 +1,66 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla 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/MPL/ + * + * 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 JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Mozilla Foundation. + * Portions created by the Initial Developer are Copyright (C) 2006 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): Jason Sachs + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +var gTestfile = 'regress-361274.js'; +//----------------------------------------------------------------------------- +var BUGNUMBER = 361274; +var summary = 'Embedded nulls in property names'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + var x='123'+'\0'+'456'; + var y='123'+'\0'+'789'; + var a={}; + a[x]=1; + a[y]=2; + + reportCompare(1, a[x], summary + ': 123\\0456'); + reportCompare(2, a[y], summary + ': 123\\0789'); + + exitFunc ('test'); +} diff --git a/tests/auto/qml/parserstress/tests/ecma_3/Object/regress-385393-07.js b/tests/auto/qml/parserstress/tests/ecma_3/Object/regress-385393-07.js new file mode 100755 index 0000000000..0473fe4956 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/Object/regress-385393-07.js @@ -0,0 +1,67 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla 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/MPL/ + * + * 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 JavaScript Engine testing utilities. + * + * The Initial Developer of the Original Code is + * Mozilla Foundation. + * Portions created by the Initial Developer are Copyright (C) 2007 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): Jesse Ruderman + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +var gTestfile = 'regress-385393-07.js'; + +//----------------------------------------------------------------------------- +var BUGNUMBER = 385393; +var summary = 'Regression test for bug 385393'; +var actual = 'No Crash'; +var expect = 'No Crash'; + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + try + { + (2).eval(); + } + catch(ex) + { + } + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/tests/auto/qml/parserstress/tests/ecma_3/Object/regress-72773.js b/tests/auto/qml/parserstress/tests/ecma_3/Object/regress-72773.js new file mode 100644 index 0000000000..5b0dee62bf --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/Object/regress-72773.js @@ -0,0 +1,97 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla 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/MPL/ + * + * 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 the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * pschwartau@netscape.com + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* + * Date: 09 May 2001 + * + * SUMMARY: Regression test: we shouldn't crash on this code + * See http://bugzilla.mozilla.org/show_bug.cgi?id=72773 + * + * See ECMA-262 Edition 3 13-Oct-1999, Section 8.6.2 re [[Class]] property. + * + * Same as class-001.js - but testing user-defined types here, not + * native types. Therefore we expect the [[Class]] property to equal + * 'Object' in each case - + * + * The getJSClass() function we use is in a utility file, e.g. "shell.js" + */ +//----------------------------------------------------------------------------- +var gTestfile = 'regress-72773.js'; +var BUGNUMBER = 72773; +var summary = "Regression test: we shouldn't crash on this code"; +var status = ''; +var actual = ''; +var expect = ''; +var sToEval = ''; + +/* + * This code should produce an error, but not a crash. + * 'TypeError: Function.prototype.toString called on incompatible object' + */ +sToEval += 'function Cow(name){this.name = name;}' +sToEval += 'function Calf(str){this.name = str;}' +sToEval += 'Calf.prototype = Cow;' +sToEval += 'new Calf().toString();' + +status = 'Trying to catch an expected error'; +try +{ + eval(sToEval); +} +catch(e) +{ + actual = getJSClass(e); + expect = 'Error'; +} + + +//---------------------------------------------------------------------------------------------- +test(); +//---------------------------------------------------------------------------------------------- + + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + reportCompare(expect, actual, status); + + exitFunc ('test'); +} diff --git a/tests/auto/qml/parserstress/tests/ecma_3/Object/regress-79129-001.js b/tests/auto/qml/parserstress/tests/ecma_3/Object/regress-79129-001.js new file mode 100644 index 0000000000..efafed8047 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/Object/regress-79129-001.js @@ -0,0 +1,80 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla 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/MPL/ + * + * 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 the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * pschwartau@netscape.com + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* + * Date: 06 May 2001 + * + * SUMMARY: Regression test: we shouldn't crash on this code + * + * See http://bugzilla.mozilla.org/show_bug.cgi?id=79129 + */ +//----------------------------------------------------------------------------- +var gTestfile = 'regress-79129-001.js'; +var BUGNUMBER = 79129; +var summary = "Regression test: we shouldn't crash on this code"; + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + tryThis(); + reportCompare('No Crash', 'No Crash', 'Should not crash'); + exitFunc ('test'); +} + + +function tryThis() +{ + obj={}; + obj.a = obj.b = obj.c = 1; + delete obj.a; + delete obj.b; + delete obj.c; + obj.d = obj.e = 1; + obj.a=1; + obj.b=1; + obj.c=1; + obj.d=1; + obj.e=1; +} diff --git a/tests/auto/qml/parserstress/tests/ecma_3/Object/shell.js b/tests/auto/qml/parserstress/tests/ecma_3/Object/shell.js new file mode 100644 index 0000000000..d0ee054485 --- /dev/null +++ b/tests/auto/qml/parserstress/tests/ecma_3/Object/shell.js @@ -0,0 +1,105 @@ +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla 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/MPL/ + * + * 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 the Initial Developer are Copyright (C) 1998 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * pschwartau@netscape.com + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +/* + * Date: 14 Mar 2001 + * + * SUMMARY: Utility functions for testing objects - + * + * Suppose obj is an instance of a native type, e.g. Number. + * Then obj.toString() invokes Number.prototype.toString(). + * We would also like to access Object.prototype.toString(). + * + * The difference is this: suppose obj = new Number(7). + * Invoking Number.prototype.toString() on this just returns 7. + * Object.prototype.toString() on this returns '[object Number]'. + * + * The getJSType() function below will return '[object Number]' for us. + * The getJSClass() function returns 'Number', the [[Class]] property of obj. + * See ECMA-262 Edition 3, 13-Oct-1999, Section 8.6.2 + */ +//----------------------------------------------------------------------------- + +gTestsubsuite = 'Object'; + +var cnNoObject = 'Unexpected Error!!! Parameter to this function must be an object'; +var cnNoClass = 'Unexpected Error!!! Cannot find Class property'; +var cnObjectToString = Object.prototype.toString; +var GLOBAL = 'global'; + +// checks that it's safe to call findType() +function getJSType(obj) +{ + if (isObject(obj)) + return findType(obj); + return cnNoObject; +} + + +// checks that it's safe to call findType() +function getJSClass(obj) +{ + if (isObject(obj)) + return findClass(findType(obj)); + return cnNoObject; +} + + +function findType(obj) +{ + return cnObjectToString.apply(obj); +} + + +// given '[object Number]', return 'Number' +function findClass(sType) +{ + var re = /^\[.*\s+(\w+)\s*\]$/; + var a = sType.match(re); + + if (a && a[1]) + return a[1]; + return cnNoClass; +} + + +function isObject(obj) +{ + return obj instanceof Object; +} + |