michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: //----------------------------------------------------------------------------- michael@0: var BUGNUMBER = 164697; michael@0: var summary = '(parent(instance) == parent(constructor))'; michael@0: var actual = ''; michael@0: var expect = ''; michael@0: michael@0: printBugNumber(BUGNUMBER); michael@0: printStatus (summary); michael@0: michael@0: expect = 'true'; michael@0: michael@0: runtest('{}', 'Object'); michael@0: runtest('new Object()', 'Object'); michael@0: michael@0: // see https://bugzilla.mozilla.org/show_bug.cgi?id=321669 michael@0: // for why this test is not contained in a function. michael@0: actual = (function (){}).__proto__ == Function.prototype; michael@0: reportCompare('true', actual+'', michael@0: '(function (){}).__proto__ == Function.prototype'); michael@0: michael@0: runtest('new Function(";")', 'Function'); michael@0: michael@0: runtest('[]', 'Array'); michael@0: runtest('new Array()', 'Array'); michael@0: michael@0: runtest('new String()', 'String'); michael@0: michael@0: runtest('new Boolean()', 'Boolean'); michael@0: michael@0: runtest('new Number("1")', 'Number'); michael@0: michael@0: runtest('new Date()', 'Date'); michael@0: michael@0: runtest('/x/', 'RegExp'); michael@0: runtest('new RegExp("x")', 'RegExp'); michael@0: michael@0: runtest('new Error()', 'Error'); michael@0: michael@0: function runtest(myinstance, myconstructor) michael@0: { michael@0: var expr; michael@0: var actual; michael@0: michael@0: if (typeof parent === "function") michael@0: { michael@0: try michael@0: { michael@0: expr = michael@0: 'parent(' + myinstance + ') == ' + michael@0: 'parent(' + myconstructor + ')'; michael@0: printStatus(expr); michael@0: actual = eval(expr).toString(); michael@0: } michael@0: catch(ex) michael@0: { michael@0: actual = ex + ''; michael@0: } michael@0: michael@0: reportCompare(expect, actual, expr); michael@0: } michael@0: michael@0: try michael@0: { michael@0: expr = '(' + myinstance + ').__proto__ == ' + michael@0: myconstructor + '.prototype'; michael@0: printStatus(expr); michael@0: actual = eval(expr).toString(); michael@0: } michael@0: catch(ex) michael@0: { michael@0: actual = ex + ''; michael@0: } michael@0: michael@0: reportCompare(expect, actual, expr); michael@0: }