Skip to content

Commit

Permalink
deno_dispose -> deno_delete
Browse files Browse the repository at this point in the history
  • Loading branch information
ry committed Jun 11, 2018
1 parent 7d972b4 commit 64d41a7
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 13 deletions.
4 changes: 2 additions & 2 deletions deno2/deno.cc
Original file line number Diff line number Diff line change
Expand Up @@ -311,9 +311,9 @@ bool deno_pub(Deno* d, const char* channel, deno_buf buf) {
return true;
}

void deno_dispose(Deno* d) {
void deno_delete(Deno* d) {
d->isolate->Dispose();
delete (d);
delete d;
}

void deno_terminate_execution(Deno* d) { d->isolate->TerminateExecution(); }
Expand Down
3 changes: 1 addition & 2 deletions deno2/include/deno.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ void deno_init();
const char* deno_v8_version();
void deno_set_flags(int* argc, char** argv);

// Constructor
Deno* deno_new(void* data, deno_sub_cb cb);
void deno_delete(Deno* d);

// Returns false on error.
// Get error text with deno_last_exception().
Expand All @@ -39,7 +39,6 @@ bool deno_pub(Deno* d, const char* channel, deno_buf buf);

const char* deno_last_exception(Deno* d);

void deno_dispose(Deno* d);
void deno_terminate_execution(Deno* d);

#ifdef __cplusplus
Expand Down
2 changes: 1 addition & 1 deletion deno2/main.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ int main(int argc, char** argv) {
printf("Error! %s\n", deno_last_exception(d));
exit(1);
}
deno_dispose(d);
deno_delete(d);
}
16 changes: 8 additions & 8 deletions deno2/mock_runtime_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,20 @@
TEST(MockRuntimeTest, InitializesCorrectly) {
Deno* d = deno_new(NULL, NULL);
EXPECT_TRUE(deno_execute(d, "a.js", "1 + 2"));
deno_dispose(d);
deno_delete(d);
}

TEST(MockRuntimeTest, CanCallFunction) {
Deno* d = deno_new(NULL, NULL);
EXPECT_TRUE(deno_execute(d, "a.js",
"if (CanCallFunction() != 'foo') throw Error();"));
deno_dispose(d);
deno_delete(d);
}

TEST(MockRuntimeTest, ErrorsCorrectly) {
Deno* d = deno_new(NULL, NULL);
EXPECT_FALSE(deno_execute(d, "a.js", "throw Error()"));
deno_dispose(d);
deno_delete(d);
}

deno_buf strbuf(const char* str) { return deno_buf{str, strlen(str)}; }
Expand All @@ -29,22 +29,22 @@ TEST(MockRuntimeTest, PubSuccess) {
Deno* d = deno_new(NULL, NULL);
EXPECT_TRUE(deno_execute(d, "a.js", "PubSuccess()"));
EXPECT_TRUE(deno_pub(d, "PubSuccess", strbuf("abc")));
deno_dispose(d);
deno_delete(d);
}

TEST(MockRuntimeTest, PubByteLength) {
Deno* d = deno_new(NULL, NULL);
EXPECT_TRUE(deno_execute(d, "a.js", "PubByteLength()"));
// We pub the wrong sized message, it should throw.
EXPECT_FALSE(deno_pub(d, "PubByteLength", strbuf("abcd")));
deno_dispose(d);
deno_delete(d);
}

TEST(MockRuntimeTest, PubNoCallback) {
Deno* d = deno_new(NULL, NULL);
// We didn't call deno_sub(), pubing should fail.
EXPECT_FALSE(deno_pub(d, "PubNoCallback", strbuf("abc")));
deno_dispose(d);
deno_delete(d);
}

TEST(MockRuntimeTest, SubReturnEmpty) {
Expand All @@ -60,7 +60,7 @@ TEST(MockRuntimeTest, SubReturnEmpty) {
});
EXPECT_TRUE(deno_execute(d, "a.js", "SubReturnEmpty()"));
EXPECT_EQ(count, 2);
deno_dispose(d);
deno_delete(d);
}

TEST(MockRuntimeTest, SubReturnBar) {
Expand All @@ -76,7 +76,7 @@ TEST(MockRuntimeTest, SubReturnBar) {
});
EXPECT_TRUE(deno_execute(d, "a.js", "SubReturnBar()"));
EXPECT_EQ(count, 1);
deno_dispose(d);
deno_delete(d);
}

int main(int argc, char** argv) {
Expand Down

0 comments on commit 64d41a7

Please sign in to comment.