mirror of
https://github.com/denoland/deno.git
synced 2024-12-22 15:24:46 -05:00
deno_dispose -> deno_delete
This commit is contained in:
parent
7d972b4534
commit
64d41a72f1
4 changed files with 12 additions and 13 deletions
|
@ -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(); }
|
||||
|
|
|
@ -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().
|
||||
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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)}; }
|
||||
|
@ -29,7 +29,7 @@ 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) {
|
||||
|
@ -37,14 +37,14 @@ TEST(MockRuntimeTest, PubByteLength) {
|
|||
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) {
|
||||
|
@ -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) {
|
||||
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue