From: iposva@chromium.org Date: Tue, 18 Nov 2008 07:32:38 +0000 (+0000) Subject: Add an API test for v8::ScriptData::PreCompile() to make sure X-Git-Tag: upstream/4.7.83~25001 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=4a31a4b6385d4c6fc32e99eb4947ed52d07a54c8;p=platform%2Fupstream%2Fv8.git Add an API test for v8::ScriptData::PreCompile() to make sure that v8::V8::Initialize() does not have to be called to allow pre-compilation. Currently this test would fail, which is why a workaround has been applied and a bug filed. Review URL: http://codereview.chromium.org/11441 git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@779 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- diff --git a/test/cctest/test-api.cc b/test/cctest/test-api.cc index 6b44dda..82dac25 100644 --- a/test/cctest/test-api.cc +++ b/test/cctest/test-api.cc @@ -5274,3 +5274,17 @@ THREADED_TEST(ExternalSymbols) { value = CompileRun("obj.externalSymbol722 = 42"); v8::V8::SetExternalSymbolCallback(NULL); } + + +// This test verifies that pre-compilation (aka preparsing) can be called +// without initializing the whole VM. Thus we cannot run this test in a +// multi-threaded setup. +TEST(PreCompile) { + // TODO(155): This test would break without the initialization of V8. This is + // a workaround for now to make this test not fail. + v8::V8::Initialize(); + const char *script = "function foo(a) { return a+1; }"; + v8::ScriptData *sd = v8::ScriptData::PreCompile(script, strlen(script)); + CHECK_NE(sd->Length(), 0); + CHECK_NE(sd->Data(), NULL); +}