| 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
| 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
| 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this |
| 4 | * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
| 5 | |
| 6 | /* |
| 7 | * |
| 8 | * Date: 10 December 2001 |
| 9 | * SUMMARY: Regression test for bug 114493 |
| 10 | * See http://bugzilla.mozilla.org/show_bug.cgi?id=114493 |
| 11 | * |
| 12 | * Rhino crashed on this code. It should produce a syntax error, not a crash. |
| 13 | * Note that "3"[5] === undefined, and Rhino correctly gave an error if you |
| 14 | * tried to use the call operator on |undefined|: |
| 15 | * |
| 16 | * js> undefined(); |
| 17 | * js: TypeError: undefined is not a function. |
| 18 | * |
| 19 | * However, Rhino CRASHED if you tried to do "3"[5](). |
| 20 | * |
| 21 | * Rhino would NOT crash if you tried "3"[0]() or "3"[5]. Only array indices |
| 22 | * that were out of bounds, followed by the call operator, would crash. |
| 23 | * |
| 24 | */ |
| 25 | //----------------------------------------------------------------------------- |
| 26 | var gTestfile = 'regress-114493.js'; |
| 27 | var UBound = 0; |
| 28 | var BUGNUMBER = 114493; |
| 29 | var summary = 'Regression test for bug 114493'; |
| 30 | var status = ''; |
| 31 | var statusitems = []; |
| 32 | var actual = ''; |
| 33 | var actualvalues = []; |
| 34 | var expect= ''; |
| 35 | var expectedvalues = []; |
| 36 | var sEval = ''; |
| 37 | |
| 38 | |
| 39 | status = inSection(1); |
| 40 | actual = 'Program execution did NOT fall into catch-block'; |
| 41 | expect = 'Program execution fell into into catch-block'; |
| 42 | try |
| 43 | { |
| 44 | sEval = '"3"[5]()'; |
| 45 | eval(sEval); |
| 46 | } |
| 47 | catch(e) |
| 48 | { |
| 49 | actual = expect; |
| 50 | } |
| 51 | addThis(); |
| 52 | |
| 53 | |
| 54 | |
| 55 | //----------------------------------------------------------------------------- |
| 56 | test(); |
| 57 | //----------------------------------------------------------------------------- |
| 58 | |
| 59 | |
| 60 | function addThis() |
| 61 | { |
| 62 | statusitems[UBound] = status; |
| 63 | actualvalues[UBound] = actual; |
| 64 | expectedvalues[UBound] = expect; |
| 65 | UBound++; |
| 66 | } |
| 67 | |
| 68 | |
| 69 | function test() |
| 70 | { |
| 71 | enterFunc ('test'); |
| 72 | printBugNumber(BUGNUMBER); |
| 73 | printStatus (summary); |
| 74 | |
| 75 | for (var i = 0; i < UBound; i++) |
| 76 | { |
| 77 | reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); |
| 78 | } |
| 79 | |
| 80 | exitFunc ('test'); |
| 81 | } |