diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2011-10-11 15:06:25 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-10-19 20:48:25 +0200 |
commit | 7dc5973bf12919d2d35230844beabe558d4faa00 (patch) | |
tree | 88d6128a911d2ec3b9a72d8e45d56fc2b250c714 /tests | |
parent | 4dc25c1f2995a5e02da47f0f6f3522af9eb6f78c (diff) |
Update V8
Change-Id: I7a9da7dbb2116a441788407d60ed10155cded941
Reviewed-by: Kent Hansen <kent.hansen@nokia.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/v8/tst_v8.cpp | 6 | ||||
-rw-r--r-- | tests/auto/v8/v8main.cpp | 3 | ||||
-rw-r--r-- | tests/auto/v8/v8test.cpp | 53 | ||||
-rw-r--r-- | tests/auto/v8/v8test.h | 1 |
4 files changed, 63 insertions, 0 deletions
diff --git a/tests/auto/v8/tst_v8.cpp b/tests/auto/v8/tst_v8.cpp index c753806518..fcb49f84e0 100644 --- a/tests/auto/v8/tst_v8.cpp +++ b/tests/auto/v8/tst_v8.cpp @@ -57,6 +57,7 @@ private slots: void eval(); void evalwithinwith(); void userobjectcompare(); + void externalteardown(); }; void tst_v8::eval() @@ -74,6 +75,11 @@ void tst_v8::userobjectcompare() QVERIFY(v8test_userobjectcompare()); } +void tst_v8::externalteardown() +{ + QVERIFY(v8test_externalteardown()); +} + int main(int argc, char *argv[]) { V8::SetFlagsFromCommandLine(&argc, argv, true); diff --git a/tests/auto/v8/v8main.cpp b/tests/auto/v8/v8main.cpp index b38bbabbd5..882c2b99bb 100644 --- a/tests/auto/v8/v8main.cpp +++ b/tests/auto/v8/v8main.cpp @@ -45,6 +45,8 @@ #define RUN_TEST(testname) { \ if (!v8test_ ## testname()) \ printf ("Test %s FAILED\n", # testname); \ + else \ + printf ("Test %s PASS\n", # testname); \ } int main(int argc, char *argv[]) @@ -54,6 +56,7 @@ int main(int argc, char *argv[]) RUN_TEST(eval); RUN_TEST(evalwithinwith); RUN_TEST(userobjectcompare); + RUN_TEST(externalteardown); return -1; } diff --git a/tests/auto/v8/v8test.cpp b/tests/auto/v8/v8test.cpp index 0b299ed23c..b2734af8c3 100644 --- a/tests/auto/v8/v8test.cpp +++ b/tests/auto/v8/v8test.cpp @@ -54,6 +54,59 @@ using namespace v8; } \ } +struct MyStringResource : public String::ExternalAsciiStringResource +{ + static bool wasDestroyed; + virtual ~MyStringResource() { wasDestroyed = true; } + virtual const char* data() const { return "v8test"; } + virtual size_t length() const { return 6; } +}; +bool MyStringResource::wasDestroyed = false; + +struct MyResource : public Object::ExternalResource +{ + static bool wasDestroyed; + virtual ~MyResource() { wasDestroyed = true; } +}; +bool MyResource::wasDestroyed = false; + +bool v8test_externalteardown() +{ + BEGINTEST(); + + Isolate *isolate = v8::Isolate::New(); + isolate->Enter(); + + { + HandleScope handle_scope; + Persistent<Context> context = Context::New(); + Context::Scope context_scope(context); + + Local<String> str = String::NewExternal(new MyStringResource); + + Local<FunctionTemplate> ft = FunctionTemplate::New(); + ft->InstanceTemplate()->SetHasExternalResource(true); + + Local<Object> obj = ft->GetFunction()->NewInstance(); + obj->SetExternalResource(new MyResource); + + context.Dispose(); + } + + // while (!v8::V8::IdleNotification()) ; + isolate->Exit(); + isolate->Dispose(); + + // ExternalString resources aren't guaranteed to be freed by v8 at this + // point. Uncommenting the IdleNotification() line above helps. +// VERIFY(MyStringResource::wasDestroyed); + + VERIFY(MyResource::wasDestroyed); + +cleanup: + + ENDTEST(); +} bool v8test_eval() { diff --git a/tests/auto/v8/v8test.h b/tests/auto/v8/v8test.h index fa9bbe9f02..cb737971cb 100644 --- a/tests/auto/v8/v8test.h +++ b/tests/auto/v8/v8test.h @@ -51,6 +51,7 @@ bool v8test_eval(); bool v8test_evalwithinwith(); bool v8test_userobjectcompare(); +bool v8test_externalteardown(); #endif // V8TEST_H |