Index: test/cctest/test-parsing.cc |
diff --git a/test/cctest/test-parsing.cc b/test/cctest/test-parsing.cc |
index 02503f225ca3b5d5004717f309cd2a35c7427357..3134b12e0278fa79e5ff5e6d48a7830bcddc9f88 100755 |
--- a/test/cctest/test-parsing.cc |
+++ b/test/cctest/test-parsing.cc |
@@ -26,6 +26,7 @@ |
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
#include <stdlib.h> |
+#include <stdio.h> |
#include "v8.h" |
@@ -34,7 +35,8 @@ |
#include "parser.h" |
#include "utils.h" |
#include "execution.h" |
- |
+#include "scanner.h" |
+#include "preparser.h" |
#include "cctest.h" |
namespace i = ::v8::internal; |
@@ -239,3 +241,31 @@ TEST(Preparsing) { |
i::Vector<const char*> args = pre_impl->BuildArgs(); |
CHECK_GT(strlen(message), 0); |
} |
+ |
+ |
+TEST(StandAlonePreParser) { |
+ int marker; |
+ i::StackGuard::SetStackLimit( |
+ reinterpret_cast<uintptr_t>(&marker) - 128 * 1024); |
+ |
+ const char* programs[] = { |
+ "{label: 42}", |
+ "var x = 42;", |
+ "function foo(x, y) { return x + y; }", |
+ "native function foo(); return %ArgleBargle(glop);", |
+ NULL |
+ }; |
+ |
+ for (int i = 0; programs[i]; i++) { |
+ const char* program = programs[i]; |
+ unibrow::Utf8InputBuffer<256> stream(program, strlen(program)); |
+ i::CompleteParserRecorder log; |
+ i::Scanner scanner; |
+ scanner.Initialize(i::Handle<i::String>::null(), &stream, i::JAVASCRIPT); |
+ i::preparser::PreParser<i::Scanner, i::CompleteParserRecorder> preparser; |
+ bool result = preparser.PreParseProgram(&scanner, &log, true); |
+ CHECK(result); |
+ i::ScriptDataImpl data(log.ExtractData()); |
+ CHECK(!data.has_error()); |
+ } |
+} |