| OLD | NEW | 
|---|
| 1 // Copyright 2007-2008 the V8 project authors. All rights reserved. | 1 // Copyright 2007-2008 the V8 project authors. All rights reserved. | 
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without | 
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are | 
| 4 // met: | 4 // met: | 
| 5 // | 5 // | 
| 6 //     * Redistributions of source code must retain the above copyright | 6 //     * Redistributions of source code must retain the above copyright | 
| 7 //       notice, this list of conditions and the following disclaimer. | 7 //       notice, this list of conditions and the following disclaimer. | 
| 8 //     * Redistributions in binary form must reproduce the above | 8 //     * Redistributions in binary form must reproduce the above | 
| 9 //       copyright notice, this list of conditions and the following | 9 //       copyright notice, this list of conditions and the following | 
| 10 //       disclaimer in the documentation and/or other materials provided | 10 //       disclaimer in the documentation and/or other materials provided | 
| (...skipping 1704 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1715 v8::Handle<Value> ThrowFromC(const v8::Arguments& args) { | 1715 v8::Handle<Value> ThrowFromC(const v8::Arguments& args) { | 
| 1716   ApiTestFuzzer::Fuzz(); | 1716   ApiTestFuzzer::Fuzz(); | 
| 1717   return v8::ThrowException(v8_str("konto")); | 1717   return v8::ThrowException(v8_str("konto")); | 
| 1718 } | 1718 } | 
| 1719 | 1719 | 
| 1720 | 1720 | 
| 1721 v8::Handle<Value> CCatcher(const v8::Arguments& args) { | 1721 v8::Handle<Value> CCatcher(const v8::Arguments& args) { | 
| 1722   if (args.Length() < 1) return v8::Boolean::New(false); | 1722   if (args.Length() < 1) return v8::Boolean::New(false); | 
| 1723   v8::HandleScope scope; | 1723   v8::HandleScope scope; | 
| 1724   v8::TryCatch try_catch; | 1724   v8::TryCatch try_catch; | 
| 1725   Local<Value> result = v8::Script::Compile(args[0]->ToString())->Run(); | 1725   v8::Script::Compile(args[0]->ToString())->Run(); | 
| 1726   CHECK(!try_catch.HasCaught() || result.IsEmpty()); |  | 
| 1727   return v8::Boolean::New(try_catch.HasCaught()); | 1726   return v8::Boolean::New(try_catch.HasCaught()); | 
| 1728 } | 1727 } | 
| 1729 | 1728 | 
| 1730 | 1729 | 
| 1731 THREADED_TEST(APICatch) { | 1730 THREADED_TEST(APICatch) { | 
| 1732   v8::HandleScope scope; | 1731   v8::HandleScope scope; | 
| 1733   Local<ObjectTemplate> templ = ObjectTemplate::New(); | 1732   Local<ObjectTemplate> templ = ObjectTemplate::New(); | 
| 1734   templ->Set(v8_str("ThrowFromC"), | 1733   templ->Set(v8_str("ThrowFromC"), | 
| 1735              v8::FunctionTemplate::New(ThrowFromC)); | 1734              v8::FunctionTemplate::New(ThrowFromC)); | 
| 1736   LocalContext context(0, templ); | 1735   LocalContext context(0, templ); | 
| (...skipping 16 matching lines...) Expand all  Loading... | 
| 1753              v8::FunctionTemplate::New(ThrowFromC)); | 1752              v8::FunctionTemplate::New(ThrowFromC)); | 
| 1754   LocalContext context(0, templ); | 1753   LocalContext context(0, templ); | 
| 1755   v8::TryCatch try_catch; | 1754   v8::TryCatch try_catch; | 
| 1756   CompileRun("ThrowFromC();"); | 1755   CompileRun("ThrowFromC();"); | 
| 1757   CHECK(try_catch.HasCaught()); | 1756   CHECK(try_catch.HasCaught()); | 
| 1758 } | 1757 } | 
| 1759 | 1758 | 
| 1760 | 1759 | 
| 1761 // Test that a try-finally block doesn't shadow a try-catch block | 1760 // Test that a try-finally block doesn't shadow a try-catch block | 
| 1762 // when setting up an external handler. | 1761 // when setting up an external handler. | 
| 1763 // | 1762 THREADED_TEST(TryCatchInTryFinally) { | 
| 1764 // TODO(271): This should be a threaded test. It was disabled for the |  | 
| 1765 // thread tests because it fails on the ARM simulator.  Should be made |  | 
| 1766 // threadable again when the simulator issue is resolved. |  | 
| 1767 TEST(TryCatchInTryFinally) { |  | 
| 1768   v8::HandleScope scope; | 1763   v8::HandleScope scope; | 
| 1769   Local<ObjectTemplate> templ = ObjectTemplate::New(); | 1764   Local<ObjectTemplate> templ = ObjectTemplate::New(); | 
| 1770   templ->Set(v8_str("CCatcher"), | 1765   templ->Set(v8_str("CCatcher"), | 
| 1771              v8::FunctionTemplate::New(CCatcher)); | 1766              v8::FunctionTemplate::New(CCatcher)); | 
| 1772   LocalContext context(0, templ); | 1767   LocalContext context(0, templ); | 
| 1773   Local<Value> result = CompileRun("try {" | 1768   Local<Value> result = CompileRun("try {" | 
| 1774                                    "  try {" | 1769                                    "  try {" | 
| 1775                                    "    CCatcher('throw 7;');" | 1770                                    "    CCatcher('throw 7;');" | 
| 1776                                    "  } finally {" | 1771                                    "  } finally {" | 
| 1777                                    "  }" | 1772                                    "  }" | 
| (...skipping 26 matching lines...) Expand all  Loading... | 
| 1804 TEST(APIThrowMessageAndVerboseTryCatch) { | 1799 TEST(APIThrowMessageAndVerboseTryCatch) { | 
| 1805   message_received = false; | 1800   message_received = false; | 
| 1806   v8::HandleScope scope; | 1801   v8::HandleScope scope; | 
| 1807   v8::V8::AddMessageListener(receive_message); | 1802   v8::V8::AddMessageListener(receive_message); | 
| 1808   Local<ObjectTemplate> templ = ObjectTemplate::New(); | 1803   Local<ObjectTemplate> templ = ObjectTemplate::New(); | 
| 1809   templ->Set(v8_str("ThrowFromC"), | 1804   templ->Set(v8_str("ThrowFromC"), | 
| 1810              v8::FunctionTemplate::New(ThrowFromC)); | 1805              v8::FunctionTemplate::New(ThrowFromC)); | 
| 1811   LocalContext context(0, templ); | 1806   LocalContext context(0, templ); | 
| 1812   v8::TryCatch try_catch; | 1807   v8::TryCatch try_catch; | 
| 1813   try_catch.SetVerbose(true); | 1808   try_catch.SetVerbose(true); | 
| 1814   Local<Value> result = CompileRun("ThrowFromC();"); | 1809   CompileRun("ThrowFromC();"); | 
| 1815   CHECK(try_catch.HasCaught()); | 1810   CHECK(try_catch.HasCaught()); | 
| 1816   CHECK(result.IsEmpty()); |  | 
| 1817   CHECK(message_received); | 1811   CHECK(message_received); | 
| 1818   v8::V8::RemoveMessageListeners(check_message); | 1812   v8::V8::RemoveMessageListeners(check_message); | 
| 1819 } | 1813 } | 
| 1820 | 1814 | 
| 1821 | 1815 | 
| 1822 THREADED_TEST(ExternalScriptException) { | 1816 THREADED_TEST(ExternalScriptException) { | 
| 1823   v8::HandleScope scope; | 1817   v8::HandleScope scope; | 
| 1824   Local<ObjectTemplate> templ = ObjectTemplate::New(); | 1818   Local<ObjectTemplate> templ = ObjectTemplate::New(); | 
| 1825   templ->Set(v8_str("ThrowFromC"), | 1819   templ->Set(v8_str("ThrowFromC"), | 
| 1826              v8::FunctionTemplate::New(ThrowFromC)); | 1820              v8::FunctionTemplate::New(ThrowFromC)); | 
| (...skipping 25 matching lines...) Expand all  Loading... | 
| 1852                                  args[1], | 1846                                  args[1], | 
| 1853                                  args[2], | 1847                                  args[2], | 
| 1854                                  args[3] }; | 1848                                  args[3] }; | 
| 1855     if (count % cInterval == 0) { | 1849     if (count % cInterval == 0) { | 
| 1856       v8::TryCatch try_catch; | 1850       v8::TryCatch try_catch; | 
| 1857       Local<Value> result = | 1851       Local<Value> result = | 
| 1858           v8::Handle<Function>::Cast(fun)->Call(global, 4, argv); | 1852           v8::Handle<Function>::Cast(fun)->Call(global, 4, argv); | 
| 1859       int expected = args[3]->Int32Value(); | 1853       int expected = args[3]->Int32Value(); | 
| 1860       if (try_catch.HasCaught()) { | 1854       if (try_catch.HasCaught()) { | 
| 1861         CHECK_EQ(expected, count); | 1855         CHECK_EQ(expected, count); | 
| 1862         CHECK(result.IsEmpty()); |  | 
| 1863         CHECK(!i::Top::has_scheduled_exception()); | 1856         CHECK(!i::Top::has_scheduled_exception()); | 
| 1864       } else { | 1857       } else { | 
| 1865         CHECK_NE(expected, count); | 1858         CHECK_NE(expected, count); | 
| 1866       } | 1859       } | 
| 1867       return result; | 1860       return result; | 
| 1868     } else { | 1861     } else { | 
| 1869       return v8::Handle<Function>::Cast(fun)->Call(global, 4, argv); | 1862       return v8::Handle<Function>::Cast(fun)->Call(global, 4, argv); | 
| 1870     } | 1863     } | 
| 1871   } | 1864   } | 
| 1872 } | 1865 } | 
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1910 // no other activations do.  The right activation is always the topmost one with | 1903 // no other activations do.  The right activation is always the topmost one with | 
| 1911 // a handler, regardless of whether it is in JavaScript or C. | 1904 // a handler, regardless of whether it is in JavaScript or C. | 
| 1912 // | 1905 // | 
| 1913 // The notation used to describe a test case looks like this: | 1906 // The notation used to describe a test case looks like this: | 
| 1914 // | 1907 // | 
| 1915 //    *JS[4] *C[3] @JS[2] C[1] JS[0] | 1908 //    *JS[4] *C[3] @JS[2] C[1] JS[0] | 
| 1916 // | 1909 // | 
| 1917 // Each entry is an activation, either JS or C.  The index is the count at that | 1910 // Each entry is an activation, either JS or C.  The index is the count at that | 
| 1918 // level.  Stars identify activations with exception handlers, the @ identifies | 1911 // level.  Stars identify activations with exception handlers, the @ identifies | 
| 1919 // the exception handler that should catch the exception. | 1912 // the exception handler that should catch the exception. | 
| 1920 // | 1913 THREADED_TEST(ExceptionOrder) { | 
| 1921 // TODO(271): This should be a threaded test. It was disabled for the |  | 
| 1922 // thread tests because it fails on the ARM simulator.  Should be made |  | 
| 1923 // threadable again when the simulator issue is resolved. |  | 
| 1924 TEST(ExceptionOrder) { |  | 
| 1925   v8::HandleScope scope; | 1914   v8::HandleScope scope; | 
| 1926   Local<ObjectTemplate> templ = ObjectTemplate::New(); | 1915   Local<ObjectTemplate> templ = ObjectTemplate::New(); | 
| 1927   templ->Set(v8_str("check"), v8::FunctionTemplate::New(JSCheck)); | 1916   templ->Set(v8_str("check"), v8::FunctionTemplate::New(JSCheck)); | 
| 1928   templ->Set(v8_str("CThrowCountDown"), | 1917   templ->Set(v8_str("CThrowCountDown"), | 
| 1929              v8::FunctionTemplate::New(CThrowCountDown)); | 1918              v8::FunctionTemplate::New(CThrowCountDown)); | 
| 1930   LocalContext context(0, templ); | 1919   LocalContext context(0, templ); | 
| 1931   CompileRun( | 1920   CompileRun( | 
| 1932     "function JSThrowCountDown(count, jsInterval, cInterval, expected) {" | 1921     "function JSThrowCountDown(count, jsInterval, cInterval, expected) {" | 
| 1933     "  if (count == 0) throw 'FromJS';" | 1922     "  if (count == 0) throw 'FromJS';" | 
| 1934     "  if (count % jsInterval == 0) {" | 1923     "  if (count % jsInterval == 0) {" | 
| (...skipping 3868 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 5803 | 5792 | 
| 5804   // Local context should still be live. | 5793   // Local context should still be live. | 
| 5805   CHECK(!local_env.IsEmpty()); | 5794   CHECK(!local_env.IsEmpty()); | 
| 5806   local_env->Enter(); | 5795   local_env->Enter(); | 
| 5807 | 5796 | 
| 5808   // Should complete without problems. | 5797   // Should complete without problems. | 
| 5809   RegExpInterruptTest().RunTest(); | 5798   RegExpInterruptTest().RunTest(); | 
| 5810 | 5799 | 
| 5811   local_env->Exit(); | 5800   local_env->Exit(); | 
| 5812 } | 5801 } | 
| OLD | NEW | 
|---|