Enabling a few tests when using snapshots.
authorolehougaard <olehougaard@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Thu, 11 Sep 2008 12:33:31 +0000 (12:33 +0000)
committerolehougaard <olehougaard@ce2b1a6d-e550-0410-aec6-3dcde31c8c00>
Thu, 11 Sep 2008 12:33:31 +0000 (12:33 +0000)
Some of the tests that were disabled when using snapshot has been modified and reenabled.
Review URL: http://codereview.chromium.org/1937

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@277 ce2b1a6d-e550-0410-aec6-3dcde31c8c00

test/cctest/test-api.cc
test/mjsunit/debug-script.js

index dea8fd28350b0ca46d01cb0c20366c0f2d9d8e9b..1f2318a7c0978882402bb5e09c08def9286c86b2 100644 (file)
@@ -4697,7 +4697,7 @@ THREADED_TEST(LockUnlockLock) {
 }
 
 
-static void EnsureNoSurvivingGlobalObjects() {
+static int GetSurvivingGlobalObjectsCount() {
   int count = 0;
   v8::internal::Heap::CollectAllGarbage();
   v8::internal::HeapIterator it;
@@ -4710,38 +4710,34 @@ static void EnsureNoSurvivingGlobalObjects() {
 #ifdef DEBUG
   if (count > 0) v8::internal::Heap::TracePathToGlobal();
 #endif
-  CHECK_EQ(0, count);
+  return count;
 }
 
 
-// This test assumes that there are zero global objects when the
-// test starts.  This is not going to be true if we are using the
-// API fuzzer.
 TEST(DontLeakGlobalObjects) {
   // Regression test for issues 1139850 and 1174891.
 
-  v8::internal::V8::Initialize(NULL);
-  if (v8::internal::Snapshot::IsEnabled()) return;
+  v8::V8::Initialize();
 
-  EnsureNoSurvivingGlobalObjects();
+  int count = GetSurvivingGlobalObjectsCount();
 
   for (int i = 0; i < 5; i++) {
     { v8::HandleScope scope;
       LocalContext context;
     }
-    EnsureNoSurvivingGlobalObjects();
+    CHECK_EQ(count, GetSurvivingGlobalObjectsCount());
 
     { v8::HandleScope scope;
       LocalContext context;
       v8_compile("Date")->Run();
     }
-    EnsureNoSurvivingGlobalObjects();
+    CHECK_EQ(count, GetSurvivingGlobalObjectsCount());
 
     { v8::HandleScope scope;
       LocalContext context;
       v8_compile("/aaa/")->Run();
     }
-    EnsureNoSurvivingGlobalObjects();
+    CHECK_EQ(count, GetSurvivingGlobalObjectsCount());
 
     { v8::HandleScope scope;
       const char* extension_list[] = { "v8/gc" };
@@ -4749,7 +4745,7 @@ TEST(DontLeakGlobalObjects) {
       LocalContext context(&extensions);
       v8_compile("gc();")->Run();
     }
-    EnsureNoSurvivingGlobalObjects();
+    CHECK_EQ(count, GetSurvivingGlobalObjectsCount());
 
     { v8::HandleScope scope;
       const char* extension_list[] = { "v8/print" };
@@ -4757,14 +4753,13 @@ TEST(DontLeakGlobalObjects) {
       LocalContext context(&extensions);
       v8_compile("print('hest');")->Run();
     }
-    EnsureNoSurvivingGlobalObjects();
+    CHECK_EQ(count, GetSurvivingGlobalObjectsCount());
   }
 }
 
 
 THREADED_TEST(CheckForCrossContextObjectLiterals) {
-  v8::internal::V8::Initialize(NULL);
-  if (v8::internal::Snapshot::IsEnabled()) return;
+  v8::V8::Initialize();
 
   const int nof = 2;
   const char* sources[nof] = {
index 55e83c19b65b1f8a51f9a5c512ac3ddbb4d418b3..4a77c3cc3dd2809da743d94e3319138560fbd476 100644 (file)
@@ -55,6 +55,9 @@ for (i = 0; i < scripts.length; i++) {
 
 // This has to be updated if the number of native scripts change.
 assertEquals(12, native_count);
+// If no snapshot is used, only the 'gc' extension is loaded.
+// If snapshot is used, all extensions are cached in the snapshot.
+assertTrue(extension_count == 1 || extension_count == 5);
 assertEquals(2, normal_count);  // This script and mjsunit.js.
 
 // Test a builtins script.