diff options
author | The Android Open Source Project <initial-contribution@android.com> | 2008-10-21 07:00:00 -0700 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2008-10-21 07:00:00 -0700 |
commit | 9364f22aed35e1a1e9d07c121510f80be3ab0502 (patch) | |
tree | d49911209b132da58d838efa852daf28d516df21 /JavaScriptCore/tests/mozilla/js1_6 | |
parent | 87eb0cb35bad8784770ebc807e6c982432e47107 (diff) | |
download | external_webkit-9364f22aed35e1a1e9d07c121510f80be3ab0502.zip external_webkit-9364f22aed35e1a1e9d07c121510f80be3ab0502.tar.gz external_webkit-9364f22aed35e1a1e9d07c121510f80be3ab0502.tar.bz2 |
Initial Contribution
Diffstat (limited to 'JavaScriptCore/tests/mozilla/js1_6')
22 files changed, 2321 insertions, 0 deletions
diff --git a/JavaScriptCore/tests/mozilla/js1_6/Array/browser.js b/JavaScriptCore/tests/mozilla/js1_6/Array/browser.js new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/JavaScriptCore/tests/mozilla/js1_6/Array/browser.js @@ -0,0 +1 @@ + diff --git a/JavaScriptCore/tests/mozilla/js1_6/Array/regress-290592.js b/JavaScriptCore/tests/mozilla/js1_6/Array/regress-290592.js new file mode 100644 index 0000000..a0c53ca --- /dev/null +++ b/JavaScriptCore/tests/mozilla/js1_6/Array/regress-290592.js @@ -0,0 +1,693 @@ +/* -*- 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): Mike Shaver + * Bob Clary + * + * 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 bug = 290592; +var summary = 'Array extras: forEach, indexOf, filter, map'; +var actual = ''; +var expect = ''; + +printBugNumber (bug); +printStatus (summary); + +// Utility functions + +function identity(v, index, array) +{ + reportCompare(v, array[index], 'identity: check callback argument consistency'); + return v; +} + +function mutate(v, index, array) +{ + reportCompare(v, array[index], 'mutate: check callback argument consistency'); + if (index == 0) + { + array[1] = 'mutated'; + delete array[2]; + array.push('not visited'); + } + return v; +} + +function mutateForEach(v, index, array) +{ + reportCompare(v, array[index], 'mutateForEach: check callback argument consistency'); + if (index == 0) + { + array[1] = 'mutated'; + delete array[2]; + array.push('not visited'); + } + actual += v + ','; +} + +function makeUpperCase(v, index, array) +{ + reportCompare(v, array[index], 'makeUpperCase: check callback argument consistency'); + try + { + return v.toUpperCase(); + } + catch(e) + { + } + return v; +} + + +function concat(v, index, array) +{ + reportCompare(v, array[index], 'concat: check callback argument consistency'); + actual += v + ','; +} + + +function isUpperCase(v, index, array) +{ + reportCompare(v, array[index], 'isUpperCase: check callback argument consistency'); + try + { + return v == v.toUpperCase(); + } + catch(e) + { + } + return false; +} + +function isString(v, index, array) +{ + reportCompare(v, array[index], 'isString: check callback argument consistency'); + return typeof v == 'string'; +} + + +// callback object. +function ArrayCallback(state) +{ + this.state = state; +} + +ArrayCallback.prototype.makeUpperCase = function (v, index, array) +{ + reportCompare(v, array[index], 'ArrayCallback.prototype.makeUpperCase: check callback argument consistency'); + try + { + return this.state ? v.toUpperCase() : v.toLowerCase(); + } + catch(e) + { + } + return v; +}; + +ArrayCallback.prototype.concat = function(v, index, array) +{ + reportCompare(v, array[index], 'ArrayCallback.prototype.concat: check callback argument consistency'); + actual += v + ','; +}; + +ArrayCallback.prototype.isUpperCase = function(v, index, array) +{ + reportCompare(v, array[index], 'ArrayCallback.prototype.isUpperCase: check callback argument consistency'); + try + { + return this.state ? true : (v == v.toUpperCase()); + } + catch(e) + { + } + return false; +}; + +ArrayCallback.prototype.isString = function(v, index, array) +{ + reportCompare(v, array[index], 'ArrayCallback.prototype.isString: check callback argument consistency'); + return this.state ? true : (typeof v == 'string'); +}; + +function dumpError(e) +{ + var s = e.name + ': ' + e.message + + ' File: ' + e.fileName + + ', Line: ' + e.lineNumber + + ', Stack: ' + e.stack; + return s; +} + +var obj; +var strings = ['hello', 'Array', 'WORLD']; +var mixed = [0, '0', 0]; +var sparsestrings = new Array(); +sparsestrings[2] = 'sparse'; + +if ('map' in Array.prototype) +{ +// see http://developer-test.mozilla.org/docs/Core_JavaScript_1.5_Reference:Objects:Array:map + + // test Array.map + + // map has 1 required argument + expect = 1; + actual = Array.prototype.map.length; + reportCompare(expect, actual, 'Array.prototype.map.length == 1'); + + // throw TypeError if no callback function specified + expect = 'TypeError'; + try + { + strings.map(); + actual = 'no error'; + } + catch(e) + { + actual = e.name; + } + reportCompare(expect, actual, 'Array.map(undefined) throws TypeError'); + + try + { + // identity map + expect = 'hello,Array,WORLD'; + actual = strings.map(identity).toString(); + } + catch(e) + { + actual = dumpError(e); + } + reportCompare(expect, actual, 'Array.map: identity'); + + + try + { + expect = 'hello,mutated,'; + actual = strings.map(mutate).toString(); + } + catch(e) + { + actual = dumpError(e); + } + reportCompare(expect, actual, 'Array.map: mutate'); + + strings = ['hello', 'Array', 'WORLD']; + + try + { + // general map + expect = 'HELLO,ARRAY,WORLD'; + actual = strings.map(makeUpperCase).toString(); + } + catch(e) + { + actual = dumpError(e); + } + reportCompare(expect, actual, 'Array.map: uppercase'); + + try + { + // pass object method as map callback + expect = 'HELLO,ARRAY,WORLD'; + var obj = new ArrayCallback(true); + actual = strings.map(obj.makeUpperCase, obj).toString(); + } + catch(e) + { + actual = dumpError(e); + } + reportCompare(expect, actual, 'Array.map: uppercase with object callback'); + + try + { + expect = 'hello,array,world'; + obj = new ArrayCallback(false); + actual = strings.map(obj.makeUpperCase, obj).toString(); + } + catch(e) + { + actual = dumpError(e); + } + reportCompare(expect, actual, 'Array.map: lowercase with object callback'); + + try + { + // map on sparse arrays + expect = ',,SPARSE'; + actual = sparsestrings.map(makeUpperCase).toString(); + } + catch(e) + { + actual = dumpError(e); + } + reportCompare(expect, actual, 'Array.map: uppercase on sparse array'); +} + +if ('forEach' in Array.prototype) +{ +// see http://developer-test.mozilla.org/docs/Core_JavaScript_1.5_Reference:Objects:Array:forEach + + // test Array.forEach + + // forEach has 1 required argument + expect = 1; + actual = Array.prototype.forEach.length; + reportCompare(expect, actual, 'Array.prototype.forEach.length == 1'); + + // throw TypeError if no callback function specified + expect = 'TypeError'; + try + { + strings.forEach(); + actual = 'no error'; + } + catch(e) + { + actual = e.name; + } + reportCompare(expect, actual, 'Array.forEach(undefined) throws TypeError'); + + try + { + // general forEach + expect = 'hello,Array,WORLD,'; + actual = ''; + strings.forEach(concat); + } + catch(e) + { + actual = dumpError(e); + } + reportCompare(expect, actual, 'Array.forEach'); + + try + { + expect = 'hello,mutated,'; + actual = ''; + strings.forEach(mutateForEach); + } + catch(e) + { + actual = dumpError(e); + } + reportCompare(expect, actual, 'Array.forEach: mutate'); + + strings = ['hello', 'Array', 'WORLD']; + + + + try + { + // pass object method as forEach callback + expect = 'hello,Array,WORLD,'; + actual = ''; + obj = new ArrayCallback(true); + strings.forEach(obj.concat, obj); + } + catch(e) + { + actual = dumpError(e); + } + reportCompare(expect, actual, 'Array.forEach with object callback 1'); + + try + { + expect = 'hello,Array,WORLD,'; + actual = ''; + obj = new ArrayCallback(false); + strings.forEach(obj.concat, obj); + } + catch(e) + { + actual = dumpError(e); + } + reportCompare(expect, actual, 'Array.forEach with object callback 2'); + + try + { + // test forEach on sparse arrays + // see https://bugzilla.mozilla.org/show_bug.cgi?id=311082 + expect = 'sparse,'; + actual = ''; + sparsestrings.forEach(concat); + } + catch(e) + { + actual = dumpError(e); + } + reportCompare(expect, actual, 'Array.forEach on sparse array'); +} + +if ('filter' in Array.prototype) +{ +// see http://developer-test.mozilla.org/docs/Core_JavaScript_1.5_Reference:Objects:Array:filter + + // test Array.filter + + // filter has 1 required argument + expect = 1; + actual = Array.prototype.filter.length; + reportCompare(expect, actual, 'Array.prototype.filter.length == 1'); + + // throw TypeError if no callback function specified + expect = 'TypeError'; + try + { + strings.filter(); + actual = 'no error'; + } + catch(e) + { + actual = e.name; + } + reportCompare(expect, actual, 'Array.filter(undefined) throws TypeError'); + + try + { + // test general filter + expect = 'WORLD'; + actual = strings.filter(isUpperCase).toString(); + } + catch(e) + { + actual = dumpError(e); + } + reportCompare(expect, actual, 'Array.filter'); + + try + { + expect = 'WORLD'; + obj = new ArrayCallback(false); + actual = strings.filter(obj.isUpperCase, obj).toString(); + } + catch(e) + { + actual = dumpError(e); + } + reportCompare(expect, actual, 'Array.filter object callback 1'); + + try + { + expect = 'hello,Array,WORLD'; + obj = new ArrayCallback(true); + actual = strings.filter(obj.isUpperCase, obj).toString(); + } + catch(e) + { + actual = dumpError(e); + } + reportCompare(expect, actual, 'Array.filter object callback 2'); +} + +if ('every' in Array.prototype) +{ +// see http://developer-test.mozilla.org/docs/Core_JavaScript_1.5_Reference:Objects:Array:every + + // test Array.every + + // every has 1 required argument + + expect = 1; + actual = Array.prototype.every.length; + reportCompare(expect, actual, 'Array.prototype.every.length == 1'); + + // throw TypeError if no every callback function specified + expect = 'TypeError'; + try + { + strings.every(); + actual = 'no error'; + } + catch(e) + { + actual = e.name; + } + reportCompare(expect, actual, 'Array.every(undefined) throws TypeError'); + + // test general every + + try + { + expect = true; + actual = strings.every(isString); + } + catch(e) + { + actual = dumpError(e); + } + reportCompare(expect, actual, 'strings: every element is a string'); + + try + { + expect = false; + actual = mixed.every(isString); + } + catch(e) + { + actual = dumpError(e); + } + reportCompare(expect, actual, 'mixed: every element is a string'); + + try + { + // see https://bugzilla.mozilla.org/show_bug.cgi?id=311082 + expect = true; + actual = sparsestrings.every(isString); + } + catch(e) + { + actual = dumpError(e); + } + reportCompare(expect, actual, 'sparsestrings: every element is a string'); + + // pass object method as map callback + + obj = new ArrayCallback(false); + + try + { + expect = true; + actual = strings.every(obj.isString, obj); + } + catch(e) + { + actual = dumpError(e); + } + reportCompare(expect, actual, 'strings: every element is a string, via object callback'); + + try + { + expect = false; + actual = mixed.every(obj.isString, obj); + } + catch(e) + { + actual = dumpError(e) ; + } + reportCompare(expect, actual, 'mixed: every element is a string, via object callback'); + + try + { + // see https://bugzilla.mozilla.org/show_bug.cgi?id=311082 + expect = true; + actual = sparsestrings.every(obj.isString, obj); + } + catch(e) + { + actual = dumpError(e); + } + reportCompare(expect, actual, 'sparsestrings: every element is a string, via object callback'); + +} + +if ('some' in Array.prototype) +{ +// see http://developer-test.mozilla.org/docs/Core_JavaScript_1.5_Reference:Objects:Array:some + + // test Array.some + + // some has 1 required argument + + expect = 1; + actual = Array.prototype.some.length; + reportCompare(expect, actual, 'Array.prototype.some.length == 1'); + + // throw TypeError if no some callback function specified + expect = 'TypeError'; + try + { + strings.some(); + actual = 'no error'; + } + catch(e) + { + actual = e.name; + } + reportCompare(expect, actual, 'Array.some(undefined) throws TypeError'); + + // test general some + + try + { + expect = true; + actual = strings.some(isString); + } + catch(e) + { + actual = dumpError(e); + } + reportCompare(expect, actual, 'strings: some element is a string'); + + try + { + expect = true; + actual = mixed.some(isString); + } + catch(e) + { + actual = dumpError(e); + } + reportCompare(expect, actual, 'mixed: some element is a string'); + + try + { + expect = true; + actual = sparsestrings.some(isString); + } + catch(e) + { + actual = dumpError(e); + } + reportCompare(expect, actual, 'sparsestrings: some element is a string'); + + // pass object method as map callback + + obj = new ArrayCallback(false); + + try + { + expect = true; + actual = strings.some(obj.isString, obj); + } + catch(e) + { + actual = dumpError(e); + } + reportCompare(expect, actual, 'strings: some element is a string, via object callback'); + + try + { + expect = true; + actual = mixed.some(obj.isString, obj); + } + catch(e) + { + actual = dumpError(e); + } + reportCompare(expect, actual, 'mixed: some element is a string, via object callback'); + + try + { + expect = true; + actual = sparsestrings.some(obj.isString, obj); + } + catch(e) + { + actual = dumpError(e); + } + reportCompare(expect, actual, 'sparsestrings: some element is a string, via object callback'); + +} + +if ('indexOf' in Array.prototype) +{ +// see http://developer-test.mozilla.org/docs/Core_JavaScript_1.5_Reference:Objects:Array:indexOf + + // test Array.indexOf + + // indexOf has 1 required argument + + expect = 1; + actual = Array.prototype.indexOf.length; + reportCompare(expect, actual, 'Array.prototype.indexOf.length == 1'); + + // test general indexOf + + try + { + expect = -1; + actual = mixed.indexOf('not found'); + } + catch(e) + { + actual = dumpError(e); + } + reportCompare(expect, actual, 'indexOf returns -1 if value not found'); + + try + { + expect = 0; + actual = mixed.indexOf(0); + } + catch(e) + { + actual = dumpError(e); + } + reportCompare(expect, actual, 'indexOf matches using strict equality'); + + try + { + expect = 1; + actual = mixed.indexOf('0'); + } + catch(e) + { + actual = dumpError(e); + } + reportCompare(expect, actual, 'indexOf matches using strict equality'); + + try + { + expect = 2; + actual = mixed.indexOf(0, 1); + } + catch(e) + { + actual = dumpError(e); + } + reportCompare(expect, actual, 'indexOf begins searching at fromIndex'); +} + diff --git a/JavaScriptCore/tests/mozilla/js1_6/Array/regress-304828.js b/JavaScriptCore/tests/mozilla/js1_6/Array/regress-304828.js new file mode 100644 index 0000000..5cab4a7 --- /dev/null +++ b/JavaScriptCore/tests/mozilla/js1_6/Array/regress-304828.js @@ -0,0 +1,270 @@ +/* -*- 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): + * + * 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 bug = 304828; +var summary = 'Array Generic Methods'; +var actual = ''; +var expect = ''; +printBugNumber (bug); +printStatus (summary); + +var value; + +// use Array methods on a String +// join +value = '123'; +expect = '1,2,3'; +try +{ + actual = Array.prototype.join.call(value); +} +catch(e) +{ + actual = e + ''; +} +reportCompare(expect, actual, summary + ': join'); + +// reverse +value = '123'; +expect = '123'; +try +{ + actual = Array.prototype.reverse.call(value) + ''; +} +catch(e) +{ + actual = e + ''; +} +reportCompare(expect, actual, summary + ': reverse'); + +// sort +value = 'cba'; +expect = 'cba'; +try +{ + actual = Array.prototype.sort.call(value) + ''; +} +catch(e) +{ + actual = e + ''; +} +reportCompare(expect, actual, summary + ': sort'); + +// push +value = 'abc'; +expect = 6; +try +{ + actual = Array.prototype.push.call(value, 'd', 'e', 'f'); +} +catch(e) +{ + actual = e + ''; +} +reportCompare(expect, actual, summary + ': push'); +reportCompare('abc', value, summary + ': push'); + +// pop +value = 'abc'; +expect = 'c'; +try +{ + actual = Array.prototype.pop.call(value); +} +catch(e) +{ + actual = e + ''; +} +reportCompare(expect, actual, summary + ': pop'); +reportCompare('abc', value, summary + ': pop'); + +// unshift +value = 'def'; +expect = 6; +try +{ + actual = Array.prototype.unshift.call(value, 'a', 'b', 'c'); +} +catch(e) +{ + actual = e + ''; +} +reportCompare(expect, actual, summary + ': unshift'); +reportCompare('def', value, summary + ': unshift'); + +// shift +value = 'abc'; +expect = 'a'; +try +{ + actual = Array.prototype.shift.call(value); +} +catch(e) +{ + actual = e + ''; +} +reportCompare(expect, actual, summary + ': shift'); +reportCompare('abc', value, summary + ': shift'); + +// splice +value = 'abc'; +expect = 'b'; +try +{ + actual = Array.prototype.splice.call(value, 1, 1) + ''; +} +catch(e) +{ + actual = e + ''; +} +reportCompare(expect, actual, summary + ': splice'); + +// concat +value = 'abc'; +expect = 'abc,d,e,f'; +try +{ + actual = Array.prototype.concat.call(value, 'd', 'e', 'f') + ''; +} +catch(e) +{ + actual = e + ''; +} +reportCompare(expect, actual, summary + ': concat'); + +// slice +value = 'abc'; +expect = 'b'; +try +{ + actual = Array.prototype.slice.call(value, 1, 2) + ''; +} +catch(e) +{ + actual = e + ''; +} +reportCompare(expect, actual, summary + ': slice'); + +// indexOf +value = 'abc'; +expect = 1; +try +{ + actual = Array.prototype.indexOf.call(value, 'b'); +} +catch(e) +{ + actual = e + ''; +} +reportCompare(expect, actual, summary + ': indexOf'); + +// lastIndexOf +value = 'abcabc'; +expect = 4; +try +{ + actual = Array.prototype.lastIndexOf.call(value, 'b'); +} +catch(e) +{ + actual = e + ''; +} +reportCompare(expect, actual, summary + ': lastIndexOf'); + +// forEach +value = 'abc'; +expect = 'ABC'; +actual = ''; +try +{ + Array.prototype.forEach.call(value, + function (v, index, array) + {actual += array[index].toUpperCase();}); +} +catch(e) +{ + actual = e + ''; +} +reportCompare(expect, actual, summary + ': forEach'); + +// map +value = 'abc'; +expect = 'A,B,C'; +try +{ + actual = Array.prototype.map.call(value, + function (v, index, array) + {return v.toUpperCase();}) + ''; +} +catch(e) +{ + actual = e + ''; +} +reportCompare(expect, actual, summary + ': map'); + +// filter +value = '1234567890'; +expect = '2,4,6,8,0'; +try +{ + actual = Array.prototype.filter.call(value, + function (v, index, array) + {return array[index] % 2 == 0;}) + ''; +} +catch(e) +{ + actual = e + ''; +} +reportCompare(expect, actual, summary + ': filter'); + +// every +value = '1234567890'; +expect = false; +try +{ + actual = Array.prototype.every.call(value, + function (v, index, array) + {return array[index] % 2 == 0;}); +} +catch(e) +{ + actual = e + ''; +} +reportCompare(expect, actual, summary + ': every'); + + + diff --git a/JavaScriptCore/tests/mozilla/js1_6/Array/regress-305002.js b/JavaScriptCore/tests/mozilla/js1_6/Array/regress-305002.js new file mode 100644 index 0000000..d2c316a --- /dev/null +++ b/JavaScriptCore/tests/mozilla/js1_6/Array/regress-305002.js @@ -0,0 +1,56 @@ +/* -*- 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): Hans-Andreas Engel + * + * 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 bug = 305002; +var summary = '[].every(f) == true'; +var actual = ''; +var expect = ''; + +printBugNumber (bug); +printStatus (summary); + +var notcalled = true; + +function callback() +{ + notcalled = false; +} + +expect = true; +actual = [].every(callback) && notcalled; + +reportCompare(expect, actual, summary); diff --git a/JavaScriptCore/tests/mozilla/js1_6/Array/regress-310425-01.js b/JavaScriptCore/tests/mozilla/js1_6/Array/regress-310425-01.js new file mode 100644 index 0000000..64f543f --- /dev/null +++ b/JavaScriptCore/tests/mozilla/js1_6/Array/regress-310425-01.js @@ -0,0 +1,58 @@ +/* -*- 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): Igor Bukanov + * + * 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 bug = 310425; +var summary = 'Array.indexOf/lastIndexOf edge cases'; +var actual = ''; +var expect = ''; + +printBugNumber (bug); +printStatus (summary); + +expect = -1; +actual = [].lastIndexOf(undefined, -1); +reportCompare(expect, actual, summary); + +expect = -1; +actual = [].indexOf(undefined, -1); +reportCompare(expect, actual, summary); + +var x = []; +x[1 << 30] = 1; +expect = (1 << 30); +actual = x.lastIndexOf(1); +reportCompare(expect, actual, summary); diff --git a/JavaScriptCore/tests/mozilla/js1_6/Array/regress-310425-02.js b/JavaScriptCore/tests/mozilla/js1_6/Array/regress-310425-02.js new file mode 100644 index 0000000..f0309a7 --- /dev/null +++ b/JavaScriptCore/tests/mozilla/js1_6/Array/regress-310425-02.js @@ -0,0 +1,48 @@ +/* -*- 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): Igor Bukanov + * + * 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 bug = 310425; +var summary = 'Array.indexOf/lastIndexOf edge cases'; +var actual = ''; +var expect = ''; + +printBugNumber (bug); +printStatus (summary); + +expect = -1; +actual = Array(1).indexOf(1); +reportCompare(expect, actual, summary); diff --git a/JavaScriptCore/tests/mozilla/js1_6/Array/regress-320887.js b/JavaScriptCore/tests/mozilla/js1_6/Array/regress-320887.js new file mode 100644 index 0000000..323bc3c --- /dev/null +++ b/JavaScriptCore/tests/mozilla/js1_6/Array/regress-320887.js @@ -0,0 +1,55 @@ +/* -*- 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): Blake Kaplan + * + * 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 bug = 320887; +var summary = 'var x should not throw a ReferenceError'; +var actual = 'No error'; +var expect = 'No error'; + +printBugNumber (bug); +printStatus (summary); + +try +{ + (function xxx() { ["var x"].map(eval); })() +} +catch(ex) +{ + actual = ex + ''; +} + +reportCompare(expect, actual, summary); diff --git a/JavaScriptCore/tests/mozilla/js1_6/Array/shell.js b/JavaScriptCore/tests/mozilla/js1_6/Array/shell.js new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/JavaScriptCore/tests/mozilla/js1_6/Array/shell.js @@ -0,0 +1 @@ + diff --git a/JavaScriptCore/tests/mozilla/js1_6/Regress/browser.js b/JavaScriptCore/tests/mozilla/js1_6/Regress/browser.js new file mode 100644 index 0000000..b262fa1 --- /dev/null +++ b/JavaScriptCore/tests/mozilla/js1_6/Regress/browser.js @@ -0,0 +1 @@ +// dummy file diff --git a/JavaScriptCore/tests/mozilla/js1_6/Regress/regress-301574.js b/JavaScriptCore/tests/mozilla/js1_6/Regress/regress-301574.js new file mode 100644 index 0000000..28b1d1a --- /dev/null +++ b/JavaScriptCore/tests/mozilla/js1_6/Regress/regress-301574.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) 2005 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): Wladimir Palant + * shutdown + * + * 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 bug = 301574; +var summary = 'E4X should be enabled even when e4x=1 not specified'; +var actual = 'No error'; +var expect = 'No error'; + +printBugNumber (bug); +printStatus (summary); + +try +{ + var xml = XML('<xml/>'); +} +catch(e) +{ + actual = 'error: ' + e; +} + +reportCompare(expect, actual, summary + ': XML()'); + +try +{ + var xml = XML('<p>text</p>'); +} +catch(e) +{ + actual = 'error: ' + e; +} + +reportCompare(expect, actual, summary + ': XMLList()'); diff --git a/JavaScriptCore/tests/mozilla/js1_6/Regress/regress-309242.js b/JavaScriptCore/tests/mozilla/js1_6/Regress/regress-309242.js new file mode 100644 index 0000000..a97bede --- /dev/null +++ b/JavaScriptCore/tests/mozilla/js1_6/Regress/regress-309242.js @@ -0,0 +1,75 @@ +/* -*- 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): + * + * 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 bug = 309242; +var summary = 'E4X should be on by default while preserving comment hack'; +var actual = ''; +var expect = ''; + +printBugNumber (bug); +printStatus (summary); + +/* + E4X should be available regardless of script type + <!-- and --> should begin comment to end of line + unless type=text/javascript;e4x=1 +*/ + +expect = true; +actual = true; +// the next line will be ignored when e4x is not requested +<!-- comment -->; actual = false; + +reportCompare(expect, actual, summary + ': <!-- is comment to end of line'); + +expect = true; +actual = false; +// the next line will be ignored when e4x is not requested +<!-- +actual = true; +// --> + +reportCompare(expect, actual, summary + ': comment hack works inside script'); + +// E4X is available always + +var x = <foo/>; + +expect = 'element'; +actual = x.nodeKind(); + +reportCompare(expect, actual, summary + ': E4X is available'); diff --git a/JavaScriptCore/tests/mozilla/js1_6/Regress/regress-311157-01.js b/JavaScriptCore/tests/mozilla/js1_6/Regress/regress-311157-01.js new file mode 100644 index 0000000..46af70c --- /dev/null +++ b/JavaScriptCore/tests/mozilla/js1_6/Regress/regress-311157-01.js @@ -0,0 +1,55 @@ +/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* ***** 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): Brendan Eich + * + * 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 bug = 311157; +var summary = 'Comment-hiding compromise left E4X parsing/scanning inconsistent'; +var actual = 'No Crash'; +var expect = 'No Crash'; + +printBugNumber (bug); +printStatus (summary); + +try +{ + eval('var x = <hi> <!-- duh -->\n there </hi>'); +} +catch(e) +{ +} + +reportCompare(expect, actual, summary); + diff --git a/JavaScriptCore/tests/mozilla/js1_6/Regress/regress-311157-02.js b/JavaScriptCore/tests/mozilla/js1_6/Regress/regress-311157-02.js new file mode 100644 index 0000000..a7ef464 --- /dev/null +++ b/JavaScriptCore/tests/mozilla/js1_6/Regress/regress-311157-02.js @@ -0,0 +1,55 @@ +/* -*- Mode: java; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ +/* ***** 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): Brendan Eich + * + * 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 bug = 311157; +var summary = 'Comment-hiding compromise left E4X parsing/scanning inconsistent'; +var actual = 'No Crash'; +var expect = 'No Crash'; + +printBugNumber (bug); +printStatus (summary); + +try +{ + eval('var x = <hi> <![CDATA[ duh ]]>\n there </hi>'); +} +catch(e) +{ +} + +reportCompare(expect, actual, summary); + diff --git a/JavaScriptCore/tests/mozilla/js1_6/Regress/regress-314887.js b/JavaScriptCore/tests/mozilla/js1_6/Regress/regress-314887.js new file mode 100644 index 0000000..61cb87a --- /dev/null +++ b/JavaScriptCore/tests/mozilla/js1_6/Regress/regress-314887.js @@ -0,0 +1,51 @@ +/* -*- 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): + * + * 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 bug = 314887; +var summary = 'Do not crash when morons embed script tags in external script files'; +var actual = 'No Crash'; +var expect = 'No Crash'; + +printBugNumber (bug); +printStatus (summary); + +<script language="JavaScript" type="text/JavaScript"> +<!-- +//--> +</script> + +reportCompare(expect, actual, summary); diff --git a/JavaScriptCore/tests/mozilla/js1_6/Regress/regress-320172.js b/JavaScriptCore/tests/mozilla/js1_6/Regress/regress-320172.js new file mode 100644 index 0000000..badd987 --- /dev/null +++ b/JavaScriptCore/tests/mozilla/js1_6/Regress/regress-320172.js @@ -0,0 +1,56 @@ +/* -*- 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): shutdown@flashmail.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 bug = 320172; +var summary = 'Regression from bug 285219'; +var actual = 'No Crash'; +var expect = 'No Crash'; + +enterFunc ('test'); +printBugNumber (bug); +printStatus (summary); + +try +{ + (function xxx(){ ["var x"].forEach(eval); })(); +} +catch(ex) +{ +} + +printStatus('No Crash'); +reportCompare(expect, actual, summary); diff --git a/JavaScriptCore/tests/mozilla/js1_6/Regress/shell.js b/JavaScriptCore/tests/mozilla/js1_6/Regress/shell.js new file mode 100644 index 0000000..b262fa1 --- /dev/null +++ b/JavaScriptCore/tests/mozilla/js1_6/Regress/shell.js @@ -0,0 +1 @@ +// dummy file diff --git a/JavaScriptCore/tests/mozilla/js1_6/String/browser.js b/JavaScriptCore/tests/mozilla/js1_6/String/browser.js new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/JavaScriptCore/tests/mozilla/js1_6/String/browser.js @@ -0,0 +1 @@ + diff --git a/JavaScriptCore/tests/mozilla/js1_6/String/regress-306591.js b/JavaScriptCore/tests/mozilla/js1_6/String/regress-306591.js new file mode 100644 index 0000000..df498c3 --- /dev/null +++ b/JavaScriptCore/tests/mozilla/js1_6/String/regress-306591.js @@ -0,0 +1,95 @@ +/* -*- 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): nanto_vi + * + * 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 bug = 306591; +var summary = 'String static methods'; +var actual = ''; +var expect = ''; + +printBugNumber (bug); +printStatus (summary); +printStatus ('See https://bugzilla.mozilla.org/show_bug.cgi?id=304828'); + +expect = ['a', 'b', 'c'].toString(); +actual = String.split(new String('abc'), '').toString(); +reportCompare(expect, actual, summary + + " String.split(new String('abc'), '')"); + +expect = '2'; +actual = String.substring(new Number(123), 1, 2); +reportCompare(expect, actual, summary + + " String.substring(new Number(123), 1, 2)"); + +expect = 'TRUE'; +actual = String.toUpperCase(new Boolean(true)); +reportCompare(expect, actual, summary + + " String.toUpperCase(new Boolean(true))"); + +expect = 2; +actual = String.indexOf(null, 'l'); +reportCompare(expect, actual, summary + + " String.indexOf(null, 'l')"); + +expect = 2; +actual = String.indexOf(String(null), 'l'); +reportCompare(expect, actual, summary + + " String.indexOf(String(null), 'l')"); + +expect = ['a', 'b', 'c'].toString(); +actual = String.split('abc', '').toString(); +reportCompare(expect, actual, summary + + " String.split('abc', '')"); + +expect = '2'; +actual = String.substring(123, 1, 2); +reportCompare(expect, actual, summary + + " String.substring(123, 1, 2)"); + +expect = 'TRUE'; +actual = String.toUpperCase(true); +reportCompare(expect, actual, summary + + " String.toUpperCase(true)"); + +expect = 2; +actual = String.indexOf(undefined, 'd'); +reportCompare(expect, actual, summary + + " String.indexOf(undefined, 'd')"); + +expect = 2; +actual = String.indexOf(String(undefined), 'd'); +reportCompare(expect, actual, summary + + " String.indexOf(String(undefined), 'd')"); diff --git a/JavaScriptCore/tests/mozilla/js1_6/String/shell.js b/JavaScriptCore/tests/mozilla/js1_6/String/shell.js new file mode 100644 index 0000000..8b13789 --- /dev/null +++ b/JavaScriptCore/tests/mozilla/js1_6/String/shell.js @@ -0,0 +1 @@ + diff --git a/JavaScriptCore/tests/mozilla/js1_6/browser.js b/JavaScriptCore/tests/mozilla/js1_6/browser.js new file mode 100644 index 0000000..c11f6c6 --- /dev/null +++ b/JavaScriptCore/tests/mozilla/js1_6/browser.js @@ -0,0 +1,147 @@ +/* -*- 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): + * + * 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 ***** */ + +/* + * 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> + */ +function writeLineToLog( string ) { + document.write( string + "<br>\n"); +} + +var testcases = new Array(); +var tc = testcases.length; +var bug = ''; +var summary = ''; +var description = ''; +var expected = ''; +var actual = ''; +var msg = ''; + + +function TestCase(n, d, e, a) +{ + this.path = (typeof gTestPath == 'undefined') ? '' : gTestPath; + this.name = n; + this.description = d; + this.expect = e; + this.actual = a; + this.passed = ( e == a ); + this.reason = ''; + this.bugnumber = typeof(bug) != 'undefined' ? bug : ''; + testcases[tc++] = this; +} + +var gInReportCompare = false; + +var _reportCompare = reportCompare; + +reportCompare = function(expected, actual, description) +{ + gInReportCompare = true; + + var testcase = new TestCase(gTestName, description, expected, actual); + testcase.passed = _reportCompare(expected, actual, description); + + gInReportCompare = false; +}; + +var _reportFailure = reportFailure; +reportFailure = function (msg, page, line) +{ + var testcase; + + if (gInReportCompare) + { + testcase = testcases[tc - 1]; + testcase.passed = false; + } + else + { + if (typeof DESCRIPTION == 'undefined') + { + DESCRIPTION = 'Unknown'; + } + if (typeof EXPECTED == 'undefined') + { + EXPECTED = 'Unknown'; + } + testcase = new TestCase(gTestName, DESCRIPTION, EXPECTED, "error"); + if (document.location.href.indexOf('-n.js') != -1) + { + // negative test + testcase.passed = true; + } + } + + testcase.reason += msg; + + if (typeof(page) != 'undefined') + { + testcase.reason += ' Page: ' + page; + } + if (typeof(line) != 'undefined') + { + testcase.reason += ' Line: ' + line; + } + if (!testcase.passed) + { + _reportFailure(msg); + } + +}; + +function gc() +{ +} + +function quit() +{ +} + +window.onerror = reportFailure; + diff --git a/JavaScriptCore/tests/mozilla/js1_6/shell.js b/JavaScriptCore/tests/mozilla/js1_6/shell.js new file mode 100644 index 0000000..a1c08c0 --- /dev/null +++ b/JavaScriptCore/tests/mozilla/js1_6/shell.js @@ -0,0 +1,477 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * + * ***** 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 Communicator client code, released + * March 31, 1998. + * + * 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): + * Rob Ginda rginda@netscape.com + * Bob Clary bob@bclary.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 FAILED = "FAILED!: "; +var STATUS = "STATUS: "; +var BUGNUMBER = "BUGNUMBER: "; +var VERBOSE = false; +var SECT_PREFIX = 'Section '; +var SECT_SUFFIX = ' of test -'; +var callStack = new Array(); + +function writeLineToLog( string ) { + print( string + "\n"); +} +/* + * The test driver searches for such a phrase in the test output. + * If such phrase exists, it will set n as the expected exit code. + */ +function expectExitCode(n) +{ + + writeLineToLog('--- NOTE: IN THIS TESTCASE, WE EXPECT EXIT CODE ' + n + ' ---'); + +} + +/* + * Statuses current section of a test + */ +function inSection(x) +{ + + return SECT_PREFIX + x + SECT_SUFFIX; + +} + +/* + * Some tests need to know if we are in Rhino as opposed to SpiderMonkey + */ +function inRhino() +{ + return (typeof defineClass == "function"); +} + +/* + * Report a failure in the 'accepted' manner + */ +function reportFailure (msg) +{ + var lines = msg.split ("\n"); + var l; + var funcName = currentFunc(); + var prefix = (funcName) ? "[reported from " + funcName + "] ": ""; + + for (var i=0; i<lines.length; i++) + writeLineToLog (FAILED + prefix + lines[i]); + +} + +/* + * Print a non-failure message. + */ +function printStatus (msg) +{ + msg = String(msg); + msg = msg.toString(); + var lines = msg.split ("\n"); + var l; + + for (var i=0; i<lines.length; i++) + writeLineToLog (STATUS + lines[i]); + +} + +/* + * Print a bugnumber message. + */ +function printBugNumber (num) +{ + + writeLineToLog (BUGNUMBER + num); + +} + +/* + * Compare expected result to actual result, if they differ (in value and/or + * type) report a failure. If description is provided, include it in the + * failure report. + */ +function reportCompare (expected, actual, description) +{ + var expected_t = typeof expected; + var actual_t = typeof actual; + var output = ""; + + if ((VERBOSE) && (typeof description != "undefined")) + printStatus ("Comparing '" + description + "'"); + + if (expected_t != actual_t) + output += "Type mismatch, expected type " + expected_t + + ", actual type " + actual_t + "\n"; + else if (VERBOSE) + printStatus ("Expected type '" + actual_t + "' matched actual " + + "type '" + expected_t + "'"); + + if (expected != actual) + output += "Expected value '" + expected + "', Actual value '" + actual + + "'\n"; + else if (VERBOSE) + printStatus ("Expected value '" + actual + "' matched actual " + + "value '" + expected + "'"); + + if (output != "") + { + if (typeof description != "undefined") + reportFailure (description); + reportFailure (output); + } + return (output == ""); // true if passed +} + +/* + * Puts funcName at the top of the call stack. This stack is used to show + * a function-reported-from field when reporting failures. + */ +function enterFunc (funcName) +{ + + if (!funcName.match(/\(\)$/)) + funcName += "()"; + + callStack.push(funcName); + +} + +/* + * Pops the top funcName off the call stack. funcName is optional, and can be + * used to check push-pop balance. + */ +function exitFunc (funcName) +{ + var lastFunc = callStack.pop(); + + if (funcName) + { + if (!funcName.match(/\(\)$/)) + funcName += "()"; + + if (lastFunc != funcName) + reportFailure ("Test driver failure, expected to exit function '" + + funcName + "' but '" + lastFunc + "' came off " + + "the stack"); + } + +} + +/* + * Peeks at the top of the call stack. + */ +function currentFunc() +{ + + return callStack[callStack.length - 1]; + +} + +/* + Calculate the "order" of a set of data points {X: [], Y: []} + by computing successive "derivatives" of the data until + the data is exhausted or the derivative is linear. +*/ +function BigO(data) +{ + var order = 0; + var origLength = data.X.length; + + while (data.X.length > 2) + { + var lr = new LinearRegression(data); + if (lr.b > 1e-6) + { + // only increase the order if the slope + // is "great" enough + order++; + } + + if (lr.r > 0.98 || lr.Syx < 1 || lr.b < 1e-6) + { + // terminate if close to a line lr.r + // small error lr.Syx + // small slope lr.b + break; + } + data = dataDeriv(data); + } + + if (2 == origLength - order) + { + order = Number.POSITIVE_INFINITY; + } + return order; + + function LinearRegression(data) + { + /* + y = a + bx + for data points (Xi, Yi); 0 <= i < n + + b = (n*SUM(XiYi) - SUM(Xi)*SUM(Yi))/(n*SUM(Xi*Xi) - SUM(Xi)*SUM(Xi)) + a = (SUM(Yi) - b*SUM(Xi))/n + */ + var i; + + if (data.X.length != data.Y.length) + { + throw 'LinearRegression: data point length mismatch'; + } + if (data.X.length < 3) + { + throw 'LinearRegression: data point length < 2'; + } + var n = data.X.length; + var X = data.X; + var Y = data.Y; + + this.Xavg = 0; + this.Yavg = 0; + + var SUM_X = 0; + var SUM_XY = 0; + var SUM_XX = 0; + var SUM_Y = 0; + var SUM_YY = 0; + + for (i = 0; i < n; i++) + { + SUM_X += X[i]; + SUM_XY += X[i]*Y[i]; + SUM_XX += X[i]*X[i]; + SUM_Y += Y[i]; + SUM_YY += Y[i]*Y[i]; + } + + this.b = (n * SUM_XY - SUM_X * SUM_Y)/(n * SUM_XX - SUM_X * SUM_X); + this.a = (SUM_Y - this.b * SUM_X)/n; + + this.Xavg = SUM_X/n; + this.Yavg = SUM_Y/n; + + var SUM_Ydiff2 = 0; + var SUM_Xdiff2 = 0; + var SUM_XdiffYdiff = 0; + + for (i = 0; i < n; i++) + { + var Ydiff = Y[i] - this.Yavg; + var Xdiff = X[i] - this.Xavg; + + SUM_Ydiff2 += Ydiff * Ydiff; + SUM_Xdiff2 += Xdiff * Xdiff; + SUM_XdiffYdiff += Xdiff * Ydiff; + } + + var Syx2 = (SUM_Ydiff2 - Math.pow(SUM_XdiffYdiff/SUM_Xdiff2, 2))/(n - 2); + var r2 = Math.pow((n*SUM_XY - SUM_X * SUM_Y), 2) / + ((n*SUM_XX - SUM_X*SUM_X)*(n*SUM_YY-SUM_Y*SUM_Y)); + + this.Syx = Math.sqrt(Syx2); + this.r = Math.sqrt(r2); + + } + + function dataDeriv(data) + { + if (data.X.length != data.Y.length) + { + throw 'length mismatch'; + } + var length = data.X.length; + + if (length < 2) + { + throw 'length ' + length + ' must be >= 2'; + } + var X = data.X; + var Y = data.Y; + + var deriv = {X: [], Y: [] }; + + for (var i = 0; i < length - 1; i++) + { + deriv.X[i] = (X[i] + X[i+1])/2; + deriv.Y[i] = (Y[i+1] - Y[i])/(X[i+1] - X[i]); + } + return deriv; + } + +} + +/* JavaScriptOptions + encapsulate the logic for setting and retrieving the values + of the javascript options. + + Note: in shell, options() takes an optional comma delimited list + of option names, toggles the values for each option and returns the + list of option names which were set before the call. + If no argument is passed to options(), it returns the current + options with value true. + + Usage; + + // create and initialize object. + jsOptions = new JavaScriptOptions(); + + // set a particular option + jsOptions.setOption(name, boolean); + + // reset all options to their original values. + jsOptions.reset(); +*/ + +function JavaScriptOptions() +{ + this.orig = {}; + this.orig.strict = this.strict = false; + this.orig.werror = this.werror = false; + + this.privileges = 'UniversalXPConnect'; + + if (typeof options == 'function') + { + // shell + var optString = options(); + if (optString) + { + var optList = optString.split(','); + for (iOpt = 0; i < optList.length; iOpt++) + { + optName = optList[iOpt]; + this[optName] = true; + } + } + } + else if (typeof document != 'undefined') + { + // browser + netscape.security.PrivilegeManager.enablePrivilege(this.privileges); + + var preferences = Components.classes['@mozilla.org/preferences;1']; + if (!preferences) + { + throw 'JavaScriptOptions: unable to get @mozilla.org/preference;1'; + } + + var prefService = preferences. + getService(Components.interfaces.nsIPrefService); + + if (!prefService) + { + throw 'JavaScriptOptions: unable to get nsIPrefService'; + } + + var pref = prefService.getBranch(''); + + if (!pref) + { + throw 'JavaScriptOptions: unable to get prefService branch'; + } + + try + { + this.orig.strict = this.strict = + pref.getBoolPref('javascript.options.strict'); + } + catch(e) + { + } + + try + { + this.orig.werror = this.werror = + pref.getBoolPref('javascript.options.werror'); + } + catch(e) + { + } + } +} + +JavaScriptOptions.prototype.setOption = +function (optionName, optionValue) +{ + if (typeof options == 'function') + { + // shell + if (this[optionName] != optionValue) + { + options(optionName); + } + } + else if (typeof document != 'undefined') + { + // browser + netscape.security.PrivilegeManager.enablePrivilege(this.privileges); + + var preferences = Components.classes['@mozilla.org/preferences;1']; + if (!preferences) + { + throw 'setOption: unable to get @mozilla.org/preference;1'; + } + + var prefService = preferences. + getService(Components.interfaces.nsIPrefService); + + if (!prefService) + { + throw 'setOption: unable to get nsIPrefService'; + } + + var pref = prefService.getBranch(''); + + if (!pref) + { + throw 'setOption: unable to get prefService branch'; + } + + pref.setBoolPref('javascript.options.' + optionName, optionValue); + } + + this[optionName] = optionValue; + + return; +} + + +JavaScriptOptions.prototype.reset = function () +{ + this.setOption('strict', this.orig.strict); + this.setOption('werror', this.orig.werror); +} diff --git a/JavaScriptCore/tests/mozilla/js1_6/template.js b/JavaScriptCore/tests/mozilla/js1_6/template.js new file mode 100644 index 0000000..dede379 --- /dev/null +++ b/JavaScriptCore/tests/mozilla/js1_6/template.js @@ -0,0 +1,57 @@ +/* -*- 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): + * + * 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 bug = 99999; +var summary = ''; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber (bug); + printStatus (summary); + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} |