| Index: test/webkit/fast/js/kde/lval-exceptions.js
|
| diff --git a/test/webkit/vardecl-blocks-init.js b/test/webkit/fast/js/kde/lval-exceptions.js
|
| similarity index 50%
|
| copy from test/webkit/vardecl-blocks-init.js
|
| copy to test/webkit/fast/js/kde/lval-exceptions.js
|
| index b77f191b7fe3ce23199e99b3d9f6fe0da4c28de6..32641f8d4da5b6b94dedee794918c1143c678f08 100644
|
| --- a/test/webkit/vardecl-blocks-init.js
|
| +++ b/test/webkit/fast/js/kde/lval-exceptions.js
|
| @@ -21,57 +21,54 @@
|
| // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
| // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
| -description(
|
| -"This test checks that variable declarations with initializers inside of catch and with blocks do not set values in a deeper scope."
|
| -);
|
| +description("KDE JS Test");
|
| +// Tests for raising --- and non-raising exceptions on access to reference to undefined things...
|
|
|
| -function catchTest() {
|
| - var e = "foo";
|
| +// Locals should throw on access if undefined..
|
| +fnShouldThrow(function() { a = x; }, ReferenceError);
|
|
|
| - try {
|
| - throw "bar";
|
| - } catch (e) {
|
| - var e = "baz";
|
| - }
|
| +// Read-modify-write versions of assignment should throw as well
|
| +fnShouldThrow(function() { x += "foo"; }, ReferenceError);
|
|
|
| - return e;
|
| -}
|
| +// Other reference types should just return undefined...
|
| +a = new Object();
|
| +fnShouldNotThrow(function() { b = a.x; });
|
| +fnShouldNotThrow(function() { b = a['x']; });
|
| +fnShouldNotThrow(function() { a['x'] += 'baz'; });
|
| +shouldBe("a['x']", '"undefinedbaz"');
|
| +fnShouldNotThrow(function() { b = a.y; });
|
| +fnShouldNotThrow(function() { a.y += 'glarch'; });
|
| +shouldBe("a['y']", '"undefinedglarch"');
|
|
|
| -function catchTest2() {
|
| - var e = "foo";
|
|
|
| +// Helpers!
|
| +function fnShouldThrow(f, exType)
|
| +{
|
| + var exception;
|
| + var _av;
|
| try {
|
| - throw "bar";
|
| + _av = f();
|
| } catch (e) {
|
| - var e = "baz";
|
| -
|
| - return e;
|
| + exception = e;
|
| }
|
| -}
|
|
|
| -function withTest() {
|
| - var e = "foo"
|
| - var object = { 'e' : "bar" };
|
| -
|
| - with (object) {
|
| - var e = "baz";
|
| - }
|
| -
|
| - return e;
|
| + if (exception) {
|
| + if (typeof exType == "undefined" || exception instanceof exType)
|
| + testPassed(f + " threw exception " + exception + ".");
|
| + else
|
| + testFailed(f + " should throw exception " + exType + ". Threw exception " + exception + ".");
|
| + } else if (typeof _av == "undefined")
|
| + testFailed(f + " should throw exception " + exType + ". Was undefined.");
|
| + else
|
| + testFailed(f + " should throw exception " + exType + ". Was " + _av + ".");
|
| }
|
|
|
| -function withTest2() {
|
| - var e = "foo"
|
| - var object = { 'e' : "bar" };
|
| -
|
| - with (object) {
|
| - var e = "baz";
|
| -
|
| - return e;
|
| +function fnShouldNotThrow(f)
|
| +{
|
| + try {
|
| + f();
|
| + testPassed(f + " did not throw an exception");
|
| + } catch (e) {
|
| + testFailed(f + " threw an exception " + e + " when no exception expected");
|
| }
|
| -}
|
| -
|
| -shouldBe("catchTest()", "'foo'");
|
| -shouldBe("catchTest2()", "'baz'");
|
| -shouldBe("withTest()", "'foo'");
|
| -shouldBe("withTest2()", "'baz'");
|
| +}
|
|
|