The Android Open Source Project | 9364f22 | 2008-10-21 07:00:00 -0700 | [diff] [blame] | 1 | /* |
| 2 | * The contents of this file are subject to the Netscape Public |
| 3 | * License Version 1.1 (the "License"); you may not use this file |
| 4 | * except in compliance with the License. You may obtain a copy of |
| 5 | * the License at http://www.mozilla.org/NPL/ |
| 6 | * |
| 7 | * Software distributed under the License is distributed on an "AS |
| 8 | * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or |
| 9 | * implied. See the License for the specific language governing |
| 10 | * rights and limitations under the License. |
| 11 | * |
| 12 | * The Original Code is mozilla.org code. |
| 13 | * |
| 14 | * The Initial Developer of the Original Code is Netscape |
| 15 | * Communications Corporation. Portions created by Netscape are |
| 16 | * Copyright (C) 1998 Netscape Communications Corporation. |
| 17 | * All Rights Reserved. |
| 18 | * |
| 19 | * Contributor(s): wtam@bigfoot.com, pschwartau@netscape.com |
| 20 | * Date: 30 October 2001 |
| 21 | * |
| 22 | * SUMMARY: Regression test for bug 94257 |
| 23 | * See http://bugzilla.mozilla.org/show_bug.cgi?id=94257 |
| 24 | * |
| 25 | * Rhino used to crash on this code; specifically, on the line |
| 26 | * |
| 27 | * arr[1+1] += 2; |
| 28 | */ |
| 29 | //----------------------------------------------------------------------------- |
| 30 | var UBound = 0; |
| 31 | var bug = 94257; |
| 32 | var summary = "Making sure we don't crash on this code -"; |
| 33 | var status = ''; |
| 34 | var statusitems = []; |
| 35 | var actual = ''; |
| 36 | var actualvalues = []; |
| 37 | var expect= ''; |
| 38 | var expectedvalues = []; |
| 39 | |
| 40 | |
| 41 | var arr = new Array(6); |
| 42 | arr[1+1] = 1; |
| 43 | arr[1+1] += 2; |
| 44 | |
| 45 | |
| 46 | status = inSection(1); |
| 47 | actual = arr[1+1]; |
| 48 | expect = 3; |
| 49 | addThis(); |
| 50 | |
| 51 | status = inSection(2); |
| 52 | actual = arr[1+1+1]; |
| 53 | expect = undefined; |
| 54 | addThis(); |
| 55 | |
| 56 | status = inSection(3); |
| 57 | actual = arr[1]; |
| 58 | expect = undefined; |
| 59 | addThis(); |
| 60 | |
| 61 | |
| 62 | arr[1+2] = 'Hello'; |
| 63 | |
| 64 | |
| 65 | status = inSection(4); |
| 66 | actual = arr[1+1+1]; |
| 67 | expect = 'Hello'; |
| 68 | addThis(); |
| 69 | |
| 70 | |
| 71 | |
| 72 | //----------------------------------------------------------------------------- |
| 73 | test(); |
| 74 | //----------------------------------------------------------------------------- |
| 75 | |
| 76 | |
| 77 | |
| 78 | function addThis() |
| 79 | { |
| 80 | statusitems[UBound] = status; |
| 81 | actualvalues[UBound] = actual; |
| 82 | expectedvalues[UBound] = expect; |
| 83 | UBound++; |
| 84 | } |
| 85 | |
| 86 | |
| 87 | function test() |
| 88 | { |
| 89 | enterFunc ('test'); |
| 90 | printBugNumber (bug); |
| 91 | printStatus (summary); |
| 92 | |
| 93 | for (var i=0; i<UBound; i++) |
| 94 | { |
| 95 | reportCompare(expectedvalues[i], actualvalues[i], statusitems[i]); |
| 96 | } |
| 97 | |
| 98 | exitFunc ('test'); |
| 99 | } |