Revision: 3575
Author: [email protected]
Date: Mon Jan 11 04:13:24 2010
Log: Added ScriptData::HasError.

Review URL: http://codereview.chromium.org/542010

http://code.google.com/p/v8/source/detail?r=3575

Modified:
 /branches/bleeding_edge/include/v8.h
 /branches/bleeding_edge/src/parser.cc
 /branches/bleeding_edge/src/parser.h
 /branches/bleeding_edge/test/cctest/test-api.cc

=======================================
--- /branches/bleeding_edge/include/v8.h        Wed Dec  9 06:32:45 2009
+++ /branches/bleeding_edge/include/v8.h        Mon Jan 11 04:13:24 2010
@@ -503,6 +503,7 @@

   virtual int Length() = 0;
   virtual unsigned* Data() = 0;
+  virtual bool HasError() = 0;
 };


=======================================
--- /branches/bleeding_edge/src/parser.cc       Thu Jan  7 11:01:23 2010
+++ /branches/bleeding_edge/src/parser.cc       Mon Jan 11 04:13:24 2010
@@ -4709,6 +4709,11 @@
 unsigned* ScriptDataImpl::Data() {
   return store_.start();
 }
+
+
+bool ScriptDataImpl::HasError() {
+  return has_error();
+}


 ScriptDataImpl* PreParse(Handle<String> source,
=======================================
--- /branches/bleeding_edge/src/parser.h        Tue Oct 13 02:37:17 2009
+++ /branches/bleeding_edge/src/parser.h        Mon Jan 11 04:13:24 2010
@@ -91,6 +91,7 @@
   virtual ~ScriptDataImpl();
   virtual int Length();
   virtual unsigned* Data();
+  virtual bool HasError();
   FunctionEntry GetFunctionEnd(int start);
   bool SanityCheck();

=======================================
--- /branches/bleeding_edge/test/cctest/test-api.cc     Wed Dec  9 06:32:45 2009
+++ /branches/bleeding_edge/test/cctest/test-api.cc     Mon Jan 11 04:13:24 2010
@@ -6742,6 +6742,27 @@
       v8::ScriptData::PreCompile(script, i::StrLength(script));
   CHECK_NE(sd->Length(), 0);
   CHECK_NE(sd->Data(), NULL);
+  CHECK(!sd->HasError());
+  delete sd;
+}
+
+
+TEST(PreCompileWithError) {
+  v8::V8::Initialize();
+  const char *script = "function foo(a) { return 1 * * 2; }";
+  v8::ScriptData *sd =
+      v8::ScriptData::PreCompile(script, i::StrLength(script));
+  CHECK(sd->HasError());
+  delete sd;
+}
+
+
+TEST(Regress31661) {
+  v8::V8::Initialize();
+  const char *script = " The Definintive Guide";
+  v8::ScriptData *sd =
+      v8::ScriptData::PreCompile(script, i::StrLength(script));
+  CHECK(sd->HasError());
   delete sd;
 }

-- 
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev

Reply via email to