diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /js/src/tests/js1_7 | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'js/src/tests/js1_7')
201 files changed, 8411 insertions, 0 deletions
diff --git a/js/src/tests/js1_7/GC/browser.js b/js/src/tests/js1_7/GC/browser.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/src/tests/js1_7/GC/browser.js diff --git a/js/src/tests/js1_7/GC/regress-341675.js b/js/src/tests/js1_7/GC/regress-341675.js new file mode 100644 index 000000000..5dc7086a2 --- /dev/null +++ b/js/src/tests/js1_7/GC/regress-341675.js @@ -0,0 +1,35 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 341675; +var summary = 'Iterators: still infinite loop during GC'; +var actual = 'No Crash'; +var expect = 'No Crash'; + +printBugNumber(BUGNUMBER); +printStatus (summary); + +var globalToPokeGC = {}; + +function generator() +{ + try { + yield []; + } finally { + make_iterator(); + } +} + +function make_iterator() +{ + var iter = generator(); + iter.next(); +} + +make_iterator(); +gc(); + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/js1_7/GC/regress-381374.js b/js/src/tests/js1_7/GC/regress-381374.js new file mode 100644 index 000000000..4ad86780c --- /dev/null +++ b/js/src/tests/js1_7/GC/regress-381374.js @@ -0,0 +1,60 @@ +// |reftest| skip-if(Android) +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +//----------------------------------------------------------------------------- +var BUGNUMBER = 381374; +var summary = 'js_AddScopeProperty - overwrite property with watchpoint'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + function huh() + { + var f; + + Iterator; // ??? + + if (0 && 0) { + eval(""); // ??? + } + + f = new Function("x = 1"); + + try { + f(); + } catch(e) {} + } + + this.watch('x', function(){}); + this.__defineGetter__('x', new Function()); + huh(); + if (typeof gczeal == 'function') + { + gczeal(2); + } + + for (y in [0,1]) { this.__defineSetter__('x', function(){}); } + + if (typeof gczeal == 'function') + { + gczeal(0); + } + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/GC/shell.js b/js/src/tests/js1_7/GC/shell.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/src/tests/js1_7/GC/shell.js diff --git a/js/src/tests/js1_7/README b/js/src/tests/js1_7/README new file mode 100644 index 000000000..38286f771 --- /dev/null +++ b/js/src/tests/js1_7/README @@ -0,0 +1 @@ +JavaScript 1.7 diff --git a/js/src/tests/js1_7/browser.js b/js/src/tests/js1_7/browser.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/src/tests/js1_7/browser.js diff --git a/js/src/tests/js1_7/expressions/browser.js b/js/src/tests/js1_7/expressions/browser.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/src/tests/js1_7/expressions/browser.js diff --git a/js/src/tests/js1_7/expressions/destructuring-scope.js b/js/src/tests/js1_7/expressions/destructuring-scope.js new file mode 100644 index 000000000..374c1bec9 --- /dev/null +++ b/js/src/tests/js1_7/expressions/destructuring-scope.js @@ -0,0 +1,67 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 'none'; +var summary = 'Test destructuring assignments for differing scopes'; +var actual = ''; +var expect = ''; + +printBugNumber(BUGNUMBER); +printStatus (summary); + +function f() { + var x = 3; + if (x > 0) { + let {a:x} = {a:7}; + if (x != 7) + throw "fail"; + } + if (x != 3) + throw "fail"; +} + +function g() { + // Before JS1.7's destructuring for…in was fixed to match JS1.8's, + // the expected values were a == "x" and b == 7. + for (var [a,b] in {x:7}) { + if (a !== "x" || typeof b !== "undefined") + throw "fail"; + } + + { + // Before JS1.7's destructuring for…in was fixed to match JS1.8's, + // the expected values were a == "y" and b == 8. + for (let [a,b] in {y:8}) { + if (a !== "y" || typeof b !== "undefined") + throw "fail"; + } + } + + if (a !== "x" || typeof b !== "undefined") + throw "fail"; +} + +f(); +g(); + +if (typeof a != "undefined" || typeof b != "undefined" || typeof x != "undefined") + throw "fail"; + +function h() { + // Before JS1.7's destructuring for…in was fixed to match JS1.8's, + // the expected values were a == "x" and b == 9. + for ([a,b] in {z:9}) { + if (a !== "z" || typeof b !== "undefined") + throw "fail"; + } +} + +h(); + +if (a !== "z" || typeof b !== "undefined") + throw "fail"; + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/js1_7/expressions/regress-346203.js b/js/src/tests/js1_7/expressions/regress-346203.js new file mode 100644 index 000000000..1c18a09ac --- /dev/null +++ b/js/src/tests/js1_7/expressions/regress-346203.js @@ -0,0 +1,28 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 346203; +var summary = 'Do not crash during destructuring assignment '; +var actual = 'No Crash'; +var expect = 'No Crash'; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + var {b:{c:x}}={b:{c:1}} + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/expressions/regress-346645-01.js b/js/src/tests/js1_7/expressions/regress-346645-01.js new file mode 100644 index 000000000..9782fc82e --- /dev/null +++ b/js/src/tests/js1_7/expressions/regress-346645-01.js @@ -0,0 +1,34 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 346645; +var summary = 'Do not crash with empty object in destructuring assign LHS'; +var actual = 'No Crash'; +var expect = 'No Crash'; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + try + { + eval('({ a:{} }) = 3;'); + } + catch(ex) + { + } + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/expressions/regress-346645-02.js b/js/src/tests/js1_7/expressions/regress-346645-02.js new file mode 100644 index 000000000..f01781c67 --- /dev/null +++ b/js/src/tests/js1_7/expressions/regress-346645-02.js @@ -0,0 +1,34 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 346645; +var summary = 'Do not crash with empty array in destructuring assign LHS'; +var actual = 'No Crash'; +var expect = 'No Crash'; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + try + { + eval('({ a:[] }) = 3;'); + } + catch(ex) + { + } + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/expressions/regress-346645-03.js b/js/src/tests/js1_7/expressions/regress-346645-03.js new file mode 100644 index 000000000..20f4d8edb --- /dev/null +++ b/js/src/tests/js1_7/expressions/regress-346645-03.js @@ -0,0 +1,34 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 346645; +var summary = 'Do not crash with non-empty array in destructuring assign LHS'; +var actual = 'No Crash'; +var expect = 'No Crash'; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + try + { + eval('({ a:[z] }) = 3;'); + } + catch(ex) + { + } + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/expressions/regress-418051.js b/js/src/tests/js1_7/expressions/regress-418051.js new file mode 100644 index 000000000..32c6b4eac --- /dev/null +++ b/js/src/tests/js1_7/expressions/regress-418051.js @@ -0,0 +1,34 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 418051; +var summary = 'Do not assert: (pnkey)->pn_arity == PN_NULLARY && ' + + '((pnkey)->pn_type == TOK_NUMBER || (pnkey)->pn_type == TOK_STRING || ' + + '(pnkey)->pn_type == TOK_NAME)'; +var actual = 'No Crash'; +var expect = 'No Crash'; + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + try + { + eval("({x:[]}={x}"); + } + catch(ex) + { + } + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/expressions/regress-451340.js b/js/src/tests/js1_7/expressions/regress-451340.js new file mode 100644 index 000000000..77733091f --- /dev/null +++ b/js/src/tests/js1_7/expressions/regress-451340.js @@ -0,0 +1,27 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 451340; +var summary = 'Do no crash [@ CheckDestructuring]'; +var actual = 'No Crash'; +var expect = 'No Crash'; + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + function x([y]) { } + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/expressions/shell.js b/js/src/tests/js1_7/expressions/shell.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/src/tests/js1_7/expressions/shell.js diff --git a/js/src/tests/js1_7/extensions/basic-Iterator.js b/js/src/tests/js1_7/extensions/basic-Iterator.js new file mode 100644 index 000000000..b35f46d03 --- /dev/null +++ b/js/src/tests/js1_7/extensions/basic-Iterator.js @@ -0,0 +1,165 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = "(none)"; +var summary = "Basic support for accessing iterable objects using Iterator"; +var actual, expect; + +printBugNumber(BUGNUMBER); +printStatus(summary); + +/************** + * BEGIN TEST * + **************/ + +var failed = false; + +function Array_equals(a, b) +{ + if (!(a instanceof Array) || !(b instanceof Array)) + throw new Error("Arguments not both of type Array"); + if (a.length != b.length) + return false; + for (var i = 0, sz = a.length; i < sz; i++) + if (a[i] !== b[i]) + return false; + return true; +} + +var iterable = { persistedProp: 17 }; + +try +{ + // nothing unusual so far -- verify basic properties + for (var i in iterable) + { + if (i != "persistedProp") + throw "no persistedProp!"; + if (iterable[i] != 17) + throw "iterable[\"persistedProp\"] == 17"; + } + + var keys = ["foo", "bar", "baz"]; + var vals = [6, 5, 14]; + + iterable.__iterator__ = + function(keysOnly) + { + var gen = + function() + { + for (var i = 0; i < keys.length; i++) + { + if (keysOnly) + yield keys[i]; + else + yield [keys[i], vals[i]]; + } + }; + return gen(); + }; + + /* Test [key, value] Iterator */ + var index = 0; + var lastSeen = "INITIALVALUE"; + var it = Iterator(iterable); + try + { + while (true) + { + var nextVal = it.next(); + if (!Array_equals(nextVal, [keys[index], vals[index]])) + throw "Iterator(iterable): wrong next result\n" + + " expected: " + [keys[index], vals[index]] + "\n" + + " actual: " + nextVal; + lastSeen = keys[index]; + index++; + } + } + catch (e) + { + if (lastSeen !== keys[keys.length - 1]) + throw "Iterator(iterable): not everything was iterated!\n" + + " last iterated was: " + lastSeen + "\n" + + " error: " + e; + if (e !== StopIteration) + throw "Iterator(iterable): missing or invalid StopIteration"; + } + + if (iterable.persistedProp != 17) + throw "iterable.persistedProp not persisted!"; + + /* Test [key, value] Iterator, called with an explicit |false| parameter */ + var index = 0; + lastSeen = "INITIALVALUE"; + it = Iterator(iterable, false); + try + { + while (true) + { + var nextVal = it.next(); + if (!Array_equals(nextVal, [keys[index], vals[index]])) + throw "Iterator(iterable, false): wrong next result\n" + + " expected: " + [keys[index], vals[index]] + "\n" + + " actual: " + nextVal; + lastSeen = keys[index]; + index++; + } + } + catch (e) + { + if (lastSeen !== keys[keys.length - 1]) + throw "Iterator(iterable, false): not everything was iterated!\n" + + " last iterated was: " + lastSeen + "\n" + + " error: " + e; + if (e !== StopIteration) + throw "Iterator(iterable, false): missing or invalid StopIteration"; + } + + if (iterable.persistedProp != 17) + throw "iterable.persistedProp not persisted!"; + + /* Test key-only Iterator */ + index = 0; + lastSeen = undefined; + it = Iterator(iterable, true); + try + { + while (true) + { + var nextVal = it.next(); + if (nextVal !== keys[index]) + throw "Iterator(iterable, true): wrong next result\n" + + " expected: " + keys[index] + "\n" + + " actual: " + nextVal; + lastSeen = keys[index]; + index++; + } + } + catch (e) + { + if (lastSeen !== keys[keys.length - 1]) + throw "Iterator(iterable, true): not everything was iterated!\n" + + " last iterated was: " + lastSeen + "\n" + + " error: " + e; + if (e !== StopIteration) + throw "Iterator(iterable, true): missing or invalid StopIteration"; + } + + if (iterable.persistedProp != 17) + throw "iterable.persistedProp not persisted!"; +} +catch (e) +{ + failed = e; +} + + + +expect = false; +actual = failed; + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/js1_7/extensions/basic-for-each.js b/js/src/tests/js1_7/extensions/basic-for-each.js new file mode 100644 index 000000000..8b3097d4b --- /dev/null +++ b/js/src/tests/js1_7/extensions/basic-for-each.js @@ -0,0 +1,90 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = "346582"; +var summary = "Basic support for iterable objects and for-each"; +var actual, expect; + +printBugNumber(BUGNUMBER); +printStatus(summary); + +/************** + * BEGIN TEST * + **************/ + +var failed = false; + +var iterable = { persistedProp: 17 }; + +function Array_equals(a, b) +{ + if (!(a instanceof Array) || !(b instanceof Array)) + throw new Error("Arguments not both of type Array"); + if (a.length != b.length) + return false; + for (var i = 0, sz = a.length; i < sz; i++) + if (a[i] !== b[i]) + return false; + return true; +} + +try +{ + // nothing unusual so far -- verify basic properties + for (var i in iterable) + { + if (i != "persistedProp") + throw "no persistedProp!"; + if (iterable[i] != 17) + throw "iterable[\"persistedProp\"] == 17"; + } + + var keys = ["foo", "bar", "baz"]; + var vals = [6, 5, 14]; + + iterable.__iterator__ = + function(keysOnly) + { + var gen = + function() + { + for (var i = 0; i < keys.length; i++) + { + if (keysOnly) + yield keys[i]; + else + yield [keys[i], vals[i]]; + } + }; + return gen(); + }; + + // for each sets keysOnly==false + var index = 0; + for each (var v in iterable) + { + if (!Array_equals(v, [keys[index], vals[index]])) + throw "for-each iteration failed on index=" + index + "!"; + index++; + } + if (index != keys.length) + throw "not everything iterated! index=" + index + + ", keys.length=" + keys.length; + + if (iterable.persistedProp != 17) + throw "iterable.persistedProp not persisted!"; +} +catch (e) +{ + failed = e; +} + + + +expect = false; +actual = failed; + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/js1_7/extensions/basic-for-in.js b/js/src/tests/js1_7/extensions/basic-for-in.js new file mode 100644 index 000000000..d50aa5cbe --- /dev/null +++ b/js/src/tests/js1_7/extensions/basic-for-in.js @@ -0,0 +1,78 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = "346582"; +var summary = "Basic support for iterable objects and for-in"; +var actual, expect; + +printBugNumber(BUGNUMBER); +printStatus(summary); + +/************** + * BEGIN TEST * + **************/ + +var failed = false; + +var iterable = { persistedProp: 17 }; + +try +{ + // nothing unusual so far -- verify basic properties + for (var i in iterable) + { + if (i != "persistedProp") + throw "no persistedProp!"; + if (iterable[i] != 17) + throw "iterable[\"persistedProp\"] == 17"; + } + + var keys = ["foo", "bar", "baz"]; + var vals = [6, 5, 14]; + + iterable.__iterator__ = + function(keysOnly) + { + var gen = + function() + { + for (var i = 0; i < keys.length; i++) + { + if (keysOnly) + yield keys[i]; + else + yield [keys[i], vals[i]]; + } + }; + return gen(); + }; + + // for in sets keysOnly==true + var index = 0; + for (var k in iterable) + { + if (k != keys[index]) + throw "for-in iteration failed on keys[\"" + index + "\"]"; + index++; + } + if (index != keys.length) + throw "not everything iterated! index=" + index + + ", keys.length=" + keys.length; + + if (iterable.persistedProp != 17) + throw "iterable.persistedProp not persisted!"; +} +catch (e) +{ + failed = e; +} + + + +expect = false; +actual = failed; + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/js1_7/extensions/browser.js b/js/src/tests/js1_7/extensions/browser.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/src/tests/js1_7/extensions/browser.js diff --git a/js/src/tests/js1_7/extensions/destructuring-order.js b/js/src/tests/js1_7/extensions/destructuring-order.js new file mode 100644 index 000000000..72bba5b09 --- /dev/null +++ b/js/src/tests/js1_7/extensions/destructuring-order.js @@ -0,0 +1,152 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = "(none)"; +var summary = "Order of destructuring, destructuring in the presence of " + + "exceptions"; +var actual, expect; + +printBugNumber(BUGNUMBER); +printStatus(summary); + +/************** + * BEGIN TEST * + **************/ + +var failed = false; + + +var a = "FAILED", b = "PASSED"; + +function exceptObj() +{ + return { get b() { throw "PASSED"; }, a: "PASSED" }; +} + +function partialEvalObj() +{ + try + { + ({a:a, b:b} = exceptObj()); + throw "FAILED"; + } + catch (ex) + { + if (ex !== "PASSED") + throw "bad exception thrown: " + ex; + } +} + + +var c = "FAILED", d = "FAILED", e = "PASSED", f = "PASSED"; + +function exceptArr() +{ + return ["PASSED", {e: "PASSED", get f() { throw "PASSED"; }}, "FAILED"]; +} + +function partialEvalArr() +{ + try + { + [c, {e: d, f: e}, f] = exceptArr(); + throw "FAILED"; + } + catch (ex) + { + if (ex !== "PASSED") + throw "bad exception thrown: " + ex; + } +} + + +var g = "FAILED", h = "FAILED", i = "FAILED", j = "FAILED", k = "FAILED"; +var _g = "PASSED", _h = "FAILED", _i = "FAILED", _j = "FAILED", _k = "FAILED"; +var order = []; + +function objWithGetters() +{ + return { + get j() + { + var rv = _j; + _g = _h = _i = _j = "FAILED"; + _k = "PASSED"; + order.push("j"); + return rv; + }, + get g() + { + var rv = _g; + _g = _i = _j = _k = "FAILED"; + _h = "PASSED"; + order.push("g"); + return rv; + }, + get i() + { + var rv = _i; + _g = _h = _i = _k = "FAILED"; + _j = "PASSED"; + order.push("i"); + return rv; + }, + get k() + { + var rv = _k; + _g = _h = _i = _j = _k = "FAILED"; + order.push("k"); + return rv; + }, + get h() + { + var rv = _h; + _g = _h = _j = _k = "FAILED"; + _i = "PASSED"; + order.push("h"); + return rv; + } + }; +} + +function partialEvalObj2() +{ + ({g: g, h: h, i: i, j: j, k: k} = objWithGetters()); +} + +try +{ + partialEvalObj(); + if (a !== "PASSED" || b !== "PASSED") + throw "FAILED: lhs not mutated correctly during destructuring!\n" + + "a == " + a + ", b == " + b; + + partialEvalObj2(); + if (g !== "PASSED" || + h !== "PASSED" || + i !== "PASSED" || + j !== "PASSED" || + k !== "PASSED") + throw "FAILED: order of property accesses wrong!\n" + + "order == " + order; + + partialEvalArr(); + if (c !== "PASSED" || d !== "PASSED" || e !== "PASSED") + throw "FAILED: lhs not mutated correctly during destructuring!\n" + + "c == " + c + + ", d == " + d + + ", e == " + e + + ", f == " + f ; +} +catch (ex) +{ + failed = ex; +} + +expect = false; +actual = failed; + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/js1_7/extensions/iterator-ctor.js b/js/src/tests/js1_7/extensions/iterator-ctor.js new file mode 100644 index 000000000..92d3347cf --- /dev/null +++ b/js/src/tests/js1_7/extensions/iterator-ctor.js @@ -0,0 +1,102 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +// See http://developer.mozilla.org/en/docs/Core_JavaScript_1.5_Guide:Iterators_and_Generators + +//----------------------------------------------------------------------------- +var BUGNUMBER = "410725"; +var summary = "Test of the global Iterator constructor"; +var actual, expect; + +printBugNumber(BUGNUMBER); +printStatus(summary); + +/************** + * BEGIN TEST * + **************/ + +function iteratorToArray(iterator) { + var result = []; + for (var i in iterator) { + result[result.length] = i; + } + return result.sort(); +} + +var obj = {a:1, b:2}; + +reportCompare('["a", "b"]', + uneval(iteratorToArray(obj)), + 'uneval(iteratorToArray(obj))'); + +reportCompare('[["a", 1], ["b", 2]]', + uneval(iteratorToArray(Iterator(obj))), + 'uneval(iteratorToArray(Iterator(obj)))'); + +reportCompare('[["a", 1], ["b", 2]]', + uneval(iteratorToArray(new Iterator(obj))), + 'uneval(iteratorToArray(new Iterator(obj)))'); + +reportCompare('[["a", 1], ["b", 2]]', + uneval(iteratorToArray(Iterator(obj,false))), + 'uneval(iteratorToArray(Iterator(obj,false)))'); + +reportCompare('[["a", 1], ["b", 2]]', + uneval(iteratorToArray(new Iterator(obj,false))), + 'uneval(iteratorToArray(new Iterator(obj,false)))'); + +reportCompare('["a", "b"]', + uneval(iteratorToArray(Iterator(obj,true))), + 'uneval(iteratorToArray(Iterator(obj,true)))'); + +reportCompare('["a", "b"]', + uneval(iteratorToArray(new Iterator(obj,true))), + 'uneval(iteratorToArray(new Iterator(obj,true)))'); + +var flag; +var obji = {a:1, b:2}; +obji.__iterator__ = function (b) { flag = b; yield -1; yield -2; } + +flag = -1; +reportCompare('[-1, -2]', + uneval(iteratorToArray(obji)), + 'uneval(iteratorToArray(obji))'); +reportCompare(true, flag, 'uneval(iteratorToArray(obji)) flag'); + +flag = -1; +reportCompare('[-1, -2]', + uneval(iteratorToArray(Iterator(obji))), + 'uneval(iteratorToArray(Iterator(obji)))'); +reportCompare(false, flag, 'uneval(iteratorToArray(Iterator(obji))) flag'); + +flag = -1; +reportCompare('[-1, -2]', + uneval(iteratorToArray(new Iterator(obji))), + 'uneval(iteratorToArray(new Iterator(obji)))'); +reportCompare(false, flag, 'uneval(iteratorToArray(new Iterator(obji))) flag'); + +flag = -1; +reportCompare('[-1, -2]', + uneval(iteratorToArray(Iterator(obji,false))), + 'uneval(iteratorToArray(Iterator(obji,false)))'); +reportCompare(false, flag, 'uneval(iteratorToArray(Iterator(obji,false))) flag'); + +flag = -1; +reportCompare('[-1, -2]', + uneval(iteratorToArray(new Iterator(obji,false))), + 'uneval(iteratorToArray(new Iterator(obji,false)))'); +reportCompare(false, flag, 'uneval(iteratorToArray(new Iterator(obji,false))) flag'); + +flag = -1; +reportCompare('[-1, -2]', + uneval(iteratorToArray(Iterator(obji,true))), + 'uneval(iteratorToArray(Iterator(obji,true)))'); +reportCompare(true, flag, 'uneval(iteratorToArray(Iterator(obji,true))) flag'); + +flag = -1; +reportCompare('[-1, -2]', + uneval(iteratorToArray(new Iterator(obji,true))), + 'uneval(iteratorToArray(new Iterator(obji,true)))'); +reportCompare(true, flag, 'uneval(iteratorToArray(new Iterator(obji,true))) flag'); diff --git a/js/src/tests/js1_7/extensions/regress-346021.js b/js/src/tests/js1_7/extensions/regress-346021.js new file mode 100644 index 000000000..e8849aae3 --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-346021.js @@ -0,0 +1,45 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 346021; +var summary = 'Implementing __iterator__ as generator'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + var o = { __iterator__: function () { print(12); yield 42; } }; + + expect = 42; + actual = 0; + + for (let i in Iterator(o)) + { + actual = i; + } + + reportCompare(expect, actual, summary); + + actual = 0; + + for (let i in o) + { + actual = i; // this doesn't iterate 42 + } + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/extensions/regress-346642-06.js b/js/src/tests/js1_7/extensions/regress-346642-06.js new file mode 100644 index 000000000..e7664eab5 --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-346642-06.js @@ -0,0 +1,62 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 346642; +var summary = 'decompilation of destructuring assignment'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + expect = 3; + actual = ''; + "" + function() { [] = 3 }; actual = 3; + actual = 3; + reportCompare(expect, actual, summary + ': 1'); + + try + { + var z = 6; + var f = eval('(function (){for(let [] = []; false;) let z; return z})'); + expect = f(); + actual = eval("("+f+")")() + reportCompare(expect, actual, summary + ': 2'); + } + catch(ex) + { + // See https://bugzilla.mozilla.org/show_bug.cgi?id=408957 + var summarytrunk = 'let declaration must be direct child of block or top-level implicit block'; + expect = 'SyntaxError'; + actual = ex.name; + reportCompare(expect, actual, summarytrunk); + } + + expect = 3; + actual = ''; + "" + function () { for(;; [[a]] = [5]) { } }; actual = 3; + reportCompare(expect, actual, summary + ': 3'); + + expect = 3; + actual = ''; + "" + function () { for(;; ([[,]] = p)) { } }; actual = 3; + reportCompare(expect, actual, summary + ': 4'); + + expect = 3; + actual = ''; + actual = 1; try {for(x in (function ([y]) { })() ) { }}catch(ex){} actual = 3; + reportCompare(expect, actual, summary + ': 5'); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/extensions/regress-346773.js b/js/src/tests/js1_7/extensions/regress-346773.js new file mode 100644 index 000000000..3faa2c73f --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-346773.js @@ -0,0 +1,52 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 346773; +var summary = 'Do not crash compiling with misplaced brances in function'; +var actual = 'No Crash'; +var expect = 'No Crash'; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + try + { + var src = + ' var it = {foo:"5"};' + + ' it.__iterator__ =' + + ' function(valsOnly)' + + ' {' + + ' var gen =' + + ' function()' + + ' {' + + ' for (var i = 0; i < keys.length; i++)' + + ' {' + + ' if (valsOnly)' + + ' yield vals[i];' + + ' else' + + ' yield [keys[i], vals[i]];' + + ' }' + + ' return gen();' + + ' }' + + ' }'; + eval(src); + } + catch(ex) + { + } + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/extensions/regress-350312.js b/js/src/tests/js1_7/extensions/regress-350312.js new file mode 100644 index 000000000..4da03648c --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-350312.js @@ -0,0 +1,80 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 350312; +var summary = 'Accessing wrong stack slot with nested catch/finally'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + var iter; + function gen() + { + try { + yield iter; + } catch (e if e == null) { + actual += 'CATCH,'; + print("CATCH"); + } finally { + actual += 'FINALLY'; + print("FINALLY"); + } + } + + expect = 'FINALLY'; + actual = ''; + (iter = gen()).next().close(); + reportCompare(expect, actual, summary); + + expect = 'FINALLY'; + actual = ''; + try + { + (iter = gen()).next().throw(1); + } + catch(ex) + { + } + reportCompare(expect, actual, summary); + + expect = 'CATCH,FINALLY'; + actual = ''; + try + { + (iter = gen()).next().throw(null); + } + catch(ex) + { + } + reportCompare(expect, actual, summary); + + expect = 'FINALLY'; + actual = ''; + var expectexcp = '[object StopIteration]'; + var actualexcp = ''; + try + { + (iter = gen()).next().next(); + } + catch(ex) + { + actualexcp = ex + ''; + } + reportCompare(expect, actual, summary); + reportCompare(expectexcp, actualexcp, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/extensions/regress-351070-02.js b/js/src/tests/js1_7/extensions/regress-351070-02.js new file mode 100644 index 000000000..b478da195 --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-351070-02.js @@ -0,0 +1,69 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 351070; +var summary = 'decompilation of let declaration should not change scope'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + try + { + var pfx = "(function f() { var n = 2, a = 2; ", + decl = " let a = 3;", + end = " return a; })"; + + var table = [ + ["if (!!true)", ""], + ["if (!!true)", " else foopy();"], + ["if (!true); else", ""], + ["do ", " while (false);"], + ["while (--n)", ""], + ["for (--n;n;--n)", ""], + ["for (a in this)", ""], + ["with (this)", ""], + ]; + + expect = 3; + + for (i = 0; i < table.length; i++) { + var src = pfx + table[i][0] + decl + table[i][1] + end; + print('src: ' + src); + var fun = eval(src); + var testval = fun(); + reportCompare(expect, testval, summary + ': ' + src); + if (testval != expect) { + break; + } + print('uneval: ' + uneval(fun)); + var declsrc = '(' + + src.slice(1, -1).replace('function f', 'function f' + i) + ')'; + print('declsrc: ' + declsrc); + this['f' + i] = eval(declsrc); + print('f' + i + ': ' + this['f' + i]); + } + } + catch(ex) + { + // See https://bugzilla.mozilla.org/show_bug.cgi?id=408957 + summary = 'let declaration must be direct child of block or top-level implicit block'; + expect = 'SyntaxError'; + actual = ex.name; + reportCompare(expect, actual, summary); + } + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/extensions/regress-351102-03.js b/js/src/tests/js1_7/extensions/regress-351102-03.js new file mode 100644 index 000000000..5790cfab8 --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-351102-03.js @@ -0,0 +1,43 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 351102; +var summary = 'try/catch-guard/finally GC issues'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + var f; + f = function() + { + try + { + d.d.d; + } + catch({} if gc()) + { + } + catch(y) + { + } + }; + + f(); + f(); + + reportCompare(expect, actual, summary + ': 3'); + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/extensions/regress-351102-04.js b/js/src/tests/js1_7/extensions/regress-351102-04.js new file mode 100644 index 000000000..716454160 --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-351102-04.js @@ -0,0 +1,35 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 351102; +var summary = 'try/catch-guard/finally GC issues'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + var f; + try + { + try { foo() } catch([] if gc()) { } + } + catch(ex) + { + } + reportCompare(expect, actual, summary + ': 4'); + + exitFunc ('test'); +} + diff --git a/js/src/tests/js1_7/extensions/regress-351102-05.js b/js/src/tests/js1_7/extensions/regress-351102-05.js new file mode 100644 index 000000000..32b3d39e6 --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-351102-05.js @@ -0,0 +1,34 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 351102; +var summary = 'try/catch-guard/finally GC issues'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + var f; + try + { + try { d.d.d } catch([] if gc()) { } + } + catch(ex) + { + } + reportCompare(expect, actual, summary + ': 5'); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/extensions/regress-351102-07.js b/js/src/tests/js1_7/extensions/regress-351102-07.js new file mode 100644 index 000000000..16a6f18fe --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-351102-07.js @@ -0,0 +1,43 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 351102; +var summary = 'try/catch-guard/finally GC issues'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + var f; + var obj = { get a() { + try { + throw 1; + } catch (e) { + } + return false; + }}; + + try { + throw obj; + } catch ({a: a} if a) { + throw "Unreachable"; + } catch (e) { + if (e !== obj) + throw "Unexpected exception: "+uneval(e); + } + reportCompare(expect, actual, summary + ': 7'); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/extensions/regress-352797-01.js b/js/src/tests/js1_7/extensions/regress-352797-01.js new file mode 100644 index 000000000..cb3c98f59 --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-352797-01.js @@ -0,0 +1,35 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 352797; +var summary = 'Do not assert: OBJ_GET_CLASS(cx, obj) == &js_BlockClass'; +var actual = 'No Crash'; +var expect = 'No Crash'; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + if (typeof Script == 'undefined') + { + print('Test skipped. Script not defined.'); + } + else + { + (function(){let x = 'fafafa'.replace(/a/g, new Script(''))})(); + } + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/extensions/regress-352885-01.js b/js/src/tests/js1_7/extensions/regress-352885-01.js new file mode 100644 index 000000000..9210f17a7 --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-352885-01.js @@ -0,0 +1,29 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 352885; +var summary = 'Do not crash iterating over gen.__proto__'; +var actual = 'No Crash'; +var expect = 'No Crash'; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + for (j in ((function() { yield 3; })().__proto__)) + print(j); + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/extensions/regress-352885-02.js b/js/src/tests/js1_7/extensions/regress-352885-02.js new file mode 100644 index 000000000..d243813f9 --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-352885-02.js @@ -0,0 +1,67 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 352885; +var summary = 'Do not crash iterating over gen.__proto__'; +var actual = 'No Crash'; +var expect = 'No Crash'; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + function dotest() + { + var proto = (function() { yield 3; })().__proto__; + + try { + proto.next(); + throw "generatorProto.next() does not throw TypeError"; + } catch (e) { + if (!(e instanceof TypeError)) + throw "generatorProto.next() throws unexpected exception: "+uneval(e); + } + + try { + proto.send(); + throw "generatorProto.send() does not throw TypeError"; + } catch (e) { + if (!(e instanceof TypeError)) + throw "generatorProto.send() throws unexpected exception: "+uneval(e); + } + + var obj = {}; + try { + proto.throw(obj); + throw "generatorProto.throw(obj) does not throw TypeError"; + } catch (e) { + if (!(e instanceof TypeError)) + throw "generatorProto.throw() throws unexpected exception: "+uneval(e); + } + + try { + proto.close(); + throw "generatorProto.close() does not throw TypeError"; + } catch (e) { + if (!(e instanceof TypeError)) + throw "generatorProto.close() throws unexpected exception: "+uneval(e); + } + + } + + dotest(); + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/extensions/regress-353214-01.js b/js/src/tests/js1_7/extensions/regress-353214-01.js new file mode 100644 index 000000000..bd0cbb676 --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-353214-01.js @@ -0,0 +1,47 @@ +// |reftest| skip -- obsolete test +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 353214; +var summary = 'bug 353214'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + var f = function () { + switch(({ get x() { export *; }, set x([[y], [x] ]) { let x; } })) { + case eval("[[1]]", function(id) { return id; }): + L:for(let x in (((eval).call)(eval("yield <x><y/></x>;", "" ))))var x; + case (uneval(this)): + import x.*; + } + } + + expect = 'function () { ' + + 'switch({ get x() { export *; }, set x([[y], [x] ]) { let x; } }) { ' + + 'case eval("[[1]]", function(id) { return id; }): ' + + 'L:for(let x in eval.call(eval("yield <x><y/></x>;", "" ))){var x;} ' + + 'case uneval(this): ' + + 'import x.*; default:;' + + '} ' + + '}'; + + actual = f + ''; + + compareSource(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/extensions/regress-353249.js b/js/src/tests/js1_7/extensions/regress-353249.js new file mode 100644 index 000000000..8bc5ed931 --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-353249.js @@ -0,0 +1,35 @@ +// |reftest| skip -- obsolete test +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 353249; +var summary = 'regression test for bug 353249'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + var f = (function () { let (x) <x/>.(1) < let (z) eval('3'); + for (x in this) {} }); + + expect = 'function () { (let (x) <x/>.((1)) < (let (z) eval("3"))); ' + + 'for (x in this) {} }'; + actual = f + ''; + compareSource(expect, actual, summary); + + // do not crash() + f(); + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/extensions/regress-354499-01.js b/js/src/tests/js1_7/extensions/regress-354499-01.js new file mode 100644 index 000000000..6a9ae40b9 --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-354499-01.js @@ -0,0 +1,46 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 354499; +var summary = 'Iterating over Array elements'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + expect = actual = 'No Crash'; + + var obj = {get a(){ return new Object(); }}; + + function setter(v) + { + // Push out obj.a from all temp roots + var tmp = { get toString() { return new Object(); }}; + try { String(tmp); } catch (e) { } + gc(); + } + + Array.prototype.__defineGetter__(0, function() { }); + Array.prototype.__defineSetter__(0, setter); + + for (var i in Iterator(obj)) + print(uneval(i)); + + delete Array.prototype[0]; + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/extensions/regress-354499-02.js b/js/src/tests/js1_7/extensions/regress-354499-02.js new file mode 100644 index 000000000..8f5c62918 --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-354499-02.js @@ -0,0 +1,49 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 354499; +var summary = 'Iterating over Array elements'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + expect = actual = 'No Crash'; + + function get_value() + { + // Unroot the first element + this[0] = 0; + + // Call gc to collect atom corresponding to Math.sqrt(2) + gc(); + } + + var counter = 2; + Iterator.prototype.next = function() + { + if (counter-- <= 0) throw StopIteration; + var a = [Math.sqrt(2), 1]; + a.__defineGetter__(1, get_value); + return a; + }; + + for (i in [1]) + ; + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/extensions/regress-354945-01.js b/js/src/tests/js1_7/extensions/regress-354945-01.js new file mode 100644 index 000000000..76f1a3c82 --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-354945-01.js @@ -0,0 +1,34 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 354945; +var summary = 'Do not crash with new Iterator'; +var expect = 'TypeError: trap __iterator__ for ({__iterator__:(function (){ })}) returned a primitive value'; +var actual; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + try { + var obj = {}; + obj.__iterator__ = function(){ }; + for(t in (new Iterator(obj))) { } + } catch (ex) { + actual = ex.toString(); + } + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/extensions/regress-354945-02.js b/js/src/tests/js1_7/extensions/regress-354945-02.js new file mode 100644 index 000000000..261bf7de1 --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-354945-02.js @@ -0,0 +1,38 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 354945; +var summary = 'Do not crash with new Iterator'; +var actual = 'No Crash'; +var expect = 'No Crash'; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + expect = 'TypeError: trap __iterator__ for ({__iterator__:(function (){ })}) returned a primitive value'; + var obj = {}; + obj.__iterator__ = function(){ }; + try + { + for(t in (obj)) { } + } + catch(ex) + { + actual = ex + ''; + } + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/extensions/regress-355052-01.js b/js/src/tests/js1_7/extensions/regress-355052-01.js new file mode 100644 index 000000000..ea5f5d7d7 --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-355052-01.js @@ -0,0 +1,37 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 355052; +var summary = 'Do not crash with valueOf:gc and __iterator__'; +var actual = 'No Crash'; +var expect = 'No Crash'; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + expect = /TypeError: .+ is not a function/; + actual = 'No Error'; + try + { + ( {valueOf: gc} - [function(){}].__iterator__ )(); + } + catch(ex) + { + actual = ex + ''; + } + + reportMatch(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/extensions/regress-355052-02.js b/js/src/tests/js1_7/extensions/regress-355052-02.js new file mode 100644 index 000000000..57d06153e --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-355052-02.js @@ -0,0 +1,37 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 355052; +var summary = 'Do not crash with valueOf:gc and __iterator__'; +var actual = 'No Crash'; +var expect = 'No Crash'; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + expect = /TypeError: .+ is not a function/; + actual = 'No Error'; + try + { + ( {valueOf: gc} - [].a )(); + } + catch(ex) + { + actual = ex + ''; + } + + reportMatch(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/extensions/regress-355052-03.js b/js/src/tests/js1_7/extensions/regress-355052-03.js new file mode 100644 index 000000000..e987101fb --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-355052-03.js @@ -0,0 +1,43 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 355052; +var summary = 'Do not crash with valueOf:gc and __iterator__'; +var actual = 'No Crash'; +var expect = 'No Crash'; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + expect = /TypeError: .+ is not a function/; + actual = 'No Error'; + try + { + var obj = {valueOf: gc }; + + function f() { + ( obj * [].a )(); + } + + f(); + } + catch(ex) + { + actual = ex + ''; + } + + reportMatch(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/extensions/regress-355410.js b/js/src/tests/js1_7/extensions/regress-355410.js new file mode 100644 index 000000000..6b00b704f --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-355410.js @@ -0,0 +1,40 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 355410; +var summary = 'GC hazard in for([k,v] in o){...}'; +var actual = 'No Crash'; +var expect = 'No Crash'; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + var address = 0xbadf00d0, basket = { food: {} }; + var AP = Array.prototype, rooter = {}; + AP.__defineGetter__(0, function() { return this[-1]; }); + AP.__defineSetter__(0, function(v) { + basket.food = null; + for(var i = 0; i < 8 * 1024; i++) { + rooter[i] = 0x10000000000000 + address; // IEEE754! + } + return this[-1] = v; + }); + for(var [key, value] in basket) { value.trigger; } + + delete Array.prototype[0]; + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/extensions/regress-355512.js b/js/src/tests/js1_7/extensions/regress-355512.js new file mode 100644 index 000000000..554242382 --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-355512.js @@ -0,0 +1,38 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 355512; +var summary = 'Do not crash with generator arguments'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + function foopy() + { + var f = function(){ r = arguments; d.d.d; yield 170; } + try { for (var i in f()) { } } catch (iterError) { } + } + + typeof uneval; + foopy(); + gc(); + uneval(r); + gc(); + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/extensions/regress-363040-01.js b/js/src/tests/js1_7/extensions/regress-363040-01.js new file mode 100644 index 000000000..5b89b4e81 --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-363040-01.js @@ -0,0 +1,65 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 363040; +var summary = 'Array.prototype.reduce application in continued fraction'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + +// Print x as a continued fraction in compact abbreviated notation and return +// the convergent [n, d] such that x - (n / d) <= epsilon. + function contfrac(x, epsilon) { + let i = Math.floor(x); + let a = [i]; + x = x - i; + let maxerr = x; + while (maxerr > epsilon) { + x = 1 / x; + i = Math.floor(x); + a.push(i); + x = x - i; + maxerr = x * maxerr / i; + } + print(uneval(a)); + a.push([1, 0]); + a.reverse(); + return a.reduce(function (x, y) {return [x[0] * y + x[1], x[0]];}); + } + + if (!Array.prototype.reduce) + { + print('Test skipped. Array.prototype.reduce not implemented'); + } + else + { +// Show contfrac in action. + for each (num in [Math.PI, Math.sqrt(2), 1 / (Math.sqrt(Math.E) - 1)]) { + print('Continued fractions for', num); + for each (eps in [1e-2, 1e-3, 1e-5, 1e-7, 1e-10]) { + let frac = contfrac(num, eps); + let est = frac[0] / frac[1]; + let err = num - est; + print(uneval(frac), est, err); + } + print(); + } + } + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/extensions/regress-363040-02.js b/js/src/tests/js1_7/extensions/regress-363040-02.js new file mode 100644 index 000000000..ea163790a --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-363040-02.js @@ -0,0 +1,64 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 363040; +var summary = 'Array.prototype.reduce application in continued fraction'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + +// Print x as a continued fraction in compact abbreviated notation and return +// the convergent [n, d] such that x - (n / d) <= epsilon. + function contfrac(x, epsilon) { + let i = Math.floor(x); + let a = [i]; + x = x - i; + let maxerr = x; + while (maxerr > epsilon) { + x = 1 / x; + i = Math.floor(x); + a.push(i); + x = x - i; + maxerr = x * maxerr / i; + } + print(uneval(a)); + return a.reduceRight(function (x, y) {return [x[0] * y + x[1], x[0]];}, [1, 0]); + } + + if (!Array.prototype.reduceRight) + { + print('Test skipped. Array.prototype.reduceRight not implemented'); + } + else + { +// Show contfrac in action on some interesting numbers. + for each (num in [Math.PI, Math.sqrt(2), 1 / (Math.sqrt(Math.E) - 1)]) { + print('Continued fractions for', num); + for each (eps in [1e-2, 1e-3, 1e-5, 1e-7, 1e-10]) { + let frac = contfrac(num, eps); + let est = frac[0] / frac[1]; + let err = num - est; + print(uneval(frac), est, err); + } + print(); + } + } + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/extensions/regress-366668-01.js b/js/src/tests/js1_7/extensions/regress-366668-01.js new file mode 100644 index 000000000..92d01e800 --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-366668-01.js @@ -0,0 +1,31 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 366668; +var summary = 'decompilation of "for (let x in x.p)" '; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + var f; + + f = function() { for(let x in x.p) { } }; + expect = 'function() { for(let x in x.p) { } }'; + actual = f + ''; + compareSource(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/extensions/regress-367629.js b/js/src/tests/js1_7/extensions/regress-367629.js new file mode 100644 index 000000000..7808701cb --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-367629.js @@ -0,0 +1,38 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +//----------------------------------------------------------------------------- +var BUGNUMBER = 367629; +var summary = 'Decompilation of result with native function as getter'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + var a = + Object.defineProperty({}, "h", + { + get: encodeURI, + enumerable: true, + configurable: true + }); + + expect = '({get h() {[native code]}})'; + actual = uneval(a); + + compareSource(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/extensions/regress-368213.js b/js/src/tests/js1_7/extensions/regress-368213.js new file mode 100644 index 000000000..c1f9be735 --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-368213.js @@ -0,0 +1,17 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 368213; +var summary = 'Do not crash with group assignment and sharp variable defn'; +var actual = 'No Crash'; +var expect = 'No Crash'; + +printBugNumber(BUGNUMBER); +printStatus (summary); + +(function() { [] = [] }); + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/js1_7/extensions/regress-368224.js b/js/src/tests/js1_7/extensions/regress-368224.js new file mode 100644 index 000000000..234f26856 --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-368224.js @@ -0,0 +1,28 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 368224; +var summary = 'Do not assert: pnprop->pn_type == TOK_COLON'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + ({ x: a } = {}); + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/extensions/regress-372364.js b/js/src/tests/js1_7/extensions/regress-372364.js new file mode 100644 index 000000000..ed641045f --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-372364.js @@ -0,0 +1,35 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 372364; +var summary = 'Do not recurse to death on (function() { yield ([15].some([].watch)); })().next()'; +var actual = 'No Crash'; +var expect = 'No Crash'; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + print('FIXME: Fix this test to check the proper error when bug 366669 is fixed'); + try + { + (function() { yield ([15].some([].watch)); })().next(); + } + catch(ex) + { + } + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/extensions/regress-379566.js b/js/src/tests/js1_7/extensions/regress-379566.js new file mode 100644 index 000000000..73f80ce04 --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-379566.js @@ -0,0 +1,45 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +//----------------------------------------------------------------------------- +var BUGNUMBER = 379566; +var summary = 'Keywords after get|set'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + expect = '({ ' + + 'get in () { return this.for; }, ' + + 'set in (value) { this.for = value; } ' + + '})'; + try + { + var obj = eval('({ ' + + 'get in() { return this.for; }, ' + + 'set in(value) { this.for = value; } ' + + '})'); + actual = obj.toSource(); + + } + catch(ex) + { + actual = ex + ''; + } + + compareSource(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/extensions/regress-380933.js b/js/src/tests/js1_7/extensions/regress-380933.js new file mode 100644 index 000000000..09f64209d --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-380933.js @@ -0,0 +1,27 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +var BUGNUMBER = 380933; +var summary = 'Do not assert with uneval object with setter with modified proto'; + +printBugNumber(BUGNUMBER); +printStatus (summary); + +var f = (function(){}); +var y = + Object.defineProperty({}, "p", + { + get: f, + enumerable: true, + configurable: true + }); +f.__proto__ = []; +uneval(y); + +if (typeof reportCompare === "function") + reportCompare(true, true); + +print("Tests complete"); + diff --git a/js/src/tests/js1_7/extensions/regress-381301.js b/js/src/tests/js1_7/extensions/regress-381301.js new file mode 100644 index 000000000..e69009b80 --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-381301.js @@ -0,0 +1,32 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +//----------------------------------------------------------------------------- +var BUGNUMBER = 381301; +var summary = 'uneval of object with native-function getter'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + var o = + Object.defineProperty({}, "x", { get: decodeURI, enumerable: true, configurable: true }); + expect = '( { get x ( ) { [ native code ] } } )'; + actual = uneval(o); + + compareSource(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/extensions/regress-381303.js b/js/src/tests/js1_7/extensions/regress-381303.js new file mode 100644 index 000000000..40c9dbdef --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-381303.js @@ -0,0 +1,35 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +//----------------------------------------------------------------------------- +var BUGNUMBER = 381303; +var summary = 'object toSource when a property has both a getter and a setter'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + var obj = {set inn(value) {this.for = value;}, get inn() {return this.for;}}; + expect = '( { ' + + 'get inn() {return this.for;}' + + ', ' + + 'set inn(value) {this.for = value;}' + + '})'; + actual = obj.toSource(); + + compareSource(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/extensions/regress-387955-01.js b/js/src/tests/js1_7/extensions/regress-387955-01.js new file mode 100644 index 000000000..e3af18401 --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-387955-01.js @@ -0,0 +1,40 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +//----------------------------------------------------------------------------- +var BUGNUMBER = 387955; +var summary = 'Do not Crash [@ TraceEdge]'; +var actual = 'No Crash'; +var expect = 'No Crash'; + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + var fal = false; + + function gen() { + let x; + function y(){} + this.__defineGetter__('', function(){}); + if (fal) + yield; + } + + for (var i in gen()) { } + + gc(); + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/extensions/regress-387955-02.js b/js/src/tests/js1_7/extensions/regress-387955-02.js new file mode 100644 index 000000000..dc3b795b6 --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-387955-02.js @@ -0,0 +1,41 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +//----------------------------------------------------------------------------- +var BUGNUMBER = 387955; +var summary = 'Do not Crash [@ TraceEdge]'; +var actual = 'No Crash'; +var expect = 'No Crash'; + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + var f; + + function gen(yield_at_least_once) { + let x = 11; + function y(){} + f = function(){ return x; }; + if (yield_at_least_once) + yield; + } + + for (var i in gen()) { } + + if (f() !== 11) + throw "unexpected value of local x"; + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/extensions/regress-392308.js b/js/src/tests/js1_7/extensions/regress-392308.js new file mode 100644 index 000000000..7d4c9e1d9 --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-392308.js @@ -0,0 +1,47 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 392308; +var summary = 'StopIteration should be catchable'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + function testStop() { + function yielder() { + actual += 'before, '; + yield; + actual += 'after, '; + } + + expect = 'before, after, iteration terminated normally'; + + try { + var gen = yielder(); + result = gen.next(); + gen.send(result); + } catch (x if x instanceof StopIteration) { + actual += 'iteration terminated normally'; + } catch (x2) { + actual += 'unexpected throw: ' + x2; + } + } + testStop(); + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/extensions/regress-396326.js b/js/src/tests/js1_7/extensions/regress-396326.js new file mode 100644 index 000000000..2a26e5350 --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-396326.js @@ -0,0 +1,37 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 396326; +var summary = 'Do not assert trying to disassemble get(var|arg) prop'; +var actual = 'No Crash'; +var expect = 'No Crash'; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + if (typeof dis == 'undefined') + { + print('disassembly not supported. test skipped.'); + reportCompare(expect, actual, summary); + } + else + { + function f4() { let local; return local.prop }; + dis(f4); + reportCompare(expect, actual, summary + + ': function f4() { let local; return local.prop };'); + } + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/extensions/regress-453955.js b/js/src/tests/js1_7/extensions/regress-453955.js new file mode 100644 index 000000000..454f712f3 --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-453955.js @@ -0,0 +1,31 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 453955; +var summary = 'Do not assert: sprop->setter != js_watch_set || pobj != obj'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + for (var z = 0; z < 2; ++z) + { + [].filter.watch("9", function(y) { yield y; }); + } + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/extensions/regress-458679.js b/js/src/tests/js1_7/extensions/regress-458679.js new file mode 100644 index 000000000..d87d23512 --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-458679.js @@ -0,0 +1,52 @@ +// |reftest| skip-if(!xulRuntime.shell||xulRuntime.shell&&xulRuntime.XPCOMABI.match(/x86_64/)) slow +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 458679; +var summary = 'Do not assert: nbytes != 0'; +var actual = ''; +var expect = ''; + +printBugNumber(BUGNUMBER); +printStatus (summary); + +function f() +{ + for (var i = 1; i < dps.length; ++i) { + var a = ""; + var b = ""; + var c = ""; + } +} + +function stringOfLength(n) +{ + if (n == 0) { + return ""; + } else if (n == 1) { + return "\""; + } else { + var r = n % 2; + var d = (n - r) / 2; + var y = stringOfLength(d); + return y + y + stringOfLength(r); + } +} + +try +{ + this.__defineGetter__('x', this.toSource); + while (x.length < 12000000) { + let q = x; + s = q + q; + } + print(x.length); +} +catch(ex) +{ +} + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/js1_7/extensions/regress-469234.js b/js/src/tests/js1_7/extensions/regress-469234.js new file mode 100644 index 000000000..52ca30bf0 --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-469234.js @@ -0,0 +1,30 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 469234; +var summary = 'TM: Do not assert: !JS_ON_TRACE(cx)'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + + for(var j=0;j<3;++j)({__proto__:[]}).__defineSetter__('x',function(){}); + + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/extensions/regress-469405-01.js b/js/src/tests/js1_7/extensions/regress-469405-01.js new file mode 100644 index 000000000..82172c3d3 --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-469405-01.js @@ -0,0 +1,27 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 469405; +var summary = 'Do not assert: !regs.sp[-2].isPrimitive()'; +var actual = ''; +var expect = ''; + +printBugNumber(BUGNUMBER); +printStatus (summary); + +try +{ + (function() { + var a, b; + for each (a in [{}, {__iterator__: function(){}}]) for (b in a) { } + })(); +} +catch(ex) +{ + print('caught ' + ex); +} + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/js1_7/extensions/regress-469405-02.js b/js/src/tests/js1_7/extensions/regress-469405-02.js new file mode 100644 index 000000000..196557e69 --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-469405-02.js @@ -0,0 +1,25 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 469405; +var summary = 'Do not assert: !regs.sp[-2].isPrimitive()'; +var actual = ''; +var expect = ''; + +printBugNumber(BUGNUMBER); +printStatus (summary); + +try +{ + eval("__proto__.__iterator__ = [].toString"); + for (var z = 0; z < 3; ++z) { if (z % 3 == 2) { for(let y in []); } } +} +catch(ex) +{ + print('caught ' + ex); +} + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/js1_7/extensions/regress-470300-01.js b/js/src/tests/js1_7/extensions/regress-470300-01.js new file mode 100644 index 000000000..6558330d1 --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-470300-01.js @@ -0,0 +1,30 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 470300; +var summary = 'TM: Do not assert: StackBase(fp) + blockDepth == regs.sp'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + + for (let a = 0; a < 3; ++a) { let b = '' + []; } + + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/extensions/regress-470300-02.js b/js/src/tests/js1_7/extensions/regress-470300-02.js new file mode 100644 index 000000000..0ecd368ff --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-470300-02.js @@ -0,0 +1,30 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 470300; +var summary = 'TM: Do not assert: !fp->blockChain || OBJ_GET_PARENT(cx, obj) == fp->blockChain'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + + for (let a = 0; a < 7; ++a) { let e = 8; if (a > 3) { let x; } } + + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/extensions/regress-473282.js b/js/src/tests/js1_7/extensions/regress-473282.js new file mode 100644 index 000000000..c50ac9234 --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-473282.js @@ -0,0 +1,20 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 473282; +var summary = 'Do not assert: thing'; +var actual = ''; +var expect = ''; + +printBugNumber(BUGNUMBER); +printStatus (summary); + +this.watch("b", "".substring); +this.__defineGetter__("a", gc); +for each (b in [this, null, null]); +a; + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/js1_7/extensions/regress-474771-01.js b/js/src/tests/js1_7/extensions/regress-474771-01.js new file mode 100644 index 000000000..ca754ba2c --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-474771-01.js @@ -0,0 +1,32 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 474771; +var summary = 'TM: do not assert: jumpTable == interruptJumpTable'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + + var o = {}; + o.__defineSetter__('x', function(){}); + for (let j = 0; j < 4; ++j) o.x = 3; + + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/extensions/regress-474771-02.js b/js/src/tests/js1_7/extensions/regress-474771-02.js new file mode 100644 index 000000000..127351858 --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-474771-02.js @@ -0,0 +1,20 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 474771; +var summary = 'TM: do not assert: jumpTable == interruptJumpTable'; +var actual = ''; +var expect = ''; + +printBugNumber(BUGNUMBER); +printStatus (summary); + + +this.__defineSetter__('x', function(){}); +for (var j = 0; j < 5; ++j) { x = 3; } + + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/js1_7/extensions/regress-476257.js b/js/src/tests/js1_7/extensions/regress-476257.js new file mode 100644 index 000000000..6f2852590 --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-476257.js @@ -0,0 +1,57 @@ +// |reftest| skip-if(Android) +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 476257; +var summary = 'Do not assert: !JS_ON_TRACE(cx)'; +var actual = ''; +var expect = ''; + +printBugNumber(BUGNUMBER); +printStatus (summary); + + +function f1() { + try + { + Object.defineProperty(__proto__, "functional", + { + enumerable: true, configurable: true, + get: function () + { + if (typeof gczeal == 'function') { gczeal(0); } + } + }); + for each (let [[]] in [true, new Boolean(true), new Boolean(true)]) {} + } + catch(ex) + { + } +} + +function f2() { + try + { + Object.defineProperty(__proto__, "functional", + { + enumerable: true, configurable: true, + get: function () + { + if (typeof dis == 'function') { dis(); } + } + }); + for each (let [[]] in [true, new Boolean(true), new Boolean(true)]) {} + } + catch(ex) + { + } +} + +f1(); +f2(); + + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/js1_7/extensions/regress-477048.js b/js/src/tests/js1_7/extensions/regress-477048.js new file mode 100644 index 000000000..638f9f035 --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-477048.js @@ -0,0 +1,34 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 477048; +var summary = 'Do not assert: cg->stackDepth == loopDepth'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + try + { + for each (this.__proto__ in x) {} + } + catch(ex) + { + } + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/extensions/regress-589112.js b/js/src/tests/js1_7/extensions/regress-589112.js new file mode 100644 index 000000000..db6d1c7c0 --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-589112.js @@ -0,0 +1,6 @@ + +f = eval("(function(){return x=Iterator(/x/)})") +for (a in f()) {} +for (d in x) {} + +reportCompare(0, 0, ""); diff --git a/js/src/tests/js1_7/extensions/regress-590813.js b/js/src/tests/js1_7/extensions/regress-590813.js new file mode 100644 index 000000000..ec701ced5 --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-590813.js @@ -0,0 +1,23 @@ + +var actual = ''; +var expected = 'A0B1B2C0C1C2'; + +var x = Iterator([1,2,3], true); + +for (var a in x) { + actual += 'A' + a; + for (var b in x) { + actual += 'B' + b; + } +} + +var y = Iterator([1,2,3], true); + +for (var c in y) { + actual += 'C' + c; +} +for (var d in y) { + actual += 'D' + d; +} + +reportCompare(expected, actual, "Handle nested Iterator iteration right"); diff --git a/js/src/tests/js1_7/extensions/regress-591450.js b/js/src/tests/js1_7/extensions/regress-591450.js new file mode 100644 index 000000000..f1ebcf675 --- /dev/null +++ b/js/src/tests/js1_7/extensions/regress-591450.js @@ -0,0 +1,12 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ + */ + +/* + * This was causing the parser to assert at one point. Now it's not. Yay! + */ +function f(a,[x,y],b,[w,z],c) { function b() { } } + +reportCompare(0, 0, "don't crash"); diff --git a/js/src/tests/js1_7/extensions/shell.js b/js/src/tests/js1_7/extensions/shell.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/src/tests/js1_7/extensions/shell.js diff --git a/js/src/tests/js1_7/geniter/326466-01.js b/js/src/tests/js1_7/geniter/326466-01.js new file mode 100644 index 000000000..4c9bf1ad3 --- /dev/null +++ b/js/src/tests/js1_7/geniter/326466-01.js @@ -0,0 +1,45 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 326466; +var summary = 'Implement Pythonic generators and iteration protocol support'; +var actual; +var expect; + +printBugNumber(BUGNUMBER); +printStatus (summary); + +function fib() +{ + var a = 0, b = 1; + + while (true) + { + yield a; + var t = a; + a = b; + b += t; + } +} + +var g = fib(); + +expect = '[object Generator]'; +actual = g.toString(); +reportCompare(expect, actual, summary); + +var actual = []; +var expect = [0, 1, 1, 2, 3, 5, 8, 13]; +actual.push(g.next()); +actual.push(g.next()); +actual.push(g.next()); +actual.push(g.next()); +actual.push(g.next()); +actual.push(g.next()); +actual.push(g.next()); +actual.push(g.next()); +reportCompare(expect.join(), actual.join(), summary); + diff --git a/js/src/tests/js1_7/geniter/browser.js b/js/src/tests/js1_7/geniter/browser.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/src/tests/js1_7/geniter/browser.js diff --git a/js/src/tests/js1_7/geniter/builtin-Iterator-function.js b/js/src/tests/js1_7/geniter/builtin-Iterator-function.js new file mode 100644 index 000000000..01b659e7d --- /dev/null +++ b/js/src/tests/js1_7/geniter/builtin-Iterator-function.js @@ -0,0 +1,89 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = "(none)"; +var summary = "Iterator() test"; +var actual, expect; + +printBugNumber(BUGNUMBER); +printStatus(summary); + +/************** + * BEGIN TEST * + **************/ + +var failed = false; + +function Array_equals(a, b) +{ + if (!(a instanceof Array) || !(b instanceof Array)) + throw new Error("Arguments not both of type Array"); + if (a.length != b.length) + return false; + for (var i = 0, sz = a.length; i < sz; i++) + if (a[i] !== b[i]) + return false; + return true; +} + +var meow = "meow", oink = "oink", baa = "baa"; + +var it = Iterator([meow, oink, baa]); +var it2 = Iterator([meow, oink, baa], true); + +try +{ + if (!Array_equals(it.next(), [0, meow])) + throw [0, meow]; + if (!Array_equals(it.next(), [1, oink])) + throw [1, oink]; + if (!Array_equals(it.next(), [2, baa])) + throw [2, baa]; + + var stopPassed = false; + try + { + it.next(); + } + catch (e) + { + if (e === StopIteration) + stopPassed = true; + } + + if (!stopPassed) + throw "it: missing or incorrect StopIteration"; + + if (it2.next() != 0) + throw "wanted key=0"; + if (it2.next() != 1) + throw "wanted key=1"; + if (it2.next() != 2) + throw "wanted key=2"; + + var stopPassed = false; + try + { + it2.next(); + } + catch (e) + { + if (e === StopIteration) + stopPassed = true; + } + + if (!stopPassed) + throw "it2: missing or incorrect StopIteration"; +} +catch (e) +{ + failed = e; +} + +expect = false; +actual = failed; + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/js1_7/geniter/close-returns-undefined.js b/js/src/tests/js1_7/geniter/close-returns-undefined.js new file mode 100644 index 000000000..a1f81ec5b --- /dev/null +++ b/js/src/tests/js1_7/geniter/close-returns-undefined.js @@ -0,0 +1,20 @@ +function gen() { + yield 3; +} + +var g = gen(); +assertEq(g.close(), undefined); + +var h = gen(); +assertEq(h.next(), 3); +var caught = false; +try { + h.next(); +} catch (e) { + caught = true; + assertEq(e instanceof StopIteration, true); +} +assertEq(caught, true); +assertEq(h.close(), undefined); + +reportCompare(); diff --git a/js/src/tests/js1_7/geniter/fibonacci-matrix-generator.js b/js/src/tests/js1_7/geniter/fibonacci-matrix-generator.js new file mode 100644 index 000000000..e1c9efb13 --- /dev/null +++ b/js/src/tests/js1_7/geniter/fibonacci-matrix-generator.js @@ -0,0 +1,64 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = "(none)"; +var summary = "Fibonacci generator by matrix multiplication"; +var actual, expect; + +printBugNumber(BUGNUMBER); +printStatus(summary); + +/************** + * BEGIN TEST * + **************/ + +function fib() +{ + var init = [1, 0]; + var mx = [[1, 1], [1, 0]]; + while (true) + { + yield init[1]; + var tmp = [,]; + tmp[0] = + mx[0][0]*init[0] + mx[0][1]*init[1]; + tmp[1] = + mx[1][0]*init[0] + mx[1][1]*init[1]; + init = tmp; + } +} + +var failed = false; +var it = fib(); + +try +{ + if (it.next() != 0) + throw "F_0 failed"; + if (it.next() != 1) + throw "F_1 failed"; + if (it.next() != 1) + throw "F_2 failed"; + if (it.next() != 2) + throw "F_3 failed"; + if (it.next() != 3) + throw "F_4 failed"; + if (it.next() != 5) + throw "F_5 failed"; + if (it.next() != 8) + throw "F_6 failed"; +} +catch (e) +{ + failed = e; +} + + + +expect = false; +actual = failed; + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/js1_7/geniter/gen-with-call-obj.js b/js/src/tests/js1_7/geniter/gen-with-call-obj.js new file mode 100644 index 000000000..90c6f09c5 --- /dev/null +++ b/js/src/tests/js1_7/geniter/gen-with-call-obj.js @@ -0,0 +1,36 @@ +var foo; + +function gen() { + var x = 0; + foo = function() { return x++; } + for (var i = 0; i < 10; ++i) + yield x++; +} + +var j = 0; +for (i in gen()) + assertEq(i, j++); + +// now mess up the stack + +function f1(x) { + var a, b, c, d, e, f, g; + return x <= 0 ? 0 : f1(x-1); +} +f1(10); +function f2(x) { + var a = x, b = x; + return x <= 0 ? 0 : f2(x-1); +} +f2(10); + +// now observe gen's call object (which should have been put) + +gc(); +assertEq(foo(), 10); +gc(); +assertEq(foo(), 11); +gc(); +assertEq(foo(), 12); + +reportCompare(true,true); diff --git a/js/src/tests/js1_7/geniter/iterator-toString.js b/js/src/tests/js1_7/geniter/iterator-toString.js new file mode 100644 index 000000000..686ec0c8b --- /dev/null +++ b/js/src/tests/js1_7/geniter/iterator-toString.js @@ -0,0 +1,43 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = "(none)"; +var summary = "gen.toString() omitting 'yield' from value"; +var actual, expect; + +printBugNumber(BUGNUMBER); +printStatus(summary); + +/************** + * BEGIN TEST * + **************/ + +var failed = false; + +function gen() +{ + yield 17; +} + +try +{ + var str = gen.toString(); + var index = str.search(/yield/); + + if (index < 0) + throw "yield not found in str: " + str; +} +catch (e) +{ + failed = e; +} + + + +expect = false; +actual = failed; + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/js1_7/geniter/message-value-passing.js b/js/src/tests/js1_7/geniter/message-value-passing.js new file mode 100644 index 000000000..626c788be --- /dev/null +++ b/js/src/tests/js1_7/geniter/message-value-passing.js @@ -0,0 +1,88 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 326466; +var summary = "Generator value/exception passing"; +var actual, expect; + +printBugNumber(BUGNUMBER); +printStatus(summary); + +/************** + * BEGIN TEST * + **************/ + +function gen() +{ + var rv, rv2, rv3, rv4; + rv = yield 1; + + if (rv) + rv2 = yield rv; + else + rv3 = yield 2; + + try + { + if (rv2) + yield rv2; + else + rv3 = yield 3; + } + catch (e) + { + if (e == 289) + yield "exception caught"; + } + + yield 5; +} + +var failed = false; +var it = gen(); + +try +{ + if (it.next() != 1) + throw "failed on 1"; + + if (it.send(17) != 17) + throw "failed on 17"; + + if (it.next() != 3) + throw "failed on 3"; + + if (it.throw(289) != "exception caught") + throw "it.throw(289) failed"; + + if (it.next() != 5) + throw "failed on 5"; + + var stopPassed = false; + try + { + it.next(); + } + catch (e) + { + if (e === StopIteration) + stopPassed = true; + } + + if (!stopPassed) + throw "missing or incorrect StopIteration"; +} +catch (e) +{ + failed = e; +} + + + +expect = false; +actual = failed; + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/js1_7/geniter/multiple-close.js b/js/src/tests/js1_7/geniter/multiple-close.js new file mode 100644 index 000000000..7864459ef --- /dev/null +++ b/js/src/tests/js1_7/geniter/multiple-close.js @@ -0,0 +1,65 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = "(none)"; +var summary = "calling it.close multiple times is harmless"; +var actual, expect; + +printBugNumber(BUGNUMBER); +printStatus(summary); + +/************** + * BEGIN TEST * + **************/ + +function fib() +{ + yield 0; // 0 + yield 1; // 1 + yield 1; // 2 + yield 2; // 3 + yield 3; // 4 + yield 5; // 5 + yield 8; // 6 +} + +var failed = false; +var it = fib(); + +try +{ + if (it.next() != 0) + throw "0 failed"; + + // closing an already-closed generator is a no-op + it.close(); + it.close(); + it.close(); + + var stopPassed = false; + try + { + it.next(); + } + catch (e) + { + if (e === StopIteration) + stopPassed = true; + } + if (!stopPassed) + throw "a closed iterator throws StopIteration on next"; +} +catch (e) +{ + failed = e; +} + + + +expect = false; +actual = failed; + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/js1_7/geniter/nested-yield.js b/js/src/tests/js1_7/geniter/nested-yield.js new file mode 100644 index 000000000..a5a1bf59e --- /dev/null +++ b/js/src/tests/js1_7/geniter/nested-yield.js @@ -0,0 +1,58 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = "(none)"; +var summary = "YieldExpression is and contains an AssignmentExpression"; +var actual, expect; + +printBugNumber(BUGNUMBER); +printStatus(summary); + +/************** + * BEGIN TEST * + **************/ + +var failed = false; + +function gen() +{ + yield (yield (yield 7)); +} + +var it = gen(); + +try +{ + if (it.next() != 7) + throw "7 not yielded"; + if (it.send(17) != 17) + throw "passed-in 17 not yielded"; + if (it.send(undefined) !== undefined) + throw "should be able to yield undefined"; + + var stopPassed = false; + try + { + it.next(); + } + catch (e) + { + if (e === StopIteration) + stopPassed = true; + } + + if (!stopPassed) + throw "it: missing or incorrect StopIteration"; +} +catch (e) +{ + failed = e; +} + +expect = false; +actual = failed; + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/js1_7/geniter/pi-generator.js b/js/src/tests/js1_7/geniter/pi-generator.js new file mode 100644 index 000000000..5be593ab4 --- /dev/null +++ b/js/src/tests/js1_7/geniter/pi-generator.js @@ -0,0 +1,59 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = "(none)"; +var summary = "A (slow) generator of pi"; +var actual, expect; + +printBugNumber(BUGNUMBER); +printStatus(summary); + +/************** + * BEGIN TEST * + **************/ + +function pi() +{ + var val = 0; + var curr = 1; + var isNeg = false; + while (true) + { + if (isNeg) + yield val -= 4/curr; + else + yield val += 4/curr; + curr += 2; + isNeg = !isNeg; + } +} + +var failed = false; +var it = pi(); + +var vals = + [4, + 4 - 4/3, + 4 - 4/3 + 4/5, + 4 - 4/3 + 4/5 - 4/7]; + +try +{ + for (var i = 0, sz = vals.length; i < sz; i++) + if (it.next() != vals[i]) + throw vals[i]; +} +catch (e) +{ + failed = e; +} + + + +expect = false; +actual = failed; + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/js1_7/geniter/regress-345855.js b/js/src/tests/js1_7/geniter/regress-345855.js new file mode 100644 index 000000000..a88ccd440 --- /dev/null +++ b/js/src/tests/js1_7/geniter/regress-345855.js @@ -0,0 +1,93 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 345855; +var summary = 'Blank yield expressions are not syntax errors'; +var actual = ''; +var expect = 'No Error'; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + expect = "SyntaxError"; + try + { + eval('(function() {x = 12 + yield;})'); + actual = 'No Error'; + } + catch(ex) + { + actual = ex.name; + } + reportCompare(expect, actual, summary + ': function() {x = 12 + yield;}'); + + expect = "SyntaxError"; + try + { + eval('(function() {x = 12 + yield 42})'); + actual = 'No Error'; + } + catch(ex) + { + actual = ex.name; + } + reportCompare(expect, actual, summary + ': function() {x = 12 + yield 42}'); + + expect = 'No Error'; + try + { + eval('(function() {x = 12 + (yield);})'); + actual = 'No Error'; + } + catch(ex) + { + actual = ex + ''; + } + reportCompare(expect, actual, summary + ': function() {x = 12 + (yield);}'); + + try + { + eval('(function () {foo((yield))})'); + actual = 'No Error'; + } + catch(ex) + { + actual = ex + ''; + } + reportCompare(expect, actual, summary + ': function () {foo((yield))}'); + + try + { + eval('(function() {x = 12 + (yield 42)})'); + actual = 'No Error'; + } + catch(ex) + { + actual = ex + ''; + } + reportCompare(expect, actual, summary + ': function() {x = 12 + (yield 42)}'); + + try + { + eval('(function (){foo((yield 42))})'); + actual = 'No Error'; + } + catch(ex) + { + actual = ex + ''; + } + reportCompare(expect, actual, summary + ': function (){foo((yield 42))}'); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/geniter/regress-345879-01.js b/js/src/tests/js1_7/geniter/regress-345879-01.js new file mode 100644 index 000000000..540852a23 --- /dev/null +++ b/js/src/tests/js1_7/geniter/regress-345879-01.js @@ -0,0 +1,33 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 345879; +var summary = 'Crash when calling a function from a generator with less arguments than its arity '; +var actual = 'No Crash'; +var expect = 'No Crash'; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + function gen() { + yield isNaN(); + } + + f = gen(); + f.next(); + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/geniter/regress-345879-02.js b/js/src/tests/js1_7/geniter/regress-345879-02.js new file mode 100644 index 000000000..aec3d81a1 --- /dev/null +++ b/js/src/tests/js1_7/geniter/regress-345879-02.js @@ -0,0 +1,34 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 345879; +var summary = 'Crash when calling a function from a generator with less arguments than its arity '; +var actual = 'No Crash'; +var expect = 'No Crash'; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + function gen() { + (yield 5)(); + yield; + } + f = gen(); + f.next(); + f.send(Function()); + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/geniter/regress-347593.js b/js/src/tests/js1_7/geniter/regress-347593.js new file mode 100644 index 000000000..353d9412c --- /dev/null +++ b/js/src/tests/js1_7/geniter/regress-347593.js @@ -0,0 +1,60 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 347593; +var summary = 'For-each loop with destructuring assignment'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + // Before JS1.7's destructuring for…in was fixed to match JS1.8's, + // the expected result was '23'. + expect = 'TypeError'; + actual = ''; + try { + for (let [, { a: b }] in [{ a: 2 }, { a: 3 }]) { + actual += b; + } + reportCompare(expect, actual, summary); + } catch (ex) { + actual = ex.name; + } + + expect = '23'; + actual = ''; + for each (let { a: b } in [{ a: 2 }, { a: 3 }]) + { + actual += b; + } + reportCompare(expect, actual, summary); + + expect = 'TypeError'; + actual = ''; + try + { + for each (let [, { a: b }] in [{ a: 2 }, { a: 3 }]) + { + actual += b; + } + } + catch(ex) + { + actual = ex.name; + } + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/geniter/regress-347739.js b/js/src/tests/js1_7/geniter/regress-347739.js new file mode 100644 index 000000000..46c749ec7 --- /dev/null +++ b/js/src/tests/js1_7/geniter/regress-347739.js @@ -0,0 +1,49 @@ +// |reftest| skip -- obsolete test +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 347739; +var summary = 'generator_instance.close readonly and immune'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + function gen_test(test_index) + { + try { + yield 1; + } finally { + actual += "Inside finally: "+test_index + ' '; + } + } + + actual = ''; + expect = 'Inside finally: 1 Inside finally: 2 '; + + var iter1 = gen_test(1); + iter1.next(); + iter1.close = null; + iter1 = null; + gc(); + + var iter2 = gen_test(2); + for (i in iter2) + iter2.close = null; + + reportCompare(expect, actual, summary + ': 2'); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/geniter/regress-349012-01.js b/js/src/tests/js1_7/geniter/regress-349012-01.js new file mode 100644 index 000000000..297b03732 --- /dev/null +++ b/js/src/tests/js1_7/geniter/regress-349012-01.js @@ -0,0 +1,52 @@ +// |reftest| skip -- obsolete test +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 349012; +var summary = 'closing a generator fails to report error if yield during close is ignored'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +if (typeof quit != 'undefined') +{ + quit(0); +} + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + expect = "Inner finally,Outer finally"; + + function gen() + { + try { + try { + yield 1; + } finally { + actual += "Inner finally"; + yield 2; + } + } finally { + actual += ",Outer finally"; + } + } + + var iter = gen(); + iter.next(); + iter = null; + gc(); + + reportCompare(expect, actual, summary); + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/geniter/regress-349012-02.js b/js/src/tests/js1_7/geniter/regress-349012-02.js new file mode 100644 index 000000000..5c78423cd --- /dev/null +++ b/js/src/tests/js1_7/geniter/regress-349012-02.js @@ -0,0 +1,61 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 349012; +var summary = 'generators with nested try finally blocks'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + expect = "[object StopIteration]"; + var expectyield = "12"; + var expectfinally = "Inner finally,Outer finally"; + var actualyield = ""; + var actualfinally = ""; + + function gen() + { + try { + try { + yield 1; + } finally { + actualfinally += "Inner finally"; + yield 2; + } + } finally { + actualfinally += ",Outer finally"; + } + } + + var iter = gen(); + actualyield += iter.next(); + actualyield += iter.next(); + try + { + actualyield += iter.next(); + actual = "No exception"; + } + catch(ex) + { + actual = ex + ''; + } + + reportCompare(expect, actual, summary); + reportCompare(expectyield, actualyield, summary); + reportCompare(expectfinally, actualfinally, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/geniter/regress-349012-03.js b/js/src/tests/js1_7/geniter/regress-349012-03.js new file mode 100644 index 000000000..4d1747597 --- /dev/null +++ b/js/src/tests/js1_7/geniter/regress-349012-03.js @@ -0,0 +1,42 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 349012; +var summary = 'generator recursively calling itself via send is a TypeError'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + function gen() { + var iter = yield; + try { + iter.send(1); + } catch (e) { + yield e; + } + } + + expect = true; + var iter = gen(); + iter.next(); + var ex = iter.send(iter); + print(ex + ''); + actual = (ex instanceof TypeError); + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/geniter/regress-349012-04.js b/js/src/tests/js1_7/geniter/regress-349012-04.js new file mode 100644 index 000000000..705bbd909 --- /dev/null +++ b/js/src/tests/js1_7/geniter/regress-349012-04.js @@ -0,0 +1,42 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 349012; +var summary = 'generator recursively calling itself via next is an Error'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + function gen() { + var iter = yield; + try { + iter.next(1); + } catch (e) { + yield e; + } + } + + expect = true; + var iter = gen(); + iter.next(); + var ex = iter.send(iter); + print(ex + ''); + actual = (ex instanceof TypeError); + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/geniter/regress-349012-05.js b/js/src/tests/js1_7/geniter/regress-349012-05.js new file mode 100644 index 000000000..5eb442b9a --- /dev/null +++ b/js/src/tests/js1_7/geniter/regress-349012-05.js @@ -0,0 +1,43 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 349012; +var summary = 'generator recursively calling itself via close is an Error'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + var iter; + function gen() { + iter.close(); + yield 1; + } + + expect = /TypeError.*[aA]lready executing generator/; + try + { + iter = gen(); + var i = iter.next(); + print("i="+i); + } + catch(ex) + { + actual = ex + ''; + } + reportMatch(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/geniter/regress-349023-01.js b/js/src/tests/js1_7/geniter/regress-349023-01.js new file mode 100644 index 000000000..3eab5eb94 --- /dev/null +++ b/js/src/tests/js1_7/geniter/regress-349023-01.js @@ -0,0 +1,42 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 349023; +var summary = 'Bogus JSCLASS_IS_EXTENDED in the generator class'; +var actual = 'No Crash'; +var expect = 'No Crash'; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + function gen() { + var i = 0; + yield i; + } + + try + { + var g = gen(); + for (var i = 0; i < 10; i++) { + print(g.next()); + } + } + catch(ex) + { + } + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/geniter/regress-349023-02.js b/js/src/tests/js1_7/geniter/regress-349023-02.js new file mode 100644 index 000000000..25bde697c --- /dev/null +++ b/js/src/tests/js1_7/geniter/regress-349023-02.js @@ -0,0 +1,29 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 349023; +var summary = 'Bogus JSCLASS_IS_EXTENDED in the generator class'; +var actual = 'No Crash'; +var expect = 'No Crash'; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + var gen = (function() { yield 3; })(); + gen.foopy; + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/geniter/regress-349023-03.js b/js/src/tests/js1_7/geniter/regress-349023-03.js new file mode 100644 index 000000000..26201061d --- /dev/null +++ b/js/src/tests/js1_7/geniter/regress-349023-03.js @@ -0,0 +1,29 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 349023; +var summary = 'Bogus JSCLASS_IS_EXTENDED in the generator class'; +var actual = 'No Crash'; +var expect = 'No Crash'; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + var gen = (function() { yield 3; })(); + var x = (gen ==gen); + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/geniter/regress-349331.js b/js/src/tests/js1_7/geniter/regress-349331.js new file mode 100644 index 000000000..091fbb1f0 --- /dev/null +++ b/js/src/tests/js1_7/geniter/regress-349331.js @@ -0,0 +1,95 @@ +// |reftest| skip -- obsolete test +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 349331; +var summary = 'generator.close without GeneratorExit'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + var catch1, catch2, catch3, finally1, finally2, finally3; + var iter; + + function gen() + { + yield 1; + try { + try { + try { + yield 1; + } catch (e) { + catch1 = true; + } finally { + finally1 = true; + } + } catch (e) { + catch2 = true; + } finally { + finally2 = true; + } + } catch (e) { + catch3 = true; + } finally { + finally3 = true; + } + } + +// test explicit close call + catch1 = catch2 = catch3 = finally1 = finally2 = finally3 = false; + iter = gen(); + iter.next(); + iter.next(); + iter.close(); + + var passed = !catch1 && !catch2 && !catch3 && finally1 && finally2 && + finally3; + + if (!passed) { + print("Failed!"); + print("catch1=" + catch1 + " catch2=" + catch2 + " catch3=" + + catch3); + print("finally1=" + finally1 + " finally2=" + finally2 + + " finally3=" + finally3); + } + + reportCompare(true, passed, 'test explicit close call'); + +// test GC-invoked close + catch1 = catch2 = catch3 = finally1 = finally2 = finally3 = false; + iter = gen(); + iter.next(); + iter.next(); + iter = null; + gc(); + gc(); + + var passed = !catch1 && !catch2 && !catch3 && finally1 && finally2 && + finally3; + + if (!passed) { + print("Failed!"); + print("catch1=" + catch1 + " catch2=" + catch2 + " catch3=" + + catch3); + print("finally1=" + finally1 + " finally2=" + finally2 + + " finally3="+finally3); + } + reportCompare(true, passed, 'test GC-invoke close'); + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/geniter/regress-349362.js b/js/src/tests/js1_7/geniter/regress-349362.js new file mode 100644 index 000000000..e87c25d16 --- /dev/null +++ b/js/src/tests/js1_7/geniter/regress-349362.js @@ -0,0 +1,29 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 349362; +var summary = 'generator toString should be [object Generator]'; +var actual = ''; +var expect = '[object Generator]'; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + var y = function(){ yield 3}; + actual = y().toString(); + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/geniter/regress-349851.js b/js/src/tests/js1_7/geniter/regress-349851.js new file mode 100644 index 000000000..efd4ee626 --- /dev/null +++ b/js/src/tests/js1_7/geniter/regress-349851.js @@ -0,0 +1,36 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 349851; +var summary = 'decompilation of yield \\n, 3'; +var actual = ''; +var expect = 'SyntaxError'; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + // note the newline after yield is required for this test + try + { + var f = eval('function(){ yield \n,3 }'); + } + catch(ex) + { + actual = ex.name; + } + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/geniter/regress-350621.js b/js/src/tests/js1_7/geniter/regress-350621.js new file mode 100644 index 000000000..60d7d5491 --- /dev/null +++ b/js/src/tests/js1_7/geniter/regress-350621.js @@ -0,0 +1,63 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 350621; +var summary = 'for-in loops over generator objects'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + var LOOPS = 500; + + function gen1() { + for (var a = 1; a <= LOOPS; ++a) + yield; + } + + function gen2() { + for (var b in gen1()) + yield; + } + + function test_it(RUNS) { + for (var c = 1; c <= RUNS; ++c) { + var count = 0; + for (var d in gen2()) { + // The next line is needed to demonstrate the bug. + // Note that simply omitting the "x" triggers the bug far less often. + Object("x"); + ++count; + } + if (count != LOOPS) { + print("Test run " + c + ": test failed, count = " + count + + ", should be " + LOOPS); + var failed = true; + } + } + actual = !failed; + if (!failed) + { + print("Test passed."); + } + } + + expect = true; + test_it(20); + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/geniter/regress-350809.js b/js/src/tests/js1_7/geniter/regress-350809.js new file mode 100644 index 000000000..fd1f600c8 --- /dev/null +++ b/js/src/tests/js1_7/geniter/regress-350809.js @@ -0,0 +1,36 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 350809; +var summary = 'Do not assertion: if yield in xml filtering predicate'; +var actual = 'No Crash'; +var expect = 'No Crash'; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + try + { + eval('(function(){ <x/>.(yield 4) })().next();'); + } + catch(ex) + { + actual = expect = + 'InternalError: yield not yet supported from filtering predicate'; + } + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/geniter/regress-351120.js b/js/src/tests/js1_7/geniter/regress-351120.js new file mode 100644 index 000000000..e01c2595a --- /dev/null +++ b/js/src/tests/js1_7/geniter/regress-351120.js @@ -0,0 +1,36 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 351120; +var summary = 'Incorrect error messages with yield expressions'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + expect = /TypeError:.*(is not a function|Cannot find function).*/; + actual = ''; + try + { + (function() { yield [].z({}); })().next(); + } + catch(ex) + { + actual = ex + ''; + } + reportMatch(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/geniter/regress-352197.js b/js/src/tests/js1_7/geniter/regress-352197.js new file mode 100644 index 000000000..7982e12ee --- /dev/null +++ b/js/src/tests/js1_7/geniter/regress-352197.js @@ -0,0 +1,36 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 352197; +var summary = 'TypeError if yield after return value in a block'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + expect = /TypeError: anonymous generator function returns a value/; + try + { + var gen = eval('(function() { { return 5; } yield 3; })'); + actual = 'No Error'; + } + catch(ex) + { + actual = ex + ''; + } + reportMatch(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/geniter/regress-352876.js b/js/src/tests/js1_7/geniter/regress-352876.js new file mode 100644 index 000000000..600c82899 --- /dev/null +++ b/js/src/tests/js1_7/geniter/regress-352876.js @@ -0,0 +1,42 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 352876; +var summary = 'Do not assert with nested finally return|yield'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + expect = '[object StopIteration]'; + actual = ''; + try + { + var g = (function() { + try { try { } finally { return; } } finally { yield 3; } + })(); + + g.next(); + g.next(); + } + catch(ex) + { + actual = ex + ''; + } + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/geniter/regress-355834.js b/js/src/tests/js1_7/geniter/regress-355834.js new file mode 100644 index 000000000..37624fa53 --- /dev/null +++ b/js/src/tests/js1_7/geniter/regress-355834.js @@ -0,0 +1,30 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 355834; +var summary = 'new Function("yield")'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + expect = '[object Generator]'; + var g = (new Function('yield'))(1); + actual = g + ''; + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/geniter/regress-359062.js b/js/src/tests/js1_7/geniter/regress-359062.js new file mode 100644 index 000000000..9a806d7cf --- /dev/null +++ b/js/src/tests/js1_7/geniter/regress-359062.js @@ -0,0 +1,41 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 359062; +var summary = 'Access generator local variables from nested functions'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + expect = "Generator string"; + + var scope = "Global"; + + function gen() { + var scope = "Generator"; + function inner() { + actual = scope + " " + typeof scope; + } + inner(); + yield; + } + + gen().next(); + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/geniter/regress-366941.js b/js/src/tests/js1_7/geniter/regress-366941.js new file mode 100644 index 000000000..74ee3a937 --- /dev/null +++ b/js/src/tests/js1_7/geniter/regress-366941.js @@ -0,0 +1,83 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ + * Contributor: Robert Sayre + */ + + +//----------------------------------------------------------------------------- +var BUGNUMBER = 366941; +var summary = 'Destructuring enumerations, iterations'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + var list1 = [[1,2],[3,4],[5,6]]; + var list2 = [[1,2,3],[4,5,6],[7,8,9]]; + + expect = '1,2;3,4;5,6;'; + actual = ''; + + for each (var [foo, bar] in list1) { + actual += foo + "," + bar + ";"; + } + + reportCompare(expect, actual, summary + ': 1'); + + expect = '1,2,3;4,5,6;7,8,9;'; + actual = ''; + for each (var [foo, bar, baz] in list2) { + actual += foo + "," + bar + "," + baz + ";"; + } + + reportCompare(expect, actual, summary + ': 2'); + + function gen(list) { + for each (var test in list) { + yield test; + } + } + + var iter1 = gen(list1); + + expect = '1,2;3,4;5,6;'; + actual = ''; + + for (var [foo, bar] in iter1) { + actual += foo + "," + bar + ";"; + } + + reportCompare(expect, actual, summary + ': 3'); + + // Before JS1.7's destructuring for…in was fixed to match JS1.8's, + // the expected result was a SyntaxError about the for…in loop's lhs. + var iter2 = gen(list2); + expect = '1,2,3;4,5,6;7,8,9;'; + actual = ''; + + try + { + eval('for (var [foo, bar, baz] in iter2) {' + + 'actual += foo + "," + bar + "," + baz + ";";' + + '}'); + } + catch(ex) + { + actual = ex + ''; + } + + reportCompare(expect, actual, summary + ': 4'); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/geniter/regress-382335.js b/js/src/tests/js1_7/geniter/regress-382335.js new file mode 100644 index 000000000..357156ce1 --- /dev/null +++ b/js/src/tests/js1_7/geniter/regress-382335.js @@ -0,0 +1,36 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +//----------------------------------------------------------------------------- +var BUGNUMBER = 382335; +var summary = 'Trampolining threads using generators and iterators'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + function make_gen() { yield 1; } + + var gen2 = make_gen(); + + gen2.next(); + gen2.close(); + + print(10); + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/geniter/regress-387871.js b/js/src/tests/js1_7/geniter/regress-387871.js new file mode 100644 index 000000000..bb5202dae --- /dev/null +++ b/js/src/tests/js1_7/geniter/regress-387871.js @@ -0,0 +1,41 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +//----------------------------------------------------------------------------- +var BUGNUMBER = 387871; +var summary = 'Do not assert: gen->state != JSGEN_RUNNING && gen->state != JSGEN_CLOSING'; +var actual = 'No Crash'; +var expect = 'No Crash'; + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + var a = gen(); + + try { + a.next(); + throw "a.next() should throw about already invoked generator"; + } catch (e) { + if (!(e instanceof TypeError)) + throw e; + } + + function gen() + { + for (x in a) + yield 1; + } + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/geniter/regress-390918.js b/js/src/tests/js1_7/geniter/regress-390918.js new file mode 100644 index 000000000..fdd19e2ad --- /dev/null +++ b/js/src/tests/js1_7/geniter/regress-390918.js @@ -0,0 +1,46 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 390918; +var summary = 'Do not assert: !gen->frame.down" with gc in generator'; +var actual = 'No Crash'; +var expect = 'No Crash'; + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + function gen() + { + var c = [1, "x"]; + gc(); + try { + yield c; + } finally { + gc(); + } + } + + var iter = gen(); + var i; + for (i in iter) { + gc(); + iter.close(); + } + + if (!(i.length === 2 && i[0] === 1 && i[1] === "x")) + throw "Unexpected yield result: "+i; + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/geniter/regress-392310.js b/js/src/tests/js1_7/geniter/regress-392310.js new file mode 100644 index 000000000..a6edd25f7 --- /dev/null +++ b/js/src/tests/js1_7/geniter/regress-392310.js @@ -0,0 +1,42 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 392310; +var summary = 'send on newborn generator'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + print("See http://developer.mozilla.org/en/docs/New_in_JavaScript_1.7"); + + function yielder() { + actual = 'before yield'; + yield; + actual = 'after yield'; + } + + var gen = yielder(); + expect = 'before yield'; + gen.send('foo'); + reportCompare(expect, actual, 'send(value) to newborn generator'); + + var gen = yielder(); + expect = 'before yield'; + gen.send(undefined); + reportCompare(expect, actual, 'send(undefined) to newborn generator'); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/geniter/regress-466206.js b/js/src/tests/js1_7/geniter/regress-466206.js new file mode 100644 index 000000000..fc6b2fe9e --- /dev/null +++ b/js/src/tests/js1_7/geniter/regress-466206.js @@ -0,0 +1,38 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 466206; +var summary = 'Do not crash due to unrooted function variables'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + var f; + + function g() { + var x = {}; + f = function () { x.y; }; + if (0) yield; + } + + try { g().next(); } catch (e) {} + gc(); + f(); + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/geniter/send-no-rhs.js b/js/src/tests/js1_7/geniter/send-no-rhs.js new file mode 100644 index 000000000..e37681ba9 --- /dev/null +++ b/js/src/tests/js1_7/geniter/send-no-rhs.js @@ -0,0 +1,57 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = "(none)"; +var summary = "|it.send(o)| without an RHS"; +var actual, expect; + +printBugNumber(BUGNUMBER); +printStatus(summary); + +/************** + * BEGIN TEST * + **************/ + +var failed = false; + +function gen() +{ + yield 7; + yield 3; +} + +var it = gen(); + +try +{ + if (it.next() != 7) + throw "7 not yielded"; + if (it.send(12) != 3) + throw "3 not yielded"; + + var stopPassed = false; + try + { + it.send(35); // resultant value of |yield 3;| + } + catch (e) + { + if (e === StopIteration) + stopPassed = true; + } + + if (!stopPassed) + throw "it: missing or incorrect StopIteration"; +} +catch (e) +{ + failed = e; +} + +expect = false; +actual = failed; + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/js1_7/geniter/sequential-yields.js b/js/src/tests/js1_7/geniter/sequential-yields.js new file mode 100644 index 000000000..b829907b6 --- /dev/null +++ b/js/src/tests/js1_7/geniter/sequential-yields.js @@ -0,0 +1,72 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = "(none)"; +var summary = "Sequential yields"; +var actual, expect; + +printBugNumber(BUGNUMBER); +printStatus(summary); + +/************** + * BEGIN TEST * + **************/ + +function fib() +{ + yield 0; // 0 + yield 1; // 1 + yield 1; // 2 + yield 2; // 3 + yield 3; // 4 + yield 5; // 5 + yield 8; // 6 +} + +var failed = false; +var it = fib(); + +try +{ + if (it.next() != 0) + throw "0 failed"; + if (it.next() != 1) + throw "1 failed"; + if (it.next() != 1) + throw "2 failed"; + if (it.next() != 2) + throw "3 failed"; + if (it.next() != 3) + throw "4 failed"; + if (it.next() != 5) + throw "5 failed"; + if (it.next() != 8) + throw "6 failed"; + + var stopPassed = false; + try + { + it.next(); + } + catch (e) + { + if (e === StopIteration) + stopPassed = true; + } + if (!stopPassed) + throw "missing or incorrect StopIteration"; +} +catch (e) +{ + failed = e; +} + + + +expect = false; +actual = failed; + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/js1_7/geniter/shell.js b/js/src/tests/js1_7/geniter/shell.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/src/tests/js1_7/geniter/shell.js diff --git a/js/src/tests/js1_7/geniter/simple-fib.js b/js/src/tests/js1_7/geniter/simple-fib.js new file mode 100644 index 000000000..51c144ab9 --- /dev/null +++ b/js/src/tests/js1_7/geniter/simple-fib.js @@ -0,0 +1,55 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 326466; // bug 326466, comment 1 +var summary = "Simple Fibonacci iterator"; +var actual, expect; + +printBugNumber(BUGNUMBER); +printStatus(summary); + +/************** + * BEGIN TEST * + **************/ + +function fib() +{ + var a = 0, b = 1; + while (true) + { + yield a; + var t = a; + a = b; + b += t; + } +} + +var failed = false; + +try +{ + var g = fib(); + + if (g.next() != 0) + throw "F_0 = 0"; + if (g.next() != 1) + throw "F_1 = 1"; + if (g.next() != 1) + throw "F_2 = 1"; + if (g.next() != 2) + throw "F_3 = 2"; +} +catch (e) +{ + failed = e; +} + + + +expect = false; +actual = failed; + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/js1_7/geniter/throw-after-close.js b/js/src/tests/js1_7/geniter/throw-after-close.js new file mode 100644 index 000000000..3aef5e306 --- /dev/null +++ b/js/src/tests/js1_7/geniter/throw-after-close.js @@ -0,0 +1,90 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = "(none)"; +var summary = "gen.close(); gen.throw(ex) throws ex forever"; +var actual, expect; + +printBugNumber(BUGNUMBER); +printStatus(summary); + +/************** + * BEGIN TEST * + **************/ + +function gen() +{ + var x = 5, y = 7; + var z = x + y; + yield z; +} + +var failed = false; +var it = gen(); + +try +{ + it.close(); + + // throw on closed generators just rethrows + var doThrow = true; + var thrown = "foobar"; + try + { + it.throw(thrown); + } + catch (e) + { + if (e === thrown) + doThrow = false; + } + + if (doThrow) + throw "it.throw(\"" + thrown + "\") failed"; + + // you can throw stuff at a closed generator forever + doThrow = true; + thrown = "sparky"; + try + { + it.throw(thrown); + } + catch (e) + { + if (e === thrown) + doThrow = false; + } + + if (doThrow) + throw "it.throw(\"" + thrown + "\") failed"; + + // don't execute a yield -- the uncaught exception + // exhausted the generator + var stopPassed = false; + try + { + it.next(); + } + catch (e) + { + if (e === StopIteration) + stopPassed = true; + } + + if (!stopPassed) + throw "invalid or incorrect StopIteration"; +} +catch (e) +{ + failed = e; +} + + + +expect = false; +actual = failed; + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/js1_7/geniter/throw-forever.js b/js/src/tests/js1_7/geniter/throw-forever.js new file mode 100644 index 000000000..2e28b39f9 --- /dev/null +++ b/js/src/tests/js1_7/geniter/throw-forever.js @@ -0,0 +1,85 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = "(none)"; +var summary = "gen.throw(ex) returns ex for an exhausted gen"; +var actual, expect; + +printBugNumber(BUGNUMBER); +printStatus(summary); + +/************** + * BEGIN TEST * + **************/ + +function gen() +{ + var x = 5, y = 7; + var z = x + y; + yield z; +} + +var failed = false; +var it = gen(); + +try +{ + // throw works even on newly-initialized generators + var thrown = "foobar"; + var doThrow = true; + try + { + it.throw(thrown); + } + catch (e) + { + if (e === thrown) + doThrow = false; + } + if (doThrow) + throw "it.throw(\"" + thrown + "\") failed"; + + // you can throw stuff at a generator which hasn't + // been used yet forever + thrown = "baz"; + doThrow = true; + try + { + it.throw(thrown); + } + catch (e) + { + if (e === thrown) + doThrow = false; + } + if (doThrow) + throw "it.throw(\"" + thrown + "\") failed"; + + // don't execute a yield -- the uncaught exception + // exhausted the generator + var stopPassed = false; + try + { + it.next(); + } + catch (e) + { + if (e === StopIteration) + stopPassed = true; + } + + if (!stopPassed) + throw "missing or incorrect StopIteration"; +} +catch (e) +{ + failed = e; +} + +expect = false; +actual = failed; + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/js1_7/geniter/unreachable-yield.js b/js/src/tests/js1_7/geniter/unreachable-yield.js new file mode 100644 index 000000000..b1338ff64 --- /dev/null +++ b/js/src/tests/js1_7/geniter/unreachable-yield.js @@ -0,0 +1,57 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = "(none)"; +var summary = "Iterator with unreachable yield statement"; +var actual, expect; + +printBugNumber(BUGNUMBER); +printStatus(summary); + +/************** + * BEGIN TEST * + **************/ + +function gen() +{ + // this is still a generator even if yield can't + // be invoked, because yield is a syntactical + // part of the language + if (false) + yield "failed"; +} + +var failed = false; +try +{ + var it = gen(); + if (it == undefined) + throw "gen() not recognized as generator"; + + // no yields to execute + var stopPassed = false; + try + { + it.next(); + } + catch (e) + { + if (e === StopIteration) + stopPassed = true; + } + + if (!stopPassed) + throw "incorrect or invalid StopIteration"; +} +catch (e) +{ + failed = e; +} + +expect = false; +actual = failed; + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/js1_7/geniter/yield-new.js b/js/src/tests/js1_7/geniter/yield-new.js new file mode 100644 index 000000000..726da3944 --- /dev/null +++ b/js/src/tests/js1_7/geniter/yield-new.js @@ -0,0 +1,28 @@ +const K = 20; + +var obj; + +var g = new function() { + this.x = "puppies"; + obj = this; + for (var i = 0; i < K; ++i) + yield i; + yield this; +} + +var ct = 0; +for (var i in g) + assertEq((ct < K && ct++ == i) || i == obj, true); +assertEq(i.x, "puppies"); + +function g2() { + for (var i=0; i<20; i++) + yield i; +} +var i = 0; +for (var x of new g2()) { + assertEq(i, x); + i++; +} + +reportCompare(true,true); diff --git a/js/src/tests/js1_7/geniter/yield-undefined.js b/js/src/tests/js1_7/geniter/yield-undefined.js new file mode 100644 index 000000000..5e75fb601 --- /dev/null +++ b/js/src/tests/js1_7/geniter/yield-undefined.js @@ -0,0 +1,63 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +// Note that this syntax isn't in the most recently posted ES4 TG1 wiki export, +// either in the specification parts or in the grammar, so this test might be +// Spidermonkey-specific. +var BUGNUMBER = "(none)"; +var summary = "|yield;| is equivalent to |yield undefined;| "; +var actual, expect; + +printBugNumber(BUGNUMBER); +printStatus(summary); + +/************** + * BEGIN TEST * + **************/ + +var failed = false; + +function gen() +{ + yield 7; + yield; + yield 3; +} + +var it = gen(); + +try +{ + if (it.next() != 7) + throw "7 not yielded"; + if (it.next() !== undefined) + throw "|yield;| should be equivalent to |yield undefined;|"; + if (it.next() != 3) + throw "3 not yielded"; + + var stopPassed = false; + try + { + it.next(); + } + catch (e) + { + if (e === StopIteration) + stopPassed = true; + } + + if (!stopPassed) + throw "it: missing or incorrect StopIteration"; +} +catch (e) +{ + failed = e; +} + +expect = false; +actual = failed; + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/js1_7/iterable/browser.js b/js/src/tests/js1_7/iterable/browser.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/src/tests/js1_7/iterable/browser.js diff --git a/js/src/tests/js1_7/iterable/regress-340526-01.js b/js/src/tests/js1_7/iterable/regress-340526-01.js new file mode 100644 index 000000000..e3e189278 --- /dev/null +++ b/js/src/tests/js1_7/iterable/regress-340526-01.js @@ -0,0 +1,27 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 340526; +var summary = 'Iterators: cross-referenced objects with close handler can ' + + 'delay close handler execution'; +var actual = 'No Crash'; +var expect = 'No Crash'; + +printBugNumber(BUGNUMBER); +printStatus (summary); + +try +{ + var iter = Iterator({}); + iter.foo = "bar"; + for (var i in iter) + ; +} +catch(ex) +{ +} + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/js1_7/iterable/regress-340526-02.js b/js/src/tests/js1_7/iterable/regress-340526-02.js new file mode 100644 index 000000000..a94566a3d --- /dev/null +++ b/js/src/tests/js1_7/iterable/regress-340526-02.js @@ -0,0 +1,43 @@ +// |reftest| skip -- obsolete test +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 340526; +var summary = 'Iterators: cross-referenced objects with close handler can ' + + 'delay close handler execution'; + +printBugNumber(BUGNUMBER); +printStatus (summary); + +var close_count = 0; + +function gen() +{ + try { + yield 0; + } finally { + ++close_count; + } +} + +var iter1 = gen(); +var iter2 = gen(); + +iter1.another = iter2; +iter2.another = iter1; + +iter1.next(); +iter2.next(); + +iter1 = null; +iter2 = null; + +gc(); + +var expect = 2; +var actual = close_count; + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/js1_7/iterable/regress-341496.js b/js/src/tests/js1_7/iterable/regress-341496.js new file mode 100644 index 000000000..9e3a5aa3a --- /dev/null +++ b/js/src/tests/js1_7/iterable/regress-341496.js @@ -0,0 +1,19 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 341496; +var summary = 'Iterators: check that adding properties does not crash'; +var actual = 'No Crash'; +var expect = 'No Crash'; + +printBugNumber(BUGNUMBER); +printStatus (summary); + +var iter = Iterator({}); +for (var i = 0; i != 10*1000; ++i) + iter[i] = i; + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/js1_7/iterable/regress-341499.js b/js/src/tests/js1_7/iterable/regress-341499.js new file mode 100644 index 000000000..7e3d619f1 --- /dev/null +++ b/js/src/tests/js1_7/iterable/regress-341499.js @@ -0,0 +1,33 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 341499; +var summary = 'Iterators: do not assert from close handler when ' + + 'allocating GC things'; +var actual = 'No Crash'; +var expect = 'No Crash'; + +printBugNumber(BUGNUMBER); +printStatus (summary); + +var someGlobal; + +function generator() +{ + try { + yield 0; + } finally { + someGlobal = []; + } +} + +var iter = generator(); +iter.next(); +iter = null; + +gc(); + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/js1_7/iterable/regress-341510.js b/js/src/tests/js1_7/iterable/regress-341510.js new file mode 100644 index 000000000..27fb73b03 --- /dev/null +++ b/js/src/tests/js1_7/iterable/regress-341510.js @@ -0,0 +1,29 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 341510; +var summary = 'Iterators: crash in close handler with assignment to ' + + 'nonexistent name'; +var actual = 'No Crash'; +var expect = 'No Crash'; + +printBugNumber(BUGNUMBER); +printStatus (summary); + +function gen(i) { + try { + yield i; + } finally { + name_that_does_not_exist_in_the_scope_chain = 1; + } +} + +var iter = gen(1); +iter.next(); +iter = null; +gc(); + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/js1_7/iterable/regress-341815.js b/js/src/tests/js1_7/iterable/regress-341815.js new file mode 100644 index 000000000..51cf2ea28 --- /dev/null +++ b/js/src/tests/js1_7/iterable/regress-341815.js @@ -0,0 +1,94 @@ +// |reftest| skip-if(!xulRuntime.shell) -- bug xxx - fails to dismiss alert +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 341815; +var summary = 'Close hook crash'; +var actual = 'No Crash'; +var expect = 'No Crash'; + +var ialert = 0; +//----------------------------------------------------------------------------- +//test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + var globalToPokeGC = {}; + + function make_iterator() + { + function generator() { + try { + yield 0; + } finally { + make_iterator(); + } + } + generator().next(); + globalToPokeGC = {}; + if (typeof alert != 'undefined') + { + alert(++ialert); + } + } + + make_iterator(); + + for (var i = 0; i != 50000; ++i) { + var x = {}; + } + + print('done'); + + setTimeout('checkTest()', 10000); + + exitFunc ('test'); +} + +function init() +{ + // give the dialog closer time to register + setTimeout('test()', 5000); +} + +var lastialert = 0; + +function checkTest() +{ + // this function is used to check if there + // additional alerts are still being fired + // in order to prevent the test from completing + // until all alerts have finished. + + if (ialert != lastialert) + { + lastialert = ialert; + setTimeout('checkTest()', 10000); + return; + } + + reportCompare(expect, actual, summary); + gDelayTestDriverEnd = false; + jsTestDriverEnd(); +} + +if (typeof window != 'undefined') +{ + // delay test driver end + gDelayTestDriverEnd = true; + + window.addEventListener("load", init, false); +} +else +{ + reportCompare(expect, actual, summary); +} + diff --git a/js/src/tests/js1_7/iterable/regress-341821.js b/js/src/tests/js1_7/iterable/regress-341821.js new file mode 100644 index 000000000..03cf79898 --- /dev/null +++ b/js/src/tests/js1_7/iterable/regress-341821.js @@ -0,0 +1,83 @@ +// |reftest| skip-if(!xulRuntime.shell) -- bug xxx - fails to dismiss alert +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 341821; +var summary = 'Close hook crash'; +var actual = 'No Crash'; +var expect = 'No Crash'; + +var ialert = 0; + +//----------------------------------------------------------------------------- +//test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + function generator() + { + try { + yield []; + } finally { + make_iterator(); + } + } + + function make_iterator() + { + var iter = generator(); + iter.next(); + iter = null; + if (typeof alert != 'undefined') + { + alert(++ialert); + } + } + + make_iterator(); + + // Trigger GC through the branch callback. + for (var i = 0; i != 50000; ++i) { + var x = {}; + } + + print('done'); + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} + +function init() +{ + // give the dialog closer time to register + setTimeout('runtest()', 5000); +} + +function runtest() +{ + test(); + reportCompare(expect, actual, summary); + gDelayTestDriverEnd = false; + jsTestDriverEnd(); +} + +if (typeof window != 'undefined') +{ + // delay test driver end + gDelayTestDriverEnd = true; + + window.addEventListener("load", init, false); +} +else +{ + reportCompare(expect, actual, summary); +} + diff --git a/js/src/tests/js1_7/iterable/regress-354750-01.js b/js/src/tests/js1_7/iterable/regress-354750-01.js new file mode 100644 index 000000000..1ad600a78 --- /dev/null +++ b/js/src/tests/js1_7/iterable/regress-354750-01.js @@ -0,0 +1,42 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 354750; +var summary = 'Changing Iterator.prototype.next should not affect default iterator'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + Iterator.prototype.next = function() { + throw "This should not be thrown"; + } + + expect = 'No exception'; + actual = 'No exception'; + try + { + for (var i in []) + { + } + } + catch(ex) + { + actual = ex; + } + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/iterable/regress-355025.js b/js/src/tests/js1_7/iterable/regress-355025.js new file mode 100644 index 000000000..6407451c0 --- /dev/null +++ b/js/src/tests/js1_7/iterable/regress-355025.js @@ -0,0 +1,28 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 355025; +var summary = 'Test regression from bug 354750 - Iterable()'; +var actual = 'No Error'; +var expect = 'No Error'; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + Iterator([]); + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/iterable/regress-355075-01.js b/js/src/tests/js1_7/iterable/regress-355075-01.js new file mode 100644 index 000000000..a3b2e8ad6 --- /dev/null +++ b/js/src/tests/js1_7/iterable/regress-355075-01.js @@ -0,0 +1,38 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 355075; +var summary = 'Regression tests from bug 354750'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + options('strict'); + options('werror'); + + function f() { + this.a = {1: "a", 2: "b"}; + var dummy; + for (var b in this.a) + dummy = b; + } + + f(); + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/iterable/regress-355090.js b/js/src/tests/js1_7/iterable/regress-355090.js new file mode 100644 index 000000000..32f70456a --- /dev/null +++ b/js/src/tests/js1_7/iterable/regress-355090.js @@ -0,0 +1,37 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 355090; +var summary = 'Iterator(8) is a function'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + expect = 'No Error'; + actual = 'No Error'; + try + { + Iterator(8); + } + catch(ex) + { + actual = ex + ''; + } + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/iterable/regress-415922.js b/js/src/tests/js1_7/iterable/regress-415922.js new file mode 100644 index 000000000..c7fe29e7b --- /dev/null +++ b/js/src/tests/js1_7/iterable/regress-415922.js @@ -0,0 +1,49 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 415922; +var summary = 'Support exception from withing JSNewEnumerateOp on JSENUMERATE_NEXT'; +var actual = 'No Error'; +var expect = 'Error: its enumeration failed'; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + function f() { for (k in it) return k } + + if (typeof it == 'undefined') + { + print(expect = actual = 'it not defined, test skipped'); + } + else + { + try + { + it.enum_fail = true; + var r = f(); + actual = 'No exception r: ' + r.toString(); + } + catch (e) + { + actual = e + ''; + } + finally + { + it.enum_fail = false; + } + } + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/iterable/regress-568056.js b/js/src/tests/js1_7/iterable/regress-568056.js new file mode 100644 index 000000000..1f6570d38 --- /dev/null +++ b/js/src/tests/js1_7/iterable/regress-568056.js @@ -0,0 +1,24 @@ +// Any copyright is dedicated to the Public Domain. +// http://creativecommons.org/licenses/publicdomain/ + +var BUGNUMBER = 568056; +var summary = "Iterator(obj) must not go up obj's prototype chain"; + +var foo = { + z: 9, +}; + +var bar = { + __proto__: foo, + a: 1, + b: 2, +}; + +var results = []; +for each (let [key, value] in Iterator(bar)) + results.push(key + ":" + value); + +var actual = results.join(';') +var expect = "a:1;b:2"; + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/js1_7/iterable/shell.js b/js/src/tests/js1_7/iterable/shell.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/src/tests/js1_7/iterable/shell.js diff --git a/js/src/tests/js1_7/lexical/browser.js b/js/src/tests/js1_7/lexical/browser.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/src/tests/js1_7/lexical/browser.js diff --git a/js/src/tests/js1_7/lexical/regress-336376-01.js b/js/src/tests/js1_7/lexical/regress-336376-01.js new file mode 100644 index 000000000..959593e04 --- /dev/null +++ b/js/src/tests/js1_7/lexical/regress-336376-01.js @@ -0,0 +1,323 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = "336376"; +var summary = "Tests reserved words in contexts in which they are not reserved"; +var actual, expect; + +printBugNumber(BUGNUMBER); +printStatus(summary); + +/************** + * TEST SETUP * + **************/ + +// +// New tests go in Tester.prototype._tests. A test is called with a single +// argument, the keyword to test in the syntax tested by that test. Tests +// should not return anything, and they should signal failure by throwing an +// explanatory exception and success by not throwing one. +// +// If you define a new test, make sure to name it using an informative string +// for ease of use if any keywords ever manually define the array of tests they +// should pass, and add it as a string to ALL_TESTS. +// + +// all tests +const ALL_TESTS = + [ + "CONTEXT_OBJECT_LITERAL_PROPERTY", + "CONTEXT_OBJECT_PROPERTY_DOT_REFERENCE", + "CONTEXT_OBJECT_PROPERTY_DOT_REFERENCE_IS_FUNCTION", + "CONTEXT_OBJECT_PROPERTY_DOT_GET", + "CONTEXT_OBJECT_PROPERTY_DOT_SET", + ]; + +function r(keyword, tests) +{ + /** + * @param keyword + * the keyword as a string + * @param tests + * array of test numbers against it, or leave undefined to run all tests + * against it + */ + function Reserved(keyword, tests) + { + this.keyword = keyword; + if (tests) + this.tests = tests; + else + this.tests = ALL_TESTS; + } + Reserved.prototype = + { + toString: + function() + { + return "'" + this.keyword + "' being run against tests " + + this.tests; + } + }; + return new Reserved(keyword, tests); +} + +// ECMA-262, 3rd. ed. keywords -- see 7.5.2 +const ECMA_262_3_KEYWORD = + [ + r("break"), + r("case"), + r("catch"), + r("continue"), + r("default"), + r("delete"), + r("do"), + r("else"), + r("finally"), + r("for"), + r("function"), + r("if"), + r("in"), + r("instanceof"), + r("new"), + r("return"), + r("switch"), + r("this"), + r("throw"), + r("try"), + r("typeof"), + r("var"), + r("void"), + r("while"), + r("with"), + ]; + +// ECMA-262, 3rd. ed. future reserved keywords -- see 7.5.3 +const ECMA_262_3_FUTURERESERVEDKEYWORD = + [ + r("abstract"), + r("boolean"), + r("byte"), + r("char"), + r("class"), + r("const"), + r("debugger"), + r("double"), + r("enum"), + r("export"), + r("extends"), + r("final"), + r("float"), + r("goto"), + r("implements"), + r("import"), + r("int"), + r("interface"), + r("long"), + r("native"), + r("package"), + r("private"), + r("protected"), + r("public"), + r("short"), + r("static"), + r("super"), + r("synchronized"), + r("throws"), + r("transient"), + r("volatile"), + ]; + +// like reserved words, but not quite reserved words +const PSEUDO_RESERVED = + [ + r("true"), + r("false"), + r("null"), + r("each"), // |for each| + ]; + +// new-in-ES4 reserved words -- fill this as each is implemented +const ECMA_262_4_RESERVED_WORDS = + [ + r("let") + ]; + + + +/** + * @param keyword + * string containing the tested keyword + * @param test + * the number of the failing test + * @param error + * the exception thrown when running the test + */ +function Failure(keyword, test, error) +{ + this.keyword = keyword; + this.test = test; + this.error = error; +} +Failure.prototype = +{ + toString: + function() + { + return "*** FAILURE on '" + this.keyword + "'!\n" + + "* test: " + this.test + "\n" + + "* error: " + this.error + "\n"; + } +}; + +function Tester() +{ + this._failedTests = []; +} +Tester.prototype = +{ + testReservedWords: + function(reservedArray) + { + var rv; + for (var i = 0, sz = reservedArray.length; i < sz; i++) + { + var res = reservedArray[i]; + if (!res) + continue; + + var tests = res.tests; + for (var j = 0, sz2 = tests.length; j < sz2; j++) + { + var test = tests[j]; + if (!test) + continue; + + try + { + this._tests[test](res.keyword); + } + catch (e) + { + this._failedTests.push(new Failure(res.keyword, test, e)); + } + } + } + }, + flushErrors: + function () + { + if (this._failedTests.length > 0) { + var except = "*************************\n" + + "* FAILURES ENCOUNTERED! *\n" + + "*************************\n"; + for (var i = 0, sz = this._failedTests.length; i < sz; i++) + except += this._failedTests[i]; + throw except; + } + }, + _tests: + { + CONTEXT_OBJECT_LITERAL_PROPERTY: + function(keyword) + { + try + { + eval("var o = { " + keyword + ": 17 };\n" + + "if (o['" + keyword + "'] != 17)\n" + + "throw \"o['" + keyword + "'] == 17\";"); + } + catch (e) + { + throw e; + } + }, + CONTEXT_OBJECT_PROPERTY_DOT_REFERENCE: + function(keyword) + { + try + { + eval("var o = { \"" + keyword + "\": 17, baz: null };\n" + + "if (o." + keyword + " != 17)\n" + + "throw \"o." + keyword + " == 17\";"); + } + catch (e) + { + throw e; + } + }, + CONTEXT_OBJECT_PROPERTY_DOT_REFERENCE_IS_FUNCTION: + function(keyword) + { + try + { + eval("var o = { '" + keyword + "': function() { return 17; }, baz: null };\n" + + "if (o." + keyword + "() != 17)\n" + + "throw \"o." + keyword + " == 17\";"); + } + catch (e) + { + throw e; + } + }, + CONTEXT_OBJECT_PROPERTY_DOT_GET: + function(keyword) + { + try + { + var o = {}; + eval("o['" + keyword + "'] = 17;\n" + + "if (o." + keyword + " != 17)\n" + + "throw \"'o." + keyword + " != 17' failed!\";"); + } + catch (e) + { + throw e; + } + }, + CONTEXT_OBJECT_PROPERTY_DOT_SET: + function(keyword) + { + try + { + var o = {}; + eval("o." + keyword + " = 17;\n" + + "if (o['" + keyword + "'] != 17)\n" + + "throw \"'o." + keyword + " = 17' failed!\";"); + } + catch (e) + { + throw e; + } + }, + } +}; + + +/*************** + * BEGIN TESTS * + ***************/ + +var failed = false; + +try +{ + var tester = new Tester(); + tester.testReservedWords(ECMA_262_3_KEYWORD); + tester.testReservedWords(ECMA_262_3_FUTURERESERVEDKEYWORD); + tester.testReservedWords(PSEUDO_RESERVED); + tester.testReservedWords(ECMA_262_4_RESERVED_WORDS); + tester.flushErrors(); +} +catch (e) +{ + failed = e; +} + +expect = false; +actual = failed; + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/js1_7/lexical/regress-346642-03.js b/js/src/tests/js1_7/lexical/regress-346642-03.js new file mode 100644 index 000000000..14f36648b --- /dev/null +++ b/js/src/tests/js1_7/lexical/regress-346642-03.js @@ -0,0 +1,124 @@ +// |reftest| skip -- obsolete test +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 346642; +var summary = 'decompilation of destructuring assignment'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + expect = 'TypeError: NaN is not a constructor'; + actual = 'No Crash'; + try + { + try { throw 1; } catch(e1 if 0) { } catch(e2 if (new NaN)) { } + } + catch(ex) + { + actual = ex + ''; + } + reportCompare(expect, actual, summary + ': 1'); + + expect = /TypeError: x.t (has no properties|is undefined)/; + actual = 'No Crash'; + try + { + z = [1]; + let (x = (undefined ? 3 : z)) { x.t.g } + } + catch(ex) + { + actual = ex + ''; + } + reportMatch(expect, actual, summary + ': 2'); + + expect = /TypeError: x.t (has no properties|is undefined)/; + actual = 'No Crash'; + try + { + z = [1]; + new Function("let (x = (undefined ? 3 : z)) { x.t.g }")() + } + catch(ex) + { + actual = ex + ''; + } + reportMatch(expect, actual, summary + ': 3'); + + expect = 'TypeError: b is not a constructor'; + actual = 'No Crash'; + try + { + with({x: (new (b = 1))}) (2).x + } + catch(ex) + { + actual = ex + ''; + } + reportCompare(expect, actual, summary + ': 4'); + + expect = /TypeError: this.zzz (has no properties|is undefined)/; + actual = 'No Crash'; + try + { + (function(){try { } catch(f) { return; } finally { this.zzz.zzz }})(); + } + catch(ex) + { + actual = ex + ''; + } + reportMatch(expect, actual, summary + ': 5'); + + expect = 'TypeError: p.z = <x><y/></x> ? 3 : 4 is not a function'; + actual = 'No Crash'; + try + { + (new Function("if(\n({y:5, p: (print).r})) { p={}; (p.z = <x\n><y/></x> ? 3 : 4)(5) }"))(); + } + catch(ex) + { + actual = ex + ''; + } + reportCompare(expect, actual, summary + ': 6'); + + expect = 'TypeError: xx is not a function'; + actual = 'No Crash'; + try + { + switch(xx) { case 3: case (new ([3].map)): } const xx; + } + catch(ex) + { + actual = ex + ''; + } + reportCompare(expect, actual, summary + ': 7'); + + expect = 'ReferenceError: x.y is not defined'; + actual = 'No Crash'; + try + { + x = {}; + import x.y; + } + catch(ex) + { + actual = ex + ''; + } + reportCompare(expect, actual, summary + ': 9'); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/lexical/regress-346642-04.js b/js/src/tests/js1_7/lexical/regress-346642-04.js new file mode 100644 index 000000000..77fe059ce --- /dev/null +++ b/js/src/tests/js1_7/lexical/regress-346642-04.js @@ -0,0 +1,36 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 346642; +var summary = 'decompilation of destructuring assignment'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + expect = 'No Crash'; + actual = 'No Crash'; + try + { + (function() { for (var [a, b] in []) for ([c, d] in []) { } }); + } + catch(ex) + { + actual = ex + ''; + } + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/lexical/regress-351515.js b/js/src/tests/js1_7/lexical/regress-351515.js new file mode 100644 index 000000000..e68e3da50 --- /dev/null +++ b/js/src/tests/js1_7/lexical/regress-351515.js @@ -0,0 +1,97 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 351515; +var summary = 'Invalid uses of yield, let keywords in js17'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +try +{ + expect = "SyntaxError"; + eval('yield = 1;'); + actual = 'No Error'; +} +catch(ex) +{ + actual = ex.name; +} +reportCompare(expect, actual, summary + ': global: yield = 1'); + +try +{ + expect = "SyntaxError"; + eval('(function(){yield = 1;})'); + actual = 'No Error'; +} +catch(ex) +{ + actual = ex.name; +} +reportCompare(expect, actual, summary + ': local: yield = 1'); + +try +{ + expect = "No Error"; + eval('let = 1;'); + actual = 'No Error'; +} +catch(ex) +{ + actual = ex.name; +} +reportCompare(expect, actual, summary + ': global: let = 1'); + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + try + { + expect = "SyntaxError"; + eval('function f(yield, let) { return yield+let; }'); + actual = 'No Error'; + } + catch(ex) + { + actual = ex.name; + } + reportCompare(expect, actual, summary + + ': function f(yield, let) { return yield+let; }'); + + try + { + expect = "SyntaxError"; + eval('var yield = 1;'); + actual = 'No Error'; + } + catch(ex) + { + actual = ex.name; + } + reportCompare(expect, actual, summary + ': function () {var yield;}'); + + try + { + expect = "No Error"; + eval('var let = 1;'); + actual = 'No Error'; + } + catch(ex) + { + actual = ex.name; + } + reportCompare(expect, actual, summary + ': function () { var let;}'); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/lexical/shell.js b/js/src/tests/js1_7/lexical/shell.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/src/tests/js1_7/lexical/shell.js diff --git a/js/src/tests/js1_7/regexp/browser.js b/js/src/tests/js1_7/regexp/browser.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/src/tests/js1_7/regexp/browser.js diff --git a/js/src/tests/js1_7/regexp/shell.js b/js/src/tests/js1_7/regexp/shell.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/src/tests/js1_7/regexp/shell.js diff --git a/js/src/tests/js1_7/regexp/yflag.js b/js/src/tests/js1_7/regexp/yflag.js new file mode 100644 index 000000000..079aae304 --- /dev/null +++ b/js/src/tests/js1_7/regexp/yflag.js @@ -0,0 +1,88 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 371932; +var summary = 'ES4 Regular Expression /y flag'; +var actual = ''; +var expect = ''; + +print('See http://developer.mozilla.org/es4/proposals/extend_regexps.html#y_flag'); + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + var c; + var s = '123456'; + + print('Test global flag.'); + + var g = /(1)/g; + expect = 'captures: 1,1; RegExp.leftContext: ""; RegExp.rightContext: "234561"'; + actual = 'captures: ' + g.exec('1234561') + + '; RegExp.leftContext: "' + RegExp.leftContext + + '"; RegExp.rightContext: "' + RegExp.rightContext + '"'; + reportCompare(expect, actual, summary + ' - /(1)/g.exec("1234561") first call'); + + expect = 'captures: 1,1; RegExp.leftContext: "123456"; RegExp.rightContext: ""'; + actual = 'captures: ' + g.exec('1234561') + + '; RegExp.leftContext: "' + RegExp.leftContext + + '"; RegExp.rightContext: "' + RegExp.rightContext + '"'; + reportCompare(expect, actual, summary + ' - /(1)/g.exec("1234561") second call'); + var y = /(1)/y; + + print('Test sticky flag.'); + + /* + * calls to reportCompare invoke regular expression matches which interfere + * with the test of the sticky flag. Collect expect and actual values prior + * to calling reportCompare. Note setting y = /(1)/y resets the lastIndex etc. + */ + + var y = /(1)/y; + var expect4 = 'captures: 1,1; RegExp.leftContext: ""; RegExp.rightContext: "234561"'; + var actual4 = 'captures: ' + y.exec('1234561') + + '; RegExp.leftContext: "' + RegExp.leftContext + + '"; RegExp.rightContext: "' + RegExp.rightContext + '"'; + + var expect5 = 'captures: null; RegExp.leftContext: ""; RegExp.rightContext: "234561"'; + var actual5 = 'captures: ' + y.exec('1234561') + + '; RegExp.leftContext: "' + RegExp.leftContext + + '"; RegExp.rightContext: "' + RegExp.rightContext + '"'; + + reportCompare(expect4, actual4, summary + ' - /(1)/y.exec("1234561") first call'); + reportCompare(expect5, actual5, summary + ' - /(1)/y.exec("1234561") second call'); + + var y = /(1)/y; + + reportCompare(expect5, actual5, summary); + + y = /(1)/y; + var expect6 = 'captures: 1,1; RegExp.leftContext: ""; RegExp.rightContext: "123456"'; + var actual6 = 'captures: ' + y.exec('1123456') + + '; RegExp.leftContext: "' + RegExp.leftContext + + '"; RegExp.rightContext: "' + RegExp.rightContext + '"'; + + var expect7 = 'captures: 1,1; RegExp.leftContext: "1"; RegExp.rightContext: "23456"'; + var actual7 = 'captures: ' + y.exec('1123456') + + '; RegExp.leftContext: "' + RegExp.leftContext + + '"; RegExp.rightContext: "' + RegExp.rightContext + '"'; + + reportCompare(expect6, actual6, summary + ' - /(1)/y.exec("1123456") first call'); + reportCompare(expect7, actual7, summary + ' - /(1)/y.exec("1123456") second call'); + + var y = /(1)/y; + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/regress/browser.js b/js/src/tests/js1_7/regress/browser.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/src/tests/js1_7/regress/browser.js diff --git a/js/src/tests/js1_7/regress/regress-350387.js b/js/src/tests/js1_7/regress/regress-350387.js new file mode 100644 index 000000000..6bdf33dd7 --- /dev/null +++ b/js/src/tests/js1_7/regress/regress-350387.js @@ -0,0 +1,38 @@ +// |reftest| skip -- obsolete test +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 350387; +var summary = 'Var declaration and let with same name'; +var actual = ''; +var expect = ''; + +expect = undefined + ''; +actual = ''; +let (x = 2) +{ + var x; +} +actual = x + ''; +reportCompare(expect, actual, summary + ': 1'); + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + expect = undefined + ''; + actual = ''; + (function () { let (x = 2) { var x; } actual = x + ''; })(); + reportCompare(expect, actual, summary + ': 2'); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/regress/regress-352640-01.js b/js/src/tests/js1_7/regress/regress-352640-01.js new file mode 100644 index 000000000..0ed722e41 --- /dev/null +++ b/js/src/tests/js1_7/regress/regress-352640-01.js @@ -0,0 +1,33 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 352640; +var summary = 'Do not assert: scopeStmt or crash @ js_LexicalLookup'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + try + { + new Function("do { with({}) let x; let b; } while( 1 );"); + } + catch(ex) + { + } + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/regress/regress-352640-02.js b/js/src/tests/js1_7/regress/regress-352640-02.js new file mode 100644 index 000000000..6336e4e86 --- /dev/null +++ b/js/src/tests/js1_7/regress/regress-352640-02.js @@ -0,0 +1,33 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 352640; +var summary = 'Do not assert: scopeStmt or crash @ js_LexicalLookup'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + try + { + new Function("do { with({}) let x; var b; } while( 1 );"); + } + catch(ex) + { + } + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/regress/regress-352640-03.js b/js/src/tests/js1_7/regress/regress-352640-03.js new file mode 100644 index 000000000..0499101b0 --- /dev/null +++ b/js/src/tests/js1_7/regress/regress-352640-03.js @@ -0,0 +1,33 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 352640; +var summary = 'Do not assert: scopeStmt or crash @ js_LexicalLookup'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + try + { + new Function("do { with({}) let x; [2 for each (b in [])]; } while( 1 );"); + } + catch(ex) + { + } + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/regress/regress-352640-04.js b/js/src/tests/js1_7/regress/regress-352640-04.js new file mode 100644 index 000000000..477695126 --- /dev/null +++ b/js/src/tests/js1_7/regress/regress-352640-04.js @@ -0,0 +1,33 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 352640; +var summary = 'Do not assert: scopeStmt or crash @ js_LexicalLookup'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + try + { + new Function("switch(w) { case 2: with({}) let y; case 3: }"); + } + catch(ex) + { + } + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/regress/regress-353079.js b/js/src/tests/js1_7/regress/regress-353079.js new file mode 100644 index 000000000..2c7fd015f --- /dev/null +++ b/js/src/tests/js1_7/regress/regress-353079.js @@ -0,0 +1,29 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 353079; +var summary = 'Do not Assert op == JSOP_LEAVEBLOCKEXPR... with WAY_TOO_MUCH_GC'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + for (let a in [1]) { { let x; + for (let y in ((function(id2) { return id2; })( '' ))) { } } } + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/regress/regress-355023.js b/js/src/tests/js1_7/regress/regress-355023.js new file mode 100644 index 000000000..73d055990 --- /dev/null +++ b/js/src/tests/js1_7/regress/regress-355023.js @@ -0,0 +1,31 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 355023; +var summary = 'destructuring assignment optimization'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + Array.prototype[0] = 1024; + + expect = (function(){ var a=[],[x]=a; return x; })(); + actual = (function(){ var [x]=[]; return x; })(); + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/regress/regress-355832-01.js b/js/src/tests/js1_7/regress/regress-355832-01.js new file mode 100644 index 000000000..dccf7e832 --- /dev/null +++ b/js/src/tests/js1_7/regress/regress-355832-01.js @@ -0,0 +1,30 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 355832; +var summary = 'execution of let binding nothing'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + expect = actual = 'No Crash'; + + { let [] = []; } + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/regress/regress-355832-02.js b/js/src/tests/js1_7/regress/regress-355832-02.js new file mode 100644 index 000000000..54e1506e4 --- /dev/null +++ b/js/src/tests/js1_7/regress/regress-355832-02.js @@ -0,0 +1,30 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 355832; +var summary = 'execution of let binding nothing'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + expect = actual = 'No Crash'; + + { let [] = []; print(3) } print(4) + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/regress/regress-363040-01.js b/js/src/tests/js1_7/regress/regress-363040-01.js new file mode 100644 index 000000000..dc081fe45 --- /dev/null +++ b/js/src/tests/js1_7/regress/regress-363040-01.js @@ -0,0 +1,95 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 363040; +var summary = 'Array.prototype.reduce, Array.prototype.reduceRight'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + function f(x,y) { return '(' + x + '+' + y + ')';} + + var testdesc; + var arr0elms = []; + var arr1elms = [1]; + var arr2elms = [1, 2]; + + testdesc = 'Test reduce of empty array without initializer.'; + try + { + expect = 'TypeError: reduce of empty array with no initial value'; + arr0elms.reduce(f); + } + catch(ex) + { + actual = ex + ''; + } + reportCompare(expect + '', actual + '', testdesc + ' : ' + expect); + + testdesc = 'Test reduceRight of empty array without initializer.'; + try + { + expect = 'TypeError: reduce of empty array with no initial value'; + arr0elms.reduceRight(f); + } + catch(ex) + { + actual = ex + ''; + } + reportCompare(expect + '', actual + '', testdesc + ' : ' + expect); + + testdesc = 'Test reduce of empty array with initial value.'; + expect = 'a'; + actual = arr0elms.reduce(f, 'a'); + reportCompare(expect + '', actual + '', testdesc + ' : ' + expect); + + testdesc = 'Test reduceRight of empty array with initial value.'; + expect = 'a'; + actual = arr0elms.reduceRight(f, 'a'); + reportCompare(expect + '', actual + '', testdesc +' : ' + expect); + + testdesc = 'Test reduce of 1 element array with no initializer.'; + expect = '1'; + actual = arr1elms.reduce(f); + reportCompare(expect + '', actual + '', testdesc + ' : ' + expect); + + testdesc = 'Test reduceRight of 1 element array with no initializer.'; + expect = '1'; + actual = arr1elms.reduceRight(f); + reportCompare(expect + '', actual + '', testdesc + ' : ' + expect); + + testdesc = 'Test reduce of 2 element array with no initializer.'; + expect = '(1+2)'; + actual = arr2elms.reduce(f); + reportCompare(expect + '', actual + '', testdesc + ' : ' + expect); + + testdesc = 'Test reduce of 2 element array with initializer.'; + expect = '((a+1)+2)'; + actual = arr2elms.reduce(f,'a'); + reportCompare(expect + '', actual + '', testdesc + ' : ' + expect); + + testdesc = 'Test reduceRight of 2 element array with no initializer.'; + expect = '(2+1)'; + actual = arr2elms.reduceRight(f); + reportCompare(expect + '', actual + '', testdesc + ' : ' + expect); + + testdesc = 'Test reduceRight of 2 element array with no initializer.'; + expect = '((a+2)+1)'; + actual = arr2elms.reduceRight(f,'a'); + reportCompare(expect + '', actual + '', testdesc + ' : ' + expect); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/regress/regress-363040-02.js b/js/src/tests/js1_7/regress/regress-363040-02.js new file mode 100644 index 000000000..c24e4a605 --- /dev/null +++ b/js/src/tests/js1_7/regress/regress-363040-02.js @@ -0,0 +1,67 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 363040; +var summary = 'Array.prototype.reduce application in array flattening'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + function flatten(arr) + { + function op(partial, item) + { + if (item instanceof Array) + Array.prototype.push.apply(partial, flatten(item)); + else + partial.push(item); + + return partial; + } + + return arr.reduce(op, []); + } + + expect = [1, 2, 3]; + actual = flatten([1, 2, 3]); // [1, 2, 3] + reportCompare(expect + '', actual + '', summary + ': ' + expect); + + expect = [1, 2, 3]; + actual = flatten([1, [2], 3]); // [1, 2, 3] + reportCompare(expect + '', actual + '', summary + ': ' + expect); + + expect = [2, 3]; + actual = flatten([[], 2, 3]); // [2, 3] + reportCompare(expect + '', actual + '', summary + ': ' + expect); + + expect = [1, 2, 3]; + actual = flatten([[1], 2, 3]); // [1, 2, 3] + reportCompare(expect + '', actual + '', summary + ': ' + expect); + + expect = [4]; + actual = flatten([[[[4]]]]); // [4] + reportCompare(expect + '', actual + '', summary + ': ' + expect); + + expect = [1, 2, 3]; + actual = flatten([1, [2, [3]]]); // [1, 2, 3] + reportCompare(expect + '', actual + '', summary + ': ' + expect); + + expect = []; + actual = flatten([[[[[]]]]]); // [] + reportCompare(expect + '', actual + '', summary + ': ' + expect); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/regress/regress-369666-01.js b/js/src/tests/js1_7/regress/regress-369666-01.js new file mode 100644 index 000000000..1be90603f --- /dev/null +++ b/js/src/tests/js1_7/regress/regress-369666-01.js @@ -0,0 +1,59 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 369666; +var summary = 'inner function declaration in let-induced outer ' + + 'function body gets wrong scope.'; +var actual = 'No Crash'; +var expect = 'No Crash'; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + function foo() { + let x = 42 + + function bar() { + return x; + } + + return bar; + } + + print(foo()()); + + baz = false; + + function foo2() { + let x = 42 + + function bar() { + return x; + } + + try { + if (baz) + return bar; + } finally { + print('finally', x); + } + return bar; + } + + print(foo2()()); + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/regress/regress-369666-02.js b/js/src/tests/js1_7/regress/regress-369666-02.js new file mode 100644 index 000000000..f55b49617 --- /dev/null +++ b/js/src/tests/js1_7/regress/regress-369666-02.js @@ -0,0 +1,63 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 369666; +var summary = 'inner function declaration in let-induced outer ' + + 'function body gets wrong scope.'; +var actual = 'No Crash'; +var expect = 'No Crash'; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + function foo() { + let x = 42 + + function bar() { + return x; + } + + return bar; + } + + print(foo()()); + + baz = false; + + function foo2() { + let x = 42 + + function bar() { + return x; + } + + function bletch() { + return x * x; + } + + try { + if (baz) + return bar; + } finally { + print('finally', x); + } + return bletch; + } + + print(foo2()()); + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/regress/regress-372331.js b/js/src/tests/js1_7/regress/regress-372331.js new file mode 100644 index 000000000..a9a868724 --- /dev/null +++ b/js/src/tests/js1_7/regress/regress-372331.js @@ -0,0 +1,55 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 372331; +var summary = 'for-in should not bind name too early'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + var index; + var obj = { index: 1 }; + + expect = 'No Error'; + actual = 'No Error'; + + function gen() + { + delete obj.index; + yield 2; + } + + with (obj) { + for (index in gen()); + } + + try + { + if ('index' in obj) + throw "for-in binds name to early"; + + if (index !== 2) + throw "unexpected value of index: "+index; + } + catch(ex) + { + actual = ex + ''; + } + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/regress/regress-373827-01.js b/js/src/tests/js1_7/regress/regress-373827-01.js new file mode 100644 index 000000000..01da279f8 --- /dev/null +++ b/js/src/tests/js1_7/regress/regress-373827-01.js @@ -0,0 +1,28 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 373827; +var summary = 'Do not assert: OBJ_GET_CLASS(cx, obj)->flags & JSCLASS_HAS_PRIVATE'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + { let [] = [{x: function(){}}]; }; + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/regress/regress-373827-02.js b/js/src/tests/js1_7/regress/regress-373827-02.js new file mode 100644 index 000000000..3596feb69 --- /dev/null +++ b/js/src/tests/js1_7/regress/regress-373827-02.js @@ -0,0 +1,34 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 373827; +var summary = 'Do not assert: OBJ_GET_CLASS(cx, obj)->flags & JSCLASS_HAS_PRIVATE'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + try + { + { let [] = [{x: function(){}}]; }; foo; + } + catch(ex) + { + } + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/regress/regress-375695.js b/js/src/tests/js1_7/regress/regress-375695.js new file mode 100644 index 000000000..508560ce9 --- /dev/null +++ b/js/src/tests/js1_7/regress/regress-375695.js @@ -0,0 +1,27 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 375695; +var summary = 'Do not assert: !fp->blockChain || OBJ_GET_PARENT(cx, obj) == fp->blockChain'; +var actual = ''; +var expect = ''; + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + try { try { throw 1 } catch([] if false) { } } catch(ex) {} + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/regress/regress-379442.js b/js/src/tests/js1_7/regress/regress-379442.js new file mode 100644 index 000000000..639523270 --- /dev/null +++ b/js/src/tests/js1_7/regress/regress-379442.js @@ -0,0 +1,28 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 379442; +var summary = 'Regression from bug 368224'; +var actual = 'No Crash'; +var expect = 'No Crash'; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + reportCompare(expect, actual, summary); + + (function () { ({ y: [] } = {}); }); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/regress/regress-379483.js b/js/src/tests/js1_7/regress/regress-379483.js new file mode 100644 index 000000000..f9ee84b30 --- /dev/null +++ b/js/src/tests/js1_7/regress/regress-379483.js @@ -0,0 +1,28 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 379483; +var summary = 'Do not assert: top < ss->printer->script->depth'; +var actual = 'No Crash'; +var expect = 'No Crash'; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + (function () { try { } catch([e]) { [1]; } }); + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/regress/regress-385133-01.js b/js/src/tests/js1_7/regress/regress-385133-01.js new file mode 100644 index 000000000..03b09f535 --- /dev/null +++ b/js/src/tests/js1_7/regress/regress-385133-01.js @@ -0,0 +1,37 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 385133; +var summary = 'Do not crash due to recursion with watch, setter, delete, generator'; +var actual = 'No Crash'; +var expect = 'No Crash'; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + try + { + Object.defineProperty(this, "x", { set: {}.watch, enumerable: true, configurable: true }); + this.watch('x', 'foo'.split); + delete x; + function g(){ x = 1; yield; } + for (i in g()) { } + } + catch(ex) + { + } + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/regress/regress-385133-02.js b/js/src/tests/js1_7/regress/regress-385133-02.js new file mode 100644 index 000000000..ce429dd15 --- /dev/null +++ b/js/src/tests/js1_7/regress/regress-385133-02.js @@ -0,0 +1,35 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 385133; +var summary = 'Do not crash due to recursion with watch, setter, delete, generator'; +var actual = 'No Crash'; +var expect = 'No Crash'; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + try + { + Object.defineProperty(this, "x", { set: {}.watch, enumerable: true, configurable: true }); + function g() { x = 1; yield; } + g().next(); + } + catch(ex) + { + } + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/regress/regress-385393-05.js b/js/src/tests/js1_7/regress/regress-385393-05.js new file mode 100644 index 000000000..c642c4ec6 --- /dev/null +++ b/js/src/tests/js1_7/regress/regress-385393-05.js @@ -0,0 +1,44 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + + +//----------------------------------------------------------------------------- +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); + + function c(gen) + { + Iterator; + + "" + gen; + + for (var i in gen()) + ; + } + + function gen() + { + ({}).hasOwnProperty(); + yield; + } + + c(gen); + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/regress/regress-407727-01.js b/js/src/tests/js1_7/regress/regress-407727-01.js new file mode 100644 index 000000000..f92113f5e --- /dev/null +++ b/js/src/tests/js1_7/regress/regress-407727-01.js @@ -0,0 +1,17 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 407727; +var summary = 'let Object global redeclaration'; +var actual = ''; +var expect = 1; + +printBugNumber(BUGNUMBER); +printStatus (summary); + +let Object = 1; +actual = Object; +reportCompare(expect, actual, summary); diff --git a/js/src/tests/js1_7/regress/regress-407727-02.js b/js/src/tests/js1_7/regress/regress-407727-02.js new file mode 100644 index 000000000..bcc7a38ab --- /dev/null +++ b/js/src/tests/js1_7/regress/regress-407727-02.js @@ -0,0 +1,19 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 407727; +var summary = 'let Object block redeclaration'; +var actual = ''; +var expect = 1; + +printBugNumber(BUGNUMBER); +printStatus (summary); + +{ + let Object = 1; + actual = Object; + reportCompare(expect, actual, summary); +} diff --git a/js/src/tests/js1_7/regress/regress-407957.js b/js/src/tests/js1_7/regress/regress-407957.js new file mode 100644 index 000000000..ffd05bd42 --- /dev/null +++ b/js/src/tests/js1_7/regress/regress-407957.js @@ -0,0 +1,30 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 407957; +var summary = 'Iterator is mutable.'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + var obj = {}; + var saveIterator = Iterator; + + Iterator = obj; + reportCompare(obj, Iterator, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/regress/regress-410649.js b/js/src/tests/js1_7/regress/regress-410649.js new file mode 100644 index 000000000..ddd2b2a57 --- /dev/null +++ b/js/src/tests/js1_7/regress/regress-410649.js @@ -0,0 +1,42 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 410649; +var summary = 'function statement and destructuring parameter name clash'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + function f(a) { + function a() { } + return a; + } + + function g([a, b]) { + function a() { } + return a; + } + + expect = 'function'; + actual = typeof f(1); + reportCompare(expect, actual, "type for simple parameter case"); + + expect = 'function'; + actual = typeof g([1, 2]); + reportCompare(expect, actual, "type for destructuring parameter case"); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/regress/regress-414553.js b/js/src/tests/js1_7/regress/regress-414553.js new file mode 100644 index 000000000..6f5139022 --- /dev/null +++ b/js/src/tests/js1_7/regress/regress-414553.js @@ -0,0 +1,25 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 414553; +printBugNumber(BUGNUMBER); +printStatus(summary); + +var expected = '1,2,3,4'; + +let a = 1, [b,c] = [2,3], d = 4; +var actual = String([a,b,c,d]); + +reportCompare(expected, actual, 'destructuring assignment in let'); + +function f() { + { + let a = 1, [b,c] = [2,3], d = 4; + return String([a,b,c,d]); + } +} + +reportCompare(expected, f(), 'destructuring assignment in let inside func'); diff --git a/js/src/tests/js1_7/regress/regress-416601.js b/js/src/tests/js1_7/regress/regress-416601.js new file mode 100644 index 000000000..197bf29af --- /dev/null +++ b/js/src/tests/js1_7/regress/regress-416601.js @@ -0,0 +1,37 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 416601; +var summary = 'Property cache can be left disabled after exit from a generator or trap handler'; +var actual = 'No Crash'; +var expect = 'No Crash'; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + function f() + { + with (Math) { + yield 1; + } + } + + var iter = f(); + iter.next(); + iter.close(); + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/regress/regress-418641.js b/js/src/tests/js1_7/regress/regress-418641.js new file mode 100644 index 000000000..7d194fc32 --- /dev/null +++ b/js/src/tests/js1_7/regress/regress-418641.js @@ -0,0 +1,80 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 418641; +var summary = '++ and -- correctness'; +var actual = ''; +var expect = ''; + +printBugNumber(BUGNUMBER); +printStatus (summary); + +function get_pre_check(operand, op) +{ + return "{\n"+ + " "+operand+" = I;\n"+ + " let tmp = "+op+op+operand+";\n"+ + " if ("+operand+" !== Number(I) "+op+" 1)\n"+ + " throw Error('"+op+op+operand+" case 1 for '+uneval(I));\n"+ + " if (tmp !== "+operand+")\n"+ + " throw Error('"+op+op+operand+" case 2 for '+uneval(I));\n"+ + "}\n"; +} + +function get_post_check(operand, op) +{ + return "{\n"+ + " "+operand+" = I;\n"+ + " let tmp = "+operand+op+op+";\n"+ + " if ("+operand+" !== Number(I) "+op+" 1)\n"+ + " throw Error('"+operand+op+op+" case 1 for '+uneval(I));\n"+ + " if (tmp !== Number(I))\n"+ + " throw Error('"+op+op+operand+" case 2 for '+uneval(I));\n"+ + "}\n"; +} + +function get_check_source(operand) +{ + return get_pre_check(operand, '+')+ + get_pre_check(operand, '-')+ + get_post_check(operand, '+')+ + get_post_check(operand, '-'); +} + +var arg_check = Function('I', 'a', get_check_source('a')); +var let_check = Function('I', 'let a;'+get_check_source('a')); +var var_check = Function('I', 'var a;'+get_check_source('a')); + +var my_name; +var my_obj = {}; +var my_index = 0; +var name_check = Function('I', get_check_source('my_name')); +var prop_check = Function('I', get_check_source('my_obj.x')); +var elem_check = Function('I', get_check_source('my_obj[my_index]')); + +var test_values = [0 , 0.5, -0.0, (1 << 30) - 1, 1 - (1 << 30)]; + +for (let i = 0; i != test_values.length; i = i + 1) { + let x = [test_values[i], String(test_values[i])]; + for (let j = 0; j != x.length; j = j + 1) { + try + { + expect = actual = 'No Error'; + let test_value = x[j]; + arg_check(test_value, 0); + let_check(test_value); + var_check(test_value); + name_check(test_value); + prop_check(test_value); + elem_check(test_value); + } + catch(ex) + { + actual = ex + ''; + } + reportCompare(expect, actual, summary + ': ' + i + ', ' + j); + } +} diff --git a/js/src/tests/js1_7/regress/regress-419803.js b/js/src/tests/js1_7/regress/regress-419803.js new file mode 100644 index 000000000..aa4b56aad --- /dev/null +++ b/js/src/tests/js1_7/regress/regress-419803.js @@ -0,0 +1,31 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 419803; +var summary = 'Do not assert: sprop->parent == scope->lastProp'; +var actual = 'No Crash'; +var expect = 'No Crash'; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + function g() { for (var i=0; i<2; ++i) yield ({ p: 5, p: 7 }); } + var iter = g(); + print(uneval(iter.next())); + print(uneval(iter.next())); + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/regress/regress-452703.js b/js/src/tests/js1_7/regress/regress-452703.js new file mode 100644 index 000000000..e86f2625f --- /dev/null +++ b/js/src/tests/js1_7/regress/regress-452703.js @@ -0,0 +1,19 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 452703; +var summary = 'Do not assert with JIT: rmask(rr)&FpRegs'; +var actual = 'No Crash'; +var expect = 'No Crash'; + +printBugNumber(BUGNUMBER); +printStatus (summary); + + +(function() { for(let y in [0,1,2,3,4]) y = NaN; })(); + + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/js1_7/regress/regress-452960.js b/js/src/tests/js1_7/regress/regress-452960.js new file mode 100644 index 000000000..8b58fd15a --- /dev/null +++ b/js/src/tests/js1_7/regress/regress-452960.js @@ -0,0 +1,31 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 452960; +var summary = 'Do not assert with JIT: !v.isPrimitive()'; +var actual = 'No Crash'; +var expect = 'No Crash'; + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + + var f = function(){}; + f.prototype = false; + for (let j=0;j<5;++j) { new f; } + + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/regress/regress-453049.js b/js/src/tests/js1_7/regress/regress-453049.js new file mode 100644 index 000000000..77ca02a5d --- /dev/null +++ b/js/src/tests/js1_7/regress/regress-453049.js @@ -0,0 +1,29 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 453049; +var summary = 'Do not assert with JIT: (*m != JSVAL_INT) || isInt32(*vp)'; +var actual = 'No Crash'; +var expect = 'No Crash'; + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + + var z = 0; for (let j = 0; j < 5; ++j) { ({p: (-z)}); } + + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/regress/regress-453051.js b/js/src/tests/js1_7/regress/regress-453051.js new file mode 100644 index 000000000..706f6c7e1 --- /dev/null +++ b/js/src/tests/js1_7/regress/regress-453051.js @@ -0,0 +1,29 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 453051; +var summary = 'Do not assert with JIT: !(((*pc == JSOP_GOTO) || (*pc == JSOP_GOTOX)) && (exitType != LOOP_EXIT))'; +var actual = 'No Crash'; +var expect = 'No Crash'; + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + + for (var p in this){} for (let a in [5,6,7]) for (var b=0;b<1;++b) break; + + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/regress/regress-453411.js b/js/src/tests/js1_7/regress/regress-453411.js new file mode 100644 index 000000000..d3a490ac4 --- /dev/null +++ b/js/src/tests/js1_7/regress/regress-453411.js @@ -0,0 +1,30 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 453411; +var summary = 'Do not assert with JIT: !cx->executingTrace|!tm->onTrace'; +var actual = 'No Crash'; +var expect = 'No Crash'; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + + for (var i in (function(){ for (var j=0;j<4;++j) { yield ""; } })()); + + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/regress/regress-462071.js b/js/src/tests/js1_7/regress/regress-462071.js new file mode 100644 index 000000000..8282184bb --- /dev/null +++ b/js/src/tests/js1_7/regress/regress-462071.js @@ -0,0 +1,30 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 462071; +var summary = 'Do not assert: !ti->stackTypeMap.matches(ti_other->stackTypeMap)'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + + for each (let i in [{}, 0, 0, {}, 0, {}, 0]) { } + + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/regress/regress-462282.js b/js/src/tests/js1_7/regress/regress-462282.js new file mode 100644 index 000000000..2ba12998a --- /dev/null +++ b/js/src/tests/js1_7/regress/regress-462282.js @@ -0,0 +1,30 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 462282; +var summary = 'Do not assert: !ti->stackTypeMap.matches(ti_other->stackTypeMap)'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + + for each (let i in [0, 0, 0, "", 0, 0, "", 0, 0, "", 0]) { } + + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/regress/regress-462388.js b/js/src/tests/js1_7/regress/regress-462388.js new file mode 100644 index 000000000..b1f03e61e --- /dev/null +++ b/js/src/tests/js1_7/regress/regress-462388.js @@ -0,0 +1,30 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 462388; +var summary = 'Do not assert: JSVAL_TAG(v) == JSVAL_STRING'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + + var c = 0, v; for each (let x in ["",v,v,v]) { for (c=0;c<4;++c) { } } + + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/regress/regress-462407.js b/js/src/tests/js1_7/regress/regress-462407.js new file mode 100644 index 000000000..236f1aae4 --- /dev/null +++ b/js/src/tests/js1_7/regress/regress-462407.js @@ -0,0 +1,19 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 462407; +var summary = 'Do not assert: !ti->stackTypeMap.matches(ti_other->stackTypeMap)'; +var actual = ''; +var expect = ''; + +printBugNumber(BUGNUMBER); +printStatus (summary); + + +(function f() { for each (let i in [0, {}, 0, 1.5, {}, 0, 1.5, 0, 0]) { }})(); + + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/js1_7/regress/regress-464403.js b/js/src/tests/js1_7/regress/regress-464403.js new file mode 100644 index 000000000..c26ab44d3 --- /dev/null +++ b/js/src/tests/js1_7/regress/regress-464403.js @@ -0,0 +1,32 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 464403; +var summary = 'Do not assert: tm->recorder != NULL'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + + print(8); + var u = [print, print, function(){}]; + for each (x in u) for (u.e in [1,1,1,1]); + + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/regress/regress-465236.js b/js/src/tests/js1_7/regress/regress-465236.js new file mode 100644 index 000000000..f446c27a9 --- /dev/null +++ b/js/src/tests/js1_7/regress/regress-465236.js @@ -0,0 +1,28 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 465236; +var summary = 'TM: Do not assert: we should have converted to numbers already'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + for (let j = 0; j < 2; ++j) null <= null; + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/regress/regress-465424.js b/js/src/tests/js1_7/regress/regress-465424.js new file mode 100644 index 000000000..dd11d1303 --- /dev/null +++ b/js/src/tests/js1_7/regress/regress-465424.js @@ -0,0 +1,30 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 465424; +var summary = 'TM: issue with post-decrement operator'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + expect = '0,1,2,3,4,'; + + for (let j=0;j<5;++j) { jj=j; print(actual += '' + (jj--) + ',') } + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/regress/regress-465484.js b/js/src/tests/js1_7/regress/regress-465484.js new file mode 100644 index 000000000..3f430e137 --- /dev/null +++ b/js/src/tests/js1_7/regress/regress-465484.js @@ -0,0 +1,28 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 465484; +var summary = 'TM: Do not assert: _allocator.active[FST0] && _fpuStkDepth == -1 || ' + + '!_allocator.active[FST0] && _fpuStkDepth == 0'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + for each (let a in [2, 2, 2]) { a %= a; a %= a; } + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/regress/regress-465686.js b/js/src/tests/js1_7/regress/regress-465686.js new file mode 100644 index 000000000..8e92a2914 --- /dev/null +++ b/js/src/tests/js1_7/regress/regress-465686.js @@ -0,0 +1,35 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 465686; +var summary = 'Do not crash @ tiny_free_list_add_ptr'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + for each (let b in [eval, eval, 4, 4]) { + ++b; + for each (b in [(void 0), (void 0), (void 0), 3, (void 0), 3]) { + b ^= b; + for each (var c in [1/0]) { + } + } + } + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/regress/regress-469239-01.js b/js/src/tests/js1_7/regress/regress-469239-01.js new file mode 100644 index 000000000..7fa5a7e61 --- /dev/null +++ b/js/src/tests/js1_7/regress/regress-469239-01.js @@ -0,0 +1,36 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 469239; +var summary = 'TM: Do not assert: entry->kpc == (jsbytecode*) atoms[index]'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + + for (let b=0;b<9;++b) { + for each (let h in ['', 3, /x/]) { + for each (c in [[], [], [], /x/]) { + '' + c; + } + } + } + + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/regress/regress-469239-02.js b/js/src/tests/js1_7/regress/regress-469239-02.js new file mode 100644 index 000000000..4396f83f0 --- /dev/null +++ b/js/src/tests/js1_7/regress/regress-469239-02.js @@ -0,0 +1,36 @@ +/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 469239; +var summary = 'TM: Do not assert: ATOM_IS_STRING(atom)'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + + for (let b=0;b<9;++b) { + for each (let h in [33, 3, /x/]) { + for each (c in [[], [], [], /x/]) { + '' + c; + } + } + } + + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/regress/regress-470223.js b/js/src/tests/js1_7/regress/regress-470223.js new file mode 100644 index 000000000..725e22983 --- /dev/null +++ b/js/src/tests/js1_7/regress/regress-470223.js @@ -0,0 +1,38 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 470223; +var summary = 'TM: Do not crash @ js_NewObjectWithGivenProto'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + + function F(A) { + for (R = [], s = 0; (m = A.indexOf("m", s++)) >= 0; ) + R.push([m]); + for (i = R.length; i--; ) { + let r = R[i]; + if (r[0]); + } + } + F("m"); F("mm"); + + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/regress/regress-470388-01.js b/js/src/tests/js1_7/regress/regress-470388-01.js new file mode 100644 index 000000000..ac18f9b07 --- /dev/null +++ b/js/src/tests/js1_7/regress/regress-470388-01.js @@ -0,0 +1,28 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 470388; +var summary = 'TM: Do not assert: !(fp->flags & JSFRAME_POP_BLOCKS)'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + for each (let x in [function(){}, new Boolean(false), function(){}]) {} + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/regress/regress-474771.js b/js/src/tests/js1_7/regress/regress-474771.js new file mode 100644 index 000000000..ae20d2c5d --- /dev/null +++ b/js/src/tests/js1_7/regress/regress-474771.js @@ -0,0 +1,45 @@ +// |reftest| skip-if(Android) +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 474771; +var summary = 'TM: do not halt execution with gczeal, prototype mangling, for..in'; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + expect = 'PASS'; + + if (typeof gczeal == 'function') + { + gczeal(2); + } + + Object.prototype.q = 3; + for each (let x in [6, 7]) { } print(actual = "PASS"); + + + delete Object.prototype.q; + + if (typeof gczeal == 'function') + { + gczeal(0); + } + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} diff --git a/js/src/tests/js1_7/regress/shell.js b/js/src/tests/js1_7/regress/shell.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/src/tests/js1_7/regress/shell.js diff --git a/js/src/tests/js1_7/shell.js b/js/src/tests/js1_7/shell.js new file mode 100644 index 000000000..cc80c5747 --- /dev/null +++ b/js/src/tests/js1_7/shell.js @@ -0,0 +1,12 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 4 -*- + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +// NOTE: This only turns on 1.7 in shell builds. The browser requires the +// futzing in js/src/tests/browser.js. +if (typeof version != 'undefined') +{ + version(170); +} + diff --git a/js/src/tests/js1_7/template.js b/js/src/tests/js1_7/template.js new file mode 100644 index 000000000..089aae2d6 --- /dev/null +++ b/js/src/tests/js1_7/template.js @@ -0,0 +1,28 @@ +/* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ + * Contributor: + */ + +//----------------------------------------------------------------------------- +var BUGNUMBER = 99999; +var summary = ''; +var actual = ''; +var expect = ''; + + +//----------------------------------------------------------------------------- +test(); +//----------------------------------------------------------------------------- + +function test() +{ + enterFunc ('test'); + printBugNumber(BUGNUMBER); + printStatus (summary); + + reportCompare(expect, actual, summary); + + exitFunc ('test'); +} |