From 2aa4a82499d4becd2284cdb482213d541b8804dd Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 28 Apr 2024 16:29:10 +0200 Subject: Adding upstream version 86.0.1. Signed-off-by: Daniel Baumann --- js/src/jit-test/tests/basic/functionnames.js | 160 +++++++++++++++++++++++++++ 1 file changed, 160 insertions(+) create mode 100644 js/src/jit-test/tests/basic/functionnames.js (limited to 'js/src/jit-test/tests/basic/functionnames.js') 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 0000000000..8b046db8b9 --- /dev/null +++ b/js/src/jit-test/tests/basic/functionnames.js @@ -0,0 +1,160 @@ +// |jit-test| skip-if: isLcovEnabled() + +/* + * 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