Index: test/webkit/eval-throw-return.js |
diff --git a/test/webkit/concat-while-having-a-bad-time.js b/test/webkit/eval-throw-return.js |
similarity index 52% |
copy from test/webkit/concat-while-having-a-bad-time.js |
copy to test/webkit/eval-throw-return.js |
index dfda1e08a0b36194b787a44ee12a9693acd8aeaf..a5fd9f5d78b861b61cadfe36280b8c7775f13581 100644 |
--- a/test/webkit/concat-while-having-a-bad-time.js |
+++ b/test/webkit/eval-throw-return.js |
@@ -21,11 +21,34 @@ |
// (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( |
-"Tests the behavior of Array.prototype.concat while the array is having a bad time due to one of the elements we are concatenating." |
-); |
+description('This test verifies the result returned by the eval function when exceptions are thrown and caught whithin the contents of the evaluated string.'); |
-Object.defineProperty(Array.prototype, 0, { writable: false }); |
-shouldBe("[42].concat()", "[42]"); |
+function throwFunc() { |
+ throw ""; |
+} |
+function throwOnReturn(){ |
+ 1; |
+ return throwFunc(); |
+} |
+function twoFunc() { |
+ 2; |
+} |
+ |
+shouldBe('eval("1;")', "1"); |
+shouldBe('eval("1; try { foo = [2,3,throwFunc(), 4]; } catch (e){}")', "1"); |
+shouldBe('eval("1; try { 2; throw \\"\\"; } catch (e){}")', "2"); |
+shouldBe('eval("1; try { 2; throwFunc(); } catch (e){}")', "2"); |
+shouldBe('eval("1; try { 2; throwFunc(); } catch (e){3;} finally {}")', "3"); |
+shouldBe('eval("1; try { 2; throwFunc(); } catch (e){3;} finally {4;}")', "4"); |
+shouldBe('eval("function blah() { 1; }\\n blah();")', "undefined"); |
+shouldBe('eval("var x = 1;")', "undefined"); |
+shouldBe('eval("if (true) { 1; } else { 2; }")', "1"); |
+shouldBe('eval("if (false) { 1; } else { 2; }")', "2"); |
+shouldBe('eval("try{1; if (true) { 2; throw \\"\\"; } else { 2; }} catch(e){}")', "2"); |
+shouldBe('eval("1; var i = 0; do { ++i; 2; } while(i!=1);")', "2"); |
+shouldBe('eval("try{1; var i = 0; do { ++i; 2; throw \\"\\"; } while(i!=1);} catch(e){}")', "2"); |
+shouldBe('eval("1; try{2; throwOnReturn();} catch(e){}")', "2"); |
+shouldBe('eval("1; twoFunc();")', "undefined"); |
+shouldBe('eval("1; with ( { a: 0 } ) { 2; }")', "2"); |