1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/ecma_3/Function/regress-193555.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,102 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.8 + 1.9 +/* 1.10 + * 1.11 + * Date: 17 February 2003 1.12 + * SUMMARY: Testing access to function name from inside function 1.13 + * 1.14 + * See http://bugzilla.mozilla.org/show_bug.cgi?id=193555 1.15 + * 1.16 + */ 1.17 +//----------------------------------------------------------------------------- 1.18 +var UBound = 0; 1.19 +var BUGNUMBER = 193555; 1.20 +var summary = 'Testing access to function name from inside function'; 1.21 +var status = ''; 1.22 +var statusitems = []; 1.23 +var actual = ''; 1.24 +var actualvalues = []; 1.25 +var expect= ''; 1.26 +var expectedvalues = []; 1.27 + 1.28 + 1.29 +// test via function statement 1.30 +status = inSection(1); 1.31 +function f() {return f.toString();}; 1.32 +actual = f(); 1.33 +expect = f.toString(); 1.34 +addThis(); 1.35 + 1.36 +// test via function expression 1.37 +status = inSection(2); 1.38 +var x = function g() {return g.toString();}; 1.39 +actual = x(); 1.40 +expect = x.toString(); 1.41 +addThis(); 1.42 + 1.43 +// test via eval() outside function 1.44 +status = inSection(3); 1.45 +eval ('function a() {return a.toString();}'); 1.46 +actual = a(); 1.47 +expect = a.toString(); 1.48 +addThis(); 1.49 + 1.50 +status = inSection(4); 1.51 +eval ('var y = function b() {return b.toString();}'); 1.52 +actual = y(); 1.53 +expect = y.toString(); 1.54 +addThis(); 1.55 + 1.56 +// test via eval() inside function 1.57 +status = inSection(5); 1.58 +function c() {return eval('c').toString();}; 1.59 +actual = c(); 1.60 +expect = c.toString(); 1.61 +addThis(); 1.62 + 1.63 +status = inSection(6); 1.64 +var z = function d() {return eval('d').toString();}; 1.65 +actual = z(); 1.66 +expect = z.toString(); 1.67 +addThis(); 1.68 + 1.69 +// test via two evals! 1.70 +status = inSection(7); 1.71 +eval('var w = function e() {return eval("e").toString();}'); 1.72 +actual = w(); 1.73 +expect = w.toString(); 1.74 +addThis(); 1.75 + 1.76 + 1.77 + 1.78 +//----------------------------------------------------------------------------- 1.79 +test(); 1.80 +//----------------------------------------------------------------------------- 1.81 + 1.82 + 1.83 + 1.84 +function addThis() 1.85 +{ 1.86 + statusitems[UBound] = status; 1.87 + actualvalues[UBound] = actual; 1.88 + expectedvalues[UBound] = expect; 1.89 + UBound++; 1.90 +} 1.91 + 1.92 + 1.93 +function test() 1.94 +{ 1.95 + enterFunc('test'); 1.96 + printBugNumber(BUGNUMBER); 1.97 + printStatus(summary); 1.98 + 1.99 + for (var i=0; i<UBound; i++) 1.100 + { 1.101 + reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); 1.102 + } 1.103 + 1.104 + exitFunc ('test'); 1.105 +}