1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/js/src/tests/js1_5/extensions/regress-164697.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,80 @@ 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 +var BUGNUMBER = 164697; 1.11 +var summary = '(parent(instance) == parent(constructor))'; 1.12 +var actual = ''; 1.13 +var expect = ''; 1.14 + 1.15 +printBugNumber(BUGNUMBER); 1.16 +printStatus (summary); 1.17 + 1.18 +expect = 'true'; 1.19 + 1.20 +runtest('{}', 'Object'); 1.21 +runtest('new Object()', 'Object'); 1.22 + 1.23 +// see https://bugzilla.mozilla.org/show_bug.cgi?id=321669 1.24 +// for why this test is not contained in a function. 1.25 +actual = (function (){}).__proto__ == Function.prototype; 1.26 +reportCompare('true', actual+'', 1.27 + '(function (){}).__proto__ == Function.prototype'); 1.28 + 1.29 +runtest('new Function(";")', 'Function'); 1.30 + 1.31 +runtest('[]', 'Array'); 1.32 +runtest('new Array()', 'Array'); 1.33 + 1.34 +runtest('new String()', 'String'); 1.35 + 1.36 +runtest('new Boolean()', 'Boolean'); 1.37 + 1.38 +runtest('new Number("1")', 'Number'); 1.39 + 1.40 +runtest('new Date()', 'Date'); 1.41 + 1.42 +runtest('/x/', 'RegExp'); 1.43 +runtest('new RegExp("x")', 'RegExp'); 1.44 + 1.45 +runtest('new Error()', 'Error'); 1.46 + 1.47 +function runtest(myinstance, myconstructor) 1.48 +{ 1.49 + var expr; 1.50 + var actual; 1.51 + 1.52 + if (typeof parent === "function") 1.53 + { 1.54 + try 1.55 + { 1.56 + expr = 1.57 + 'parent(' + myinstance + ') == ' + 1.58 + 'parent(' + myconstructor + ')'; 1.59 + printStatus(expr); 1.60 + actual = eval(expr).toString(); 1.61 + } 1.62 + catch(ex) 1.63 + { 1.64 + actual = ex + ''; 1.65 + } 1.66 + 1.67 + reportCompare(expect, actual, expr); 1.68 + } 1.69 + 1.70 + try 1.71 + { 1.72 + expr = '(' + myinstance + ').__proto__ == ' + 1.73 + myconstructor + '.prototype'; 1.74 + printStatus(expr); 1.75 + actual = eval(expr).toString(); 1.76 + } 1.77 + catch(ex) 1.78 + { 1.79 + actual = ex + ''; 1.80 + } 1.81 + 1.82 + reportCompare(expect, actual, expr); 1.83 +}