michael@0: // |reftest| skip -- obsolete test michael@0: /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- 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: /* michael@0: * SUMMARY: New properties fileName, lineNumber have been added to Error objects michael@0: * in SpiderMonkey. These are non-ECMA extensions and do not exist in Rhino. michael@0: * michael@0: * See http://bugzilla.mozilla.org/show_bug.cgi?id=50447 michael@0: */ michael@0: michael@0: //----------------------------------------------------------------------------- michael@0: var BUGNUMBER = 50447; michael@0: var summary = 'Test (non-ECMA) Error object properties fileName, lineNumber'; michael@0: michael@0: michael@0: //----------------------------------------------------------------------------- michael@0: test(); michael@0: //----------------------------------------------------------------------------- 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: testRealError(); michael@0: test1(); michael@0: test2(); michael@0: test3(); michael@0: test4(); michael@0: michael@0: exitFunc('test'); michael@0: } michael@0: michael@0: michael@0: function testRealError() michael@0: { michael@0: /* throw a real error, and see what it looks like */ michael@0: enterFunc ("testRealError"); michael@0: michael@0: try michael@0: { michael@0: blabla; michael@0: } michael@0: catch (e) michael@0: { michael@0: if (e.fileName.search (/-50447\.js$/i) == -1) michael@0: reportCompare('PASS', 'FAIL', michael@0: "expected fileName to end with '-50447.js'"); michael@0: michael@0: reportCompare (83, e.lineNumber, michael@0: "lineNumber property returned unexpected value."); michael@0: } michael@0: michael@0: exitFunc ("testRealError"); michael@0: } michael@0: michael@0: michael@0: function test1() michael@0: { michael@0: /* generate an error with msg, file, and lineno properties */ michael@0: enterFunc ("test1"); michael@0: michael@0: var e = new InternalError ("msg", "file", 2); michael@0: reportCompare ("(new InternalError(\"msg\", \"file\", 2))", michael@0: e.toSource(), michael@0: "toSource() returned unexpected result."); michael@0: reportCompare ("file", e.fileName, michael@0: "fileName property returned unexpected value."); michael@0: reportCompare (2, e.lineNumber, michael@0: "lineNumber property returned unexpected value."); michael@0: michael@0: exitFunc ("test1"); michael@0: } michael@0: michael@0: michael@0: function test2() michael@0: { michael@0: /* generate an error with only msg property */ michael@0: enterFunc ("test2"); michael@0: michael@0: var e = new InternalError ("msg"); michael@0: reportCompare ("(new InternalError(\"msg\", \"\"))", michael@0: e.toSource(), michael@0: "toSource() returned unexpected result."); michael@0: reportCompare ("", e.fileName, michael@0: "fileName property returned unexpected value."); michael@0: reportCompare (0, e.lineNumber, michael@0: "lineNumber property returned unexpected value."); michael@0: michael@0: exitFunc ("test2"); michael@0: } michael@0: michael@0: michael@0: function test3() michael@0: { michael@0: /* generate an error with only msg and lineNo properties */ michael@0: enterFunc ("test3"); michael@0: michael@0: var e = new InternalError ("msg"); michael@0: e.lineNumber = 10; michael@0: reportCompare ("(new InternalError(\"msg\", \"\", 10))", michael@0: e.toSource(), michael@0: "toSource() returned unexpected result."); michael@0: reportCompare ("", e.fileName, michael@0: "fileName property returned unexpected value."); michael@0: reportCompare (10, e.lineNumber, michael@0: "lineNumber property returned unexpected value."); michael@0: michael@0: exitFunc ("test3"); michael@0: } michael@0: michael@0: michael@0: function test4() michael@0: { michael@0: /* generate an error with only msg and filename properties */ michael@0: enterFunc ("test4"); michael@0: michael@0: var e = new InternalError ("msg", "file"); michael@0: reportCompare ("(new InternalError(\"msg\", \"file\"))", michael@0: e.toSource(), michael@0: "toSource() returned unexpected result."); michael@0: reportCompare ("file", e.fileName, michael@0: "fileName property returned unexpected value."); michael@0: reportCompare (0, e.lineNumber, michael@0: "lineNumber property returned unexpected value."); michael@0: michael@0: exitFunc ("test4"); michael@0: }