diff --git a/deno2/deno.cc b/deno2/deno.cc index c21dc43c02..de03ed426c 100644 --- a/deno2/deno.cc +++ b/deno2/deno.cc @@ -153,8 +153,8 @@ void Pub(const v8::FunctionCallbackInfo& args) { } } -bool Load(v8::Local context, const char* name_s, - const char* source_s) { +bool Execute(v8::Local context, const char* js_filename, + const char* js_source) { auto* isolate = context->GetIsolate(); v8::Isolate::Scope isolate_scope(isolate); v8::HandleScope handle_scope(isolate); @@ -163,8 +163,8 @@ bool Load(v8::Local context, const char* name_s, v8::TryCatch try_catch(isolate); - auto name = v8_str(name_s); - auto source = v8_str(source_s); + auto name = v8_str(js_filename); + auto source = v8_str(js_source); v8::ScriptOrigin origin(name); @@ -217,7 +217,7 @@ v8::StartupData MakeSnapshot(v8::StartupData* prev_natives_blob, auto pub_val = pub_tmpl->GetFunction(context).ToLocalChecked(); CHECK(global->Set(context, deno::v8_str("deno_pub"), pub_val).FromJust()); - bool r = Load(context, js_filename, js_source); + bool r = Execute(context, js_filename, js_source); assert(r); creator->SetDefaultContext(context); @@ -261,13 +261,13 @@ void deno_set_flags(int* argc, char** argv) { const char* deno_last_exception(Deno* d) { return d->last_exception.c_str(); } -bool deno_load(Deno* d, const char* name_s, const char* source_s) { +bool deno_execute(Deno* d, const char* js_filename, const char* js_source) { auto* isolate = d->isolate; v8::Locker locker(isolate); v8::Isolate::Scope isolate_scope(isolate); v8::HandleScope handle_scope(isolate); auto context = d->context.Get(d->isolate); - return deno::Load(context, name_s, source_s); + return deno::Execute(context, js_filename, js_source); } // Routes message to the javascript callback set with deno_sub(). diff --git a/deno2/include/deno.h b/deno2/include/deno.h index c6bc82e265..4678a94afe 100644 --- a/deno2/include/deno.h +++ b/deno2/include/deno.h @@ -29,7 +29,7 @@ Deno* deno_new(void* data, deno_sub_cb cb); // Returns false on error. // Get error text with deno_last_exception(). -bool deno_load(Deno* d, const char* name_s, const char* source_s); +bool deno_execute(Deno* d, const char* js_filename, const char* js_source); // Returns false on error. // Get error text with deno_last_exception(). diff --git a/deno2/mock_runtime_test.cc b/deno2/mock_runtime_test.cc index 6f6688f48e..0b2966b697 100644 --- a/deno2/mock_runtime_test.cc +++ b/deno2/mock_runtime_test.cc @@ -6,19 +6,19 @@ TEST(MockRuntimeTest, InitializesCorrectly) { Deno* d = deno_new(NULL, NULL); - EXPECT_TRUE(deno_load(d, "a.js", "1 + 2")); + EXPECT_TRUE(deno_execute(d, "a.js", "1 + 2")); deno_dispose(d); } TEST(MockRuntimeTest, CanCallFoo) { Deno* d = deno_new(NULL, NULL); - EXPECT_TRUE(deno_load(d, "a.js", "if (foo() != 'foo') throw Error();")); + EXPECT_TRUE(deno_execute(d, "a.js", "if (foo() != 'foo') throw Error();")); deno_dispose(d); } TEST(MockRuntimeTest, ErrorsCorrectly) { Deno* d = deno_new(NULL, NULL); - EXPECT_FALSE(deno_load(d, "a.js", "throw Error()")); + EXPECT_FALSE(deno_execute(d, "a.js", "throw Error()")); deno_dispose(d); } @@ -29,14 +29,14 @@ deno_buf strbuf(const char* str) { TEST(MockRuntimeTest, PubSuccess) { Deno* d = deno_new(NULL, NULL); - EXPECT_TRUE(deno_load(d, "a.js", "subabc();")); + EXPECT_TRUE(deno_execute(d, "a.js", "subabc();")); EXPECT_TRUE(deno_pub(d, strbuf("abc"))); deno_dispose(d); } TEST(MockRuntimeTest, PubByteLength) { Deno* d = deno_new(NULL, NULL); - EXPECT_TRUE(deno_load(d, "a.js", "subabc();")); + EXPECT_TRUE(deno_execute(d, "a.js", "subabc();")); // We pub the wrong sized message, it should throw. EXPECT_FALSE(deno_pub(d, strbuf("abcd"))); deno_dispose(d); @@ -61,7 +61,7 @@ TEST(MockRuntimeTest, SubReturnEmpty) { EXPECT_EQ(data[2], 'c'); return deno_buf{nullptr, 0}; }); - EXPECT_TRUE(deno_load(d, "a.js", "pubReturnEmpty()")); + EXPECT_TRUE(deno_execute(d, "a.js", "pubReturnEmpty()")); EXPECT_EQ(count, 2); deno_dispose(d); } @@ -78,7 +78,7 @@ TEST(MockRuntimeTest, SubReturnBar) { EXPECT_EQ(data[2], 'c'); return strbuf("bar"); }); - EXPECT_TRUE(deno_load(d, "a.js", "pubReturnBar()")); + EXPECT_TRUE(deno_execute(d, "a.js", "pubReturnBar()")); EXPECT_EQ(count, 1); deno_dispose(d); }