Skip to content

Commit

Permalink
Rename deno_load to deno_execute.
Browse files Browse the repository at this point in the history
  • Loading branch information
ry committed Jun 11, 2018
1 parent 482fc3a commit 56c3ac4
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 15 deletions.
14 changes: 7 additions & 7 deletions deno2/deno.cc
Original file line number Diff line number Diff line change
Expand Up @@ -153,8 +153,8 @@ void Pub(const v8::FunctionCallbackInfo<v8::Value>& args) {
}
}

bool Load(v8::Local<v8::Context> context, const char* name_s,
const char* source_s) {
bool Execute(v8::Local<v8::Context> context, const char* js_filename,
const char* js_source) {
auto* isolate = context->GetIsolate();
v8::Isolate::Scope isolate_scope(isolate);
v8::HandleScope handle_scope(isolate);
Expand All @@ -163,8 +163,8 @@ bool Load(v8::Local<v8::Context> 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);

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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().
Expand Down
2 changes: 1 addition & 1 deletion deno2/include/deno.h
Original file line number Diff line number Diff line change
Expand Up @@ -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().
Expand Down
14 changes: 7 additions & 7 deletions deno2/mock_runtime_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand All @@ -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);
Expand All @@ -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);
}
Expand All @@ -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);
}
Expand Down

0 comments on commit 56c3ac4

Please sign in to comment.