Extend and fix tests for custom heap snapshot.
authoryangguo <yangguo@chromium.org>
Fri, 16 Jan 2015 22:17:37 +0000 (14:17 -0800)
committerCommit bot <commit-bot@chromium.org>
Fri, 16 Jan 2015 22:18:27 +0000 (22:18 +0000)
R=vogelheim@chromium.org

Review URL: https://codereview.chromium.org/856793002

Cr-Commit-Position: refs/heads/master@{#26110}

test/cctest/test-serialize.cc
test/mjsunit/debug-script.js
test/mjsunit/es6/iteration-syntax.js

index eb59779..1f7eb37 100644 (file)
@@ -563,11 +563,12 @@ UNINITIALIZED_TEST(CustomContextSerialization) {
         CompileRun(
             "var e;"
             "(function() {"
-            "  e = function(s) { eval (s); }"
+            "  e = function(s) { return eval (s); }"
             "})();"
             "var o = this;"
-            "var r = Math.random();"
-            "var f = (function(a, b) {}).bind(1, 2, 3);");
+            "var r = Math.random() + Math.cos(0);"
+            "var f = (function(a, b) { return a + b; }).bind(1, 2, 3);"
+            "var s = parseInt('12345');");
       }
       // Make sure all builtin scripts are cached.
       {
@@ -616,8 +617,9 @@ UNINITIALIZED_TEST(CustomContextSerialization) {
 }
 
 
-UNINITIALIZED_DEPENDENT_TEST(CustomContextDeSerialization,
+UNINITIALIZED_DEPENDENT_TEST(CustomContextDeserialization,
                              CustomContextSerialization) {
+  FLAG_crankshaft = false;
   if (!Snapshot::HaveASnapshotToStartFrom()) {
     int file_name_length = StrLength(FLAG_testing_serialization_file) + 10;
     Vector<char> startup_name = Vector<char>::New(file_name_length + 1);
@@ -654,6 +656,17 @@ UNINITIALIZED_DEPENDENT_TEST(CustomContextDeSerialization,
         Handle<JSObject> global_object(context->global_object(), isolate);
         Handle<Object> property = JSObject::GetDataProperty(global_object, o);
         CHECK(property.is_identical_to(global_proxy));
+
+        v8::Handle<v8::Context> v8_context = v8::Utils::ToLocal(context);
+        v8::Context::Scope context_scope(v8_context);
+        double r = CompileRun("r")->ToNumber(v8_isolate)->Value();
+        CHECK(r >= 1 && r <= 2);
+        int f = CompileRun("f()")->ToNumber(v8_isolate)->Int32Value();
+        CHECK_EQ(5, f);
+        f = CompileRun("e('f()')")->ToNumber(v8_isolate)->Int32Value();
+        CHECK_EQ(5, f);
+        v8::Handle<v8::String> s = CompileRun("s")->ToString(v8_isolate);
+        CHECK(s->Equals(v8_str("12345")));
       }
     }
     v8_isolate->Dispose();
index 07f0e3c..af1eb45 100644 (file)
@@ -96,9 +96,9 @@ if (extension_gc_script) {
 }
 
 // Test a normal script.
-var mjsunit_js_script = Debug.findScript(/mjsunit.js/);
-assertTrue(/mjsunit.js/.test(mjsunit_js_script.name));
-assertEquals(Debug.ScriptType.Normal, mjsunit_js_script.type);
+var debug_script = Debug.findScript(/debug-script.js/);
+assertTrue(/debug-script.js/.test(debug_script.name));
+assertEquals(Debug.ScriptType.Normal, debug_script.type);
 
 // Check a nonexistent script.
 var dummy_script = Debug.findScript('dummy.js');
index 356a978..4be94c5 100644 (file)
@@ -25,7 +25,7 @@
 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 
-// Flags: --harmony-scoping --use-strict
+// Flags: --harmony-scoping
 
 // Test for-of syntax.
 
@@ -35,28 +35,38 @@ function f() { for (x of y) { } }
 function f() { for (var x of y) { } }
 function f() { for (let x of y) { } }
 
-assertThrows("function f() { for (x of) { } }", SyntaxError);
-assertThrows("function f() { for (x of y z) { } }", SyntaxError);
-assertThrows("function f() { for (x of y;) { } }", SyntaxError);
+function StrictSyntaxError(s) {
+  try {
+    eval(s);
+  } catch (e) {
+    assertInstanceof(e, SyntaxError);
+    return;
+  }
+  throw "did not throw";
+}
 
-assertThrows("function f() { for (var x of) { } }", SyntaxError);
-assertThrows("function f() { for (var x of y z) { } }", SyntaxError);
-assertThrows("function f() { for (var x of y;) { } }", SyntaxError);
+StrictSyntaxError("function f() { for (x of) { } }");
+StrictSyntaxError("function f() { for (x of y z) { } }");
+StrictSyntaxError("function f() { for (x of y;) { } }");
 
-assertThrows("function f() { for (let x of) { } }", SyntaxError);
-assertThrows("function f() { for (let x of y z) { } }", SyntaxError);
-assertThrows("function f() { for (let x of y;) { } }", SyntaxError);
+StrictSyntaxError("function f() { for (var x of) { } }");
+StrictSyntaxError("function f() { for (var x of y z) { } }");
+StrictSyntaxError("function f() { for (var x of y;) { } }");
 
-assertThrows("function f() { for (of y) { } }", SyntaxError);
-assertThrows("function f() { for (of of) { } }", SyntaxError);
-assertThrows("function f() { for (var of y) { } }", SyntaxError);
-assertThrows("function f() { for (var of of) { } }", SyntaxError);
-assertThrows("function f() { for (let of y) { } }", SyntaxError);
-assertThrows("function f() { for (let of of) { } }", SyntaxError);
+StrictSyntaxError("function f() { for (let x of) { } }");
+StrictSyntaxError("function f() { for (let x of y z) { } }");
+StrictSyntaxError("function f() { for (let x of y;) { } }");
 
-assertThrows("function f() { for (x = 3 of y) { } }", SyntaxError);
-assertThrows("function f() { for (var x = 3 of y) { } }", SyntaxError);
-assertThrows("function f() { for (let x = 3 of y) { } }", SyntaxError);
+StrictSyntaxError("function f() { for (of y) { } }");
+StrictSyntaxError("function f() { for (of of) { } }");
+StrictSyntaxError("function f() { for (var of y) { } }");
+StrictSyntaxError("function f() { for (var of of) { } }");
+StrictSyntaxError("function f() { for (let of y) { } }");
+StrictSyntaxError("function f() { for (let of of) { } }");
+
+StrictSyntaxError("function f() { for (x = 3 of y) { } }");
+StrictSyntaxError("function f() { for (var x = 3 of y) { } }");
+StrictSyntaxError("function f() { for (let x = 3 of y) { } }");
 
 
 // Alack, this appears to be valid.