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 = 465377; michael@0: var summary = 'instanceof relations between Error objects'; michael@0: var actual = ''; michael@0: var expect = ''; michael@0: michael@0: michael@0: //----------------------------------------------------------------------------- michael@0: test(); michael@0: //----------------------------------------------------------------------------- michael@0: michael@0: function test() michael@0: { michael@0: enterFunc ('test'); michael@0: printBugNumber(BUGNUMBER); michael@0: printStatus (summary); michael@0: michael@0: expect = actual = 'No Exception'; michael@0: michael@0: try michael@0: { michael@0: var list = [ michael@0: "Error", michael@0: "InternalError", michael@0: "EvalError", michael@0: "RangeError", michael@0: "ReferenceError", michael@0: "SyntaxError", michael@0: "TypeError", michael@0: "URIError" michael@0: ]; michael@0: var instances = []; michael@0: michael@0: for (var i = 0; i != list.length; ++i) { michael@0: var name = list[i]; michael@0: var constructor = this[name]; michael@0: var tmp = constructor.name; michael@0: if (tmp !== name) michael@0: throw "Bad value for "+name+".name: "+uneval(tmp); michael@0: instances[i] = new constructor(); michael@0: } michael@0: michael@0: for (var i = 0; i != instances.length; ++i) { michael@0: var instance = instances[i]; michael@0: var name = instance.name; michael@0: var constructor = instance.constructor; michael@0: if (constructor !== this[name]) michael@0: throw "Bad value of (new "+name+").constructor: "+uneval(tmp); michael@0: var tmp = constructor.name; michael@0: if (tmp !== name) michael@0: throw "Bad value for constructor.name: "+uneval(tmp); michael@0: if (!(instance instanceof Object)) michael@0: throw "Bad instanceof Object for "+name; michael@0: if (!(instance instanceof Error)) michael@0: throw "Bad instanceof Error for "+name; michael@0: if (!(instance instanceof constructor)) michael@0: throw "Bad instanceof constructor for "+name; michael@0: if (instance instanceof Function) michael@0: throw "Bad instanceof Function for "+name; michael@0: for (var j = 1; j != instances.length; ++j) { michael@0: if (i != j && instance instanceof instances[j].constructor) { michael@0: throw "Unexpected (new "+name+") instanceof "+ instances[j].name; michael@0: } michael@0: } michael@0: } michael@0: michael@0: print("OK"); michael@0: } michael@0: catch(ex) michael@0: { michael@0: actual = ex + ''; michael@0: } michael@0: reportCompare(expect, actual, summary); michael@0: michael@0: exitFunc ('test'); michael@0: }