/* -*- tab-width: 2; indent-tabs-mode: nil; js-indent-level: 2 -*- */ /* This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* * * Date: 10 October 2001 * SUMMARY: Regression test for Bugzilla bug 104077 * See http://bugzilla.mozilla.org/show_bug.cgi?id=104077 * "JS crash: with/finally/return" * * Also http://bugzilla.mozilla.org/show_bug.cgi?id=120571 * "JS crash: try/catch/continue." * * SpiderMonkey crashed on this code - it shouldn't. * * NOTE: the finally-blocks below should execute even if their try-blocks * have return or throw statements in them: * * ------- Additional Comment #76 From Mike Shaver 2001-12-07 01:21 ------- * finally trumps return, and all other control-flow constructs that cause * program execution to jump out of the try block: throw, break, etc. Once you * enter a try block, you will execute the finally block after leaving the try, * regardless of what happens to make you leave the try. *
*/ //----------------------------------------------------------------------------- var UBound = 0; var BUGNUMBER = 104077; var summary = "Just testing that we don't crash on with/finally/return -"; var status = ''; var statusitems = []; var actual = ''; var actualvalues = []; var expect= ''; var expectedvalues = [];
function addValues(obj)
{ var sum;
with (obj)
{ try
{
sum = arg1 + arg2;
} finally
{ return sum;
}
}
}
status = inSection(1); var obj = new Object();
obj.arg1 = 1;
obj.arg2 = 2;
actual = addValues(obj);
expect = 3;
captureThis();
function tryThis()
{ var sum = 4 ; var i = 0;
while (sum < 10)
{ try
{
sum += 1;
i += 1;
} finally
{
print("In finally case of tryThis() function");
}
} return i;
}
status = inSection(2);
actual = tryThis();
expect = 6;
captureThis();
function myTest(x)
{ var obj = new Object(); var msg;
with (obj)
{
msg = (x != null) ? "NO" : "YES";
print("Is the provided argument to myTest() null? : " + msg);
// this caused a crash! Test to see that it doesn't now.
print(a120571);
// Now test that we have a non-null value for a120571.toString()
status = inSection(13); try
{
actual = a120571.toString().match(/continue/)[0];
} catch(e)
{
actual = 'FAILED! Did not find "continue" in function body';
}
expect = 'continue';
captureThis();
// this caused a crash!!! Test to see that it doesn't now.
print(b);
// Now test that we have a non-null value for b.toString()
status = inSection(14); try
{
actual = b.toString().match(/continue/)[0];
} catch(e)
{
actual = 'FAILED! Did not find "continue" in function body';
}
expect = 'continue';
captureThis();
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.