diff options
Diffstat (limited to 'js/src/tests/ecma_3/FunExpr')
-rw-r--r-- | js/src/tests/ecma_3/FunExpr/browser.js | 0 | ||||
-rw-r--r-- | js/src/tests/ecma_3/FunExpr/fe-001-n.js | 22 | ||||
-rw-r--r-- | js/src/tests/ecma_3/FunExpr/fe-001.js | 21 | ||||
-rw-r--r-- | js/src/tests/ecma_3/FunExpr/fe-002.js | 25 | ||||
-rw-r--r-- | js/src/tests/ecma_3/FunExpr/regress-518103.js | 27 | ||||
-rw-r--r-- | js/src/tests/ecma_3/FunExpr/regress-524826.js | 28 | ||||
-rw-r--r-- | js/src/tests/ecma_3/FunExpr/regress-528082.js | 20 | ||||
-rw-r--r-- | js/src/tests/ecma_3/FunExpr/regress-533254.js | 28 | ||||
-rw-r--r-- | js/src/tests/ecma_3/FunExpr/regress-545980.js | 41 | ||||
-rw-r--r-- | js/src/tests/ecma_3/FunExpr/shell.js | 0 |
10 files changed, 212 insertions, 0 deletions
diff --git a/js/src/tests/ecma_3/FunExpr/browser.js b/js/src/tests/ecma_3/FunExpr/browser.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/src/tests/ecma_3/FunExpr/browser.js diff --git a/js/src/tests/ecma_3/FunExpr/fe-001-n.js b/js/src/tests/ecma_3/FunExpr/fe-001-n.js new file mode 100644 index 000000000..2af7bfa25 --- /dev/null +++ b/js/src/tests/ecma_3/FunExpr/fe-001-n.js @@ -0,0 +1,22 @@ +/* -*- 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/. */ + + +DESCRIPTION = "Previous statement should have thrown a ReferenceError"; +EXPECTED = "error"; + +test(); + +function test() +{ + enterFunc ("test"); + printStatus ("Function Expression test."); + + var x = function f(){return "inner";}(); + var y = f(); + reportCompare('PASS', 'FAIL', "Previous statement should have thrown a ReferenceError"); + + exitFunc ("test"); +} diff --git a/js/src/tests/ecma_3/FunExpr/fe-001.js b/js/src/tests/ecma_3/FunExpr/fe-001.js new file mode 100644 index 000000000..65c9b7375 --- /dev/null +++ b/js/src/tests/ecma_3/FunExpr/fe-001.js @@ -0,0 +1,21 @@ +/* -*- 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/. */ + + +if (1) function f() {return 1;} +if (0) function f() {return 0;} + +function test() +{ + enterFunc ("test"); + + printStatus ("Function Expression Statements basic test."); + + reportCompare (1, f(), "Both functions were defined."); + + exitFunc ("test"); +} + +test(); diff --git a/js/src/tests/ecma_3/FunExpr/fe-002.js b/js/src/tests/ecma_3/FunExpr/fe-002.js new file mode 100644 index 000000000..bb0f1a714 --- /dev/null +++ b/js/src/tests/ecma_3/FunExpr/fe-002.js @@ -0,0 +1,25 @@ +/* -*- tab-width: 8; 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/. */ + + +function f() +{ + return "outer"; +} + +function test() +{ + enterFunc ("test"); + printStatus ("Function Expression test."); + + var x = function f(){return "inner";}(); + + reportCompare ("outer", f(), + "Inner function statement should not have been called."); + + exitFunc ("test"); +} + +test(); diff --git a/js/src/tests/ecma_3/FunExpr/regress-518103.js b/js/src/tests/ecma_3/FunExpr/regress-518103.js new file mode 100644 index 000000000..70bab0d57 --- /dev/null +++ b/js/src/tests/ecma_3/FunExpr/regress-518103.js @@ -0,0 +1,27 @@ +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ + */ + +var BUGNUMBER = 518103; +var summary = 'lambda constructor "method" vs. instanceof'; +var actual; +var expect; + +printBugNumber(BUGNUMBER); +printStatus(summary); + +var Y = {widget: {}}; + +Y.widget.DataSource = function () {}; +Y.widget.DS_JSArray = function (A) { this.data = A; }; +Y.widget.DS_JSArray.prototype = new Y.widget.DataSource(); + +var J = new Y.widget.DS_JSArray( [ ] ); + +actual = J instanceof Y.widget.DataSource; +expect = true; + +reportCompare(expect, actual, summary); + +printStatus("All tests passed!"); diff --git a/js/src/tests/ecma_3/FunExpr/regress-524826.js b/js/src/tests/ecma_3/FunExpr/regress-524826.js new file mode 100644 index 000000000..da1dfbba0 --- /dev/null +++ b/js/src/tests/ecma_3/FunExpr/regress-524826.js @@ -0,0 +1,28 @@ +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ + */ + +var BUGNUMBER = 524826; +var summary = 'null-closure property initialiser mis-brands object literal scope'; +var actual; +var expect; + +printBugNumber(BUGNUMBER); +printStatus(summary); + +function make(g) { + var o = {f: function(a,b) { return a*b; }, g: g}; + return o; +} +var z = -1; +var x = make(function(c) { return c*z; }); +var y = make(function(c) { return -c*z; }); + +function callg(o, c) { return o.g(c); }; +actual = callg(x, 1); +expect = -callg(y, 1); + +reportCompare(expect, actual, summary); + +printStatus("All tests passed!"); diff --git a/js/src/tests/ecma_3/FunExpr/regress-528082.js b/js/src/tests/ecma_3/FunExpr/regress-528082.js new file mode 100644 index 000000000..1ca7b77cb --- /dev/null +++ b/js/src/tests/ecma_3/FunExpr/regress-528082.js @@ -0,0 +1,20 @@ +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ + */ + +var BUGNUMBER = 528082; +var summary = 'named function expression function-name-as-upvar slot botch'; + +printBugNumber(BUGNUMBER); +printStatus(summary); + +function f() { + return function g(a) { return function () { return g; }(); }(); +} +var actual = typeof f(); +var expect = "function"; + +reportCompare(expect, actual, summary); + +printStatus("All tests passed!"); diff --git a/js/src/tests/ecma_3/FunExpr/regress-533254.js b/js/src/tests/ecma_3/FunExpr/regress-533254.js new file mode 100644 index 000000000..b0e319818 --- /dev/null +++ b/js/src/tests/ecma_3/FunExpr/regress-533254.js @@ -0,0 +1,28 @@ +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ + */ + +var BUGNUMBER = 533254; +var summary = 'init-method late in table-big initialiser screwup'; + +printBugNumber(BUGNUMBER); +printStatus(summary); + +function f() { + var proto = {p8:8}; + var obj = { + p0:0, p1:1, p2:2, p3:3, p4:4, p5:5, p6:6, p7:7, p8:8, p9:9, + p10:0, p11:1, p12:2, p13:3, p14:4, p15:5, p16:6, p17:7, p18:8, p19:9, + m: function() { return 42; } + }; + return obj; +} +var expect = f(), + actual = f(); + +expect += ''; +actual += ''; +reportCompare(expect, actual, summary); + +printStatus("All tests passed!"); diff --git a/js/src/tests/ecma_3/FunExpr/regress-545980.js b/js/src/tests/ecma_3/FunExpr/regress-545980.js new file mode 100644 index 000000000..1ecf1c9b6 --- /dev/null +++ b/js/src/tests/ecma_3/FunExpr/regress-545980.js @@ -0,0 +1,41 @@ +/* + * Any copyright is dedicated to the Public Domain. + * http://creativecommons.org/licenses/publicdomain/ + */ + +var BUGNUMBER = 518103; +var summary = 'partial flat closures must not reach across funargs'; +var actual = "no crash"; +var expect = actual; + +function Timer(){} +Timer.prototype = { initWithCallback: function (o) {Timer.q.push(o)} }; +Timer.q = []; + +var later; +var ac = {startSearch: function(q,s,n,o){later=o}}; + +var bm = {insertBookmark: function(){}, getIdForItemAt: function(){}}; + +function run_test() { + var tagIds = []; + + (function doSearch(query) { + ac.startSearch(query, "", null, { + onSearchResult: function() { + var num = tagIds.length; + + var timer = new Timer; + var next = query.slice(1); + timer.initWithCallback({ notify: function() doSearch(next) }); + } + }); + })("title"); +} + +run_test(); +later.onSearchResult(); +for (var i in Timer.q) + Timer.q[i].notify(); + +reportCompare(expect, actual, summary); diff --git a/js/src/tests/ecma_3/FunExpr/shell.js b/js/src/tests/ecma_3/FunExpr/shell.js new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/js/src/tests/ecma_3/FunExpr/shell.js |