mirror of
https://github.com/denoland/deno.git
synced 2025-02-07 23:06:50 -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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
void deno_dispose(Deno* d) {
|
void deno_delete(Deno* d) {
|
||||||
d->isolate->Dispose();
|
d->isolate->Dispose();
|
||||||
delete (d);
|
delete d;
|
||||||
}
|
}
|
||||||
|
|
||||||
void deno_terminate_execution(Deno* d) { d->isolate->TerminateExecution(); }
|
void deno_terminate_execution(Deno* d) { d->isolate->TerminateExecution(); }
|
||||||
|
|
|
@ -26,8 +26,8 @@ void deno_init();
|
||||||
const char* deno_v8_version();
|
const char* deno_v8_version();
|
||||||
void deno_set_flags(int* argc, char** argv);
|
void deno_set_flags(int* argc, char** argv);
|
||||||
|
|
||||||
// Constructor
|
|
||||||
Deno* deno_new(void* data, deno_sub_cb cb);
|
Deno* deno_new(void* data, deno_sub_cb cb);
|
||||||
|
void deno_delete(Deno* d);
|
||||||
|
|
||||||
// Returns false on error.
|
// Returns false on error.
|
||||||
// Get error text with deno_last_exception().
|
// 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);
|
const char* deno_last_exception(Deno* d);
|
||||||
|
|
||||||
void deno_dispose(Deno* d);
|
|
||||||
void deno_terminate_execution(Deno* d);
|
void deno_terminate_execution(Deno* d);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -14,5 +14,5 @@ int main(int argc, char** argv) {
|
||||||
printf("Error! %s\n", deno_last_exception(d));
|
printf("Error! %s\n", deno_last_exception(d));
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
deno_dispose(d);
|
deno_delete(d);
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,20 +7,20 @@
|
||||||
TEST(MockRuntimeTest, InitializesCorrectly) {
|
TEST(MockRuntimeTest, InitializesCorrectly) {
|
||||||
Deno* d = deno_new(NULL, NULL);
|
Deno* d = deno_new(NULL, NULL);
|
||||||
EXPECT_TRUE(deno_execute(d, "a.js", "1 + 2"));
|
EXPECT_TRUE(deno_execute(d, "a.js", "1 + 2"));
|
||||||
deno_dispose(d);
|
deno_delete(d);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(MockRuntimeTest, CanCallFunction) {
|
TEST(MockRuntimeTest, CanCallFunction) {
|
||||||
Deno* d = deno_new(NULL, NULL);
|
Deno* d = deno_new(NULL, NULL);
|
||||||
EXPECT_TRUE(deno_execute(d, "a.js",
|
EXPECT_TRUE(deno_execute(d, "a.js",
|
||||||
"if (CanCallFunction() != 'foo') throw Error();"));
|
"if (CanCallFunction() != 'foo') throw Error();"));
|
||||||
deno_dispose(d);
|
deno_delete(d);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(MockRuntimeTest, ErrorsCorrectly) {
|
TEST(MockRuntimeTest, ErrorsCorrectly) {
|
||||||
Deno* d = deno_new(NULL, NULL);
|
Deno* d = deno_new(NULL, NULL);
|
||||||
EXPECT_FALSE(deno_execute(d, "a.js", "throw Error()"));
|
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)}; }
|
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);
|
Deno* d = deno_new(NULL, NULL);
|
||||||
EXPECT_TRUE(deno_execute(d, "a.js", "PubSuccess()"));
|
EXPECT_TRUE(deno_execute(d, "a.js", "PubSuccess()"));
|
||||||
EXPECT_TRUE(deno_pub(d, "PubSuccess", strbuf("abc")));
|
EXPECT_TRUE(deno_pub(d, "PubSuccess", strbuf("abc")));
|
||||||
deno_dispose(d);
|
deno_delete(d);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(MockRuntimeTest, PubByteLength) {
|
TEST(MockRuntimeTest, PubByteLength) {
|
||||||
|
@ -37,14 +37,14 @@ TEST(MockRuntimeTest, PubByteLength) {
|
||||||
EXPECT_TRUE(deno_execute(d, "a.js", "PubByteLength()"));
|
EXPECT_TRUE(deno_execute(d, "a.js", "PubByteLength()"));
|
||||||
// We pub the wrong sized message, it should throw.
|
// We pub the wrong sized message, it should throw.
|
||||||
EXPECT_FALSE(deno_pub(d, "PubByteLength", strbuf("abcd")));
|
EXPECT_FALSE(deno_pub(d, "PubByteLength", strbuf("abcd")));
|
||||||
deno_dispose(d);
|
deno_delete(d);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(MockRuntimeTest, PubNoCallback) {
|
TEST(MockRuntimeTest, PubNoCallback) {
|
||||||
Deno* d = deno_new(NULL, NULL);
|
Deno* d = deno_new(NULL, NULL);
|
||||||
// We didn't call deno_sub(), pubing should fail.
|
// We didn't call deno_sub(), pubing should fail.
|
||||||
EXPECT_FALSE(deno_pub(d, "PubNoCallback", strbuf("abc")));
|
EXPECT_FALSE(deno_pub(d, "PubNoCallback", strbuf("abc")));
|
||||||
deno_dispose(d);
|
deno_delete(d);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(MockRuntimeTest, SubReturnEmpty) {
|
TEST(MockRuntimeTest, SubReturnEmpty) {
|
||||||
|
@ -60,7 +60,7 @@ TEST(MockRuntimeTest, SubReturnEmpty) {
|
||||||
});
|
});
|
||||||
EXPECT_TRUE(deno_execute(d, "a.js", "SubReturnEmpty()"));
|
EXPECT_TRUE(deno_execute(d, "a.js", "SubReturnEmpty()"));
|
||||||
EXPECT_EQ(count, 2);
|
EXPECT_EQ(count, 2);
|
||||||
deno_dispose(d);
|
deno_delete(d);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(MockRuntimeTest, SubReturnBar) {
|
TEST(MockRuntimeTest, SubReturnBar) {
|
||||||
|
@ -76,7 +76,7 @@ TEST(MockRuntimeTest, SubReturnBar) {
|
||||||
});
|
});
|
||||||
EXPECT_TRUE(deno_execute(d, "a.js", "SubReturnBar()"));
|
EXPECT_TRUE(deno_execute(d, "a.js", "SubReturnBar()"));
|
||||||
EXPECT_EQ(count, 1);
|
EXPECT_EQ(count, 1);
|
||||||
deno_dispose(d);
|
deno_delete(d);
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char** argv) {
|
int main(int argc, char** argv) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue