0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-03-03 09:31:22 -05:00

Add mock_runtime_test for deno_last_exception.

This commit is contained in:
Ryan Dahl 2018-07-23 14:10:48 -04:00
parent 7baf8a0fd1
commit b87e6d5604
2 changed files with 7 additions and 5 deletions

View file

@ -31,9 +31,8 @@ global.SendSuccess = () => {
});
};
global.SendByteLength = () => {
global.SendWrongByteLength = () => {
deno.recv(msg => {
assert(msg instanceof ArrayBuffer);
assert(msg.byteLength === 3);
});
};

View file

@ -41,11 +41,14 @@ TEST(MockRuntimeTest, SendSuccess) {
deno_delete(d);
}
TEST(MockRuntimeTest, SendByteLength) {
TEST(MockRuntimeTest, SendWrongByteLength) {
Deno* d = deno_new(nullptr, nullptr);
EXPECT_TRUE(deno_execute(d, "a.js", "SendByteLength()"));
// We pub the wrong sized message, it should throw.
EXPECT_TRUE(deno_execute(d, "a.js", "SendWrongByteLength()"));
// deno_send the wrong sized message, it should throw.
EXPECT_FALSE(deno_send(d, strbuf("abcd")));
std::string exception = deno_last_exception(d);
EXPECT_GT(exception.length(), 1);
EXPECT_NE(exception.find("assert"), std::string::npos);
deno_delete(d);
}