Update the test to ensure OutOfMemoryError is thrown as intended
[WebKit-https.git] / JSTests / stress / create-error-out-of-memory-rope-string.js
index c34191c..33fff7c 100644 (file)
@@ -1,3 +1,13 @@
-var foo = 'yy?x\uFFFD$w    5?\uFFFDo\uFFFD?\uFFFD\'i?\uFFFDE-N\uFFFD\uFFFD6_\uFFFD\\ d';
-foo = foo.padEnd(2147483644, 1);
-eval('foo()');
+function assert(a, message) {
+    if (!a)
+        throw new Error(message);
+}
+
+try {
+    var foo = 'yy?x\uFFFD$w    5?\uFFFDo\uFFFD?\uFFFD\'i?\uFFFDE-N\uFFFD\uFFFD6_\uFFFD\\ d';
+    foo = foo.padEnd(2147483644, 1);
+    eval('foo()');
+    assert(false, `Should throw OOM error`);
+} catch (error) {
+    assert(error.message == "Out of memory", "Expected OutOfMemoryError, but got: " + error);
+}