Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ry/0429eb4887370ee2a263446a59ec9ed7 to your computer and use it in GitHub Desktop.
Save ry/0429eb4887370ee2a263446a59ec9ed7 to your computer and use it in GitHub Desktop.
From da856685b7dcddf6843ceefab4a14153adf96db3 Mon Sep 17 00:00:00 2001
From: Ryan Dahl <ry@tinyclouds.org>
Date: Mon, 18 Jun 2018 15:10:43 +0200
Subject: [PATCH] Add failing test SnapshotCreatorArrayJoinWithKeep
---
test/cctest/test-serialize.cc | 42 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 42 insertions(+)
diff --git a/test/cctest/test-serialize.cc b/test/cctest/test-serialize.cc
index 5afa77bfb7..957190d93b 100644
--- a/test/cctest/test-serialize.cc
+++ b/test/cctest/test-serialize.cc
@@ -2618,6 +2618,48 @@ TEST(SnapshotCreatorNoExternalReferencesDefault) {
delete[] blob.data;
}
+v8::StartupData CreateCustomSnapshotArrayJoinWithKeep() {
+ v8::SnapshotCreator creator;
+ v8::Isolate* isolate = creator.GetIsolate();
+ {
+ v8::HandleScope handle_scope(isolate);
+ {
+ v8::Local<v8::Context> context = v8::Context::New(isolate);
+ v8::Context::Scope context_scope(context);
+ CompileRun(
+ "[].join('');\n"
+ "function g() { return String([1,2,3]); }\n"
+ );
+ ExpectString("g()", "1,2,3");
+ creator.SetDefaultContext(context);
+ }
+ }
+ return creator.CreateBlob(v8::SnapshotCreator::FunctionCodeHandling::kKeep);
+}
+
+TEST(SnapshotCreatorArrayJoinWithKeep) {
+ DisableAlwaysOpt();
+ v8::StartupData blob = CreateCustomSnapshotArrayJoinWithKeep();
+
+ // Deserialize with an incomplete list of external references.
+ {
+ v8::Isolate::CreateParams params;
+ params.snapshot_blob = &blob;
+ params.array_buffer_allocator = CcTest::array_buffer_allocator();
+ // Test-appropriate equivalent of v8::Isolate::New.
+ v8::Isolate* isolate = TestIsolate::New(params);
+ {
+ v8::Isolate::Scope isolate_scope(isolate);
+ v8::HandleScope handle_scope(isolate);
+ v8::Local<v8::Context> context = v8::Context::New(isolate);
+ v8::Context::Scope context_scope(context);
+ ExpectString("g()", "1,2,3");
+ }
+ isolate->Dispose();
+ }
+ delete[] blob.data;
+}
+
TEST(SnapshotCreatorNoExternalReferencesCustomFail1) {
DisableAlwaysOpt();
v8::StartupData blob = CreateSnapshotWithDefaultAndCustom();
--
2.15.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment