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/jit-test/tests/basic/functionnames.js | |
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/jit-test/tests/basic/functionnames.js')
-rw-r--r-- | js/src/jit-test/tests/basic/functionnames.js | 158 |
1 files changed, 158 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/basic/functionnames.js b/js/src/jit-test/tests/basic/functionnames.js new file mode 100644 index 000000000..935292ee3 --- /dev/null +++ b/js/src/jit-test/tests/basic/functionnames.js @@ -0,0 +1,158 @@ +/* + * Most of these test cases are adapted from: + * http://johnjbarton.github.com/nonymous/index.html + */ + +function assertName(fn, name) { + assertEq(displayName(fn), name) +} + +/* simple names */ +var a = function b() {}; +function c() {}; +assertName(a, 'b'); +assertName(c, 'c'); + +var a = function(){}, + b = function(){}; +assertName(a, 'a'); +assertName(b, 'b'); + +/* nested names */ +var main = function() { + function Foo(a) { assertName(a, 'main/foo<') } + var foo = new Foo(function() {}); +}; +assertName(main, 'main') +main(); + +/* duplicated */ +var Baz = Bar = function(){} +assertName(Baz, 'Bar'); +assertName(Bar, 'Bar'); + +/* returned from an immediate function */ +var Foo = function (){ + assertName(arguments.callee, 'Foo<') + return function(){}; +}(); +assertName(Foo, 'Foo</<'); + +/* various properties and such */ +var x = {fox: { bax: function(){} } }; +assertName(x.fox.bax, 'x.fox.bax'); +var foo = {foo: {foo: {}}}; +foo.foo.foo = function(){}; +assertName(foo.foo.foo, 'foo.foo.foo'); +var z = { + foz: function() { + var baz = function() { + var y = {bay: function() {}}; + assertName(y.bay, 'z.foz/baz/y.bay'); + }; + assertName(baz, 'z.foz/baz'); + baz(); + } +}; +assertName(z.foz, 'z.foz'); +z.foz(); + +var outer = function() { + x.fox.bax.nx = function(){}; + var w = {fow: { baw: function(){} } }; + assertName(x.fox.bax.nx, 'outer/x.fox.bax.nx') + assertName(w.fow.baw, 'outer/w.fow.baw'); +}; +assertName(outer, 'outer'); +outer(); +function Fuz(){}; +Fuz.prototype = { + add: function() {} +} +assertName(Fuz.prototype.add, 'Fuz.prototype.add'); + +var x = 1; +x = function(){}; +assertName(x, 'x'); + +var a = {b: {}}; +a.b.c = (function() { + assertName(arguments.callee, 'a.b.c<') +}()); + +a.b = function() { + function foo(f) { assertName(f, 'a.b/<'); }; + return foo(function(){}); +} +a.b(); + +var bar = 'bar'; +a.b[bar] = function(){}; +assertName(a.b.bar, 'a.b[bar]'); + +a.b = function() { + assertName(arguments.callee, 'a.b<'); + return { a: function() {} } +}(); +assertName(a.b.a, 'a.b</<.a'); + +a = { + b: function(a) { + if (a) + return function() {}; + else + return function() {}; + } +}; +assertName(a.b, 'a.b'); +assertName(a.b(true), 'a.b/<') +assertName(a.b(false), 'a.b/<') + +function f(g) { + assertName(g, 'x<'); + return g(); +} +var x = f(function () { return function() {}; }); +assertName(x, 'x</<'); + +var a = {'b': function(){}}; +assertName(a.b, 'a.b'); + +function g(f) { + assertName(f, ''); +} +label: g(function () {}); + +var z = [function() {}]; +assertName(z[0], 'z<'); + +/* fuzz bug from 785089 */ +odeURIL:(function(){}) + +a = { 1: function () {} }; +assertName(a[1], 'a[1]'); + +a = { + "embedded spaces": function(){}, + "dots.look.like.property.references": function(){}, + "\"\'quotes\'\"": function(){}, + "!@#$%": function(){} +}; +assertName(a["embedded spaces"], 'a["embedded spaces"]'); +assertName(a["dots.look.like.property.references"], 'a["dots.look.like.property.references"]'); +assertName(a["\"\'quotes\'\""], 'a["\\\"\'quotes\'\\\""]'); +assertName(a["!@#$%"], 'a["!@#$%"]'); + +a.b = {}; +a.b.c = {}; +a.b["c"]["d e"] = { f: { 1: { "g": { "h i": function() {} } } } }; +assertName(a.b.c["d e"].f[1].g["h i"], 'a.b.c["d e"].f[1].g["h i"]'); + +this.m = function () {}; +assertName(m, "this.m"); + +function N() { + this.o = function () {} +} +let n = new N() +assertName(n.o, "N/this.o"); |