mirror of
https://github.com/denoland/deno.git
synced 2025-09-29 13:44:47 +00:00
Add mock_runtime_test for deno_last_exception.
This commit is contained in:
parent
7baf8a0fd1
commit
b87e6d5604
2 changed files with 7 additions and 5 deletions
|
@ -31,9 +31,8 @@ global.SendSuccess = () => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
global.SendByteLength = () => {
|
global.SendWrongByteLength = () => {
|
||||||
deno.recv(msg => {
|
deno.recv(msg => {
|
||||||
assert(msg instanceof ArrayBuffer);
|
|
||||||
assert(msg.byteLength === 3);
|
assert(msg.byteLength === 3);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -41,11 +41,14 @@ TEST(MockRuntimeTest, SendSuccess) {
|
||||||
deno_delete(d);
|
deno_delete(d);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST(MockRuntimeTest, SendByteLength) {
|
TEST(MockRuntimeTest, SendWrongByteLength) {
|
||||||
Deno* d = deno_new(nullptr, nullptr);
|
Deno* d = deno_new(nullptr, nullptr);
|
||||||
EXPECT_TRUE(deno_execute(d, "a.js", "SendByteLength()"));
|
EXPECT_TRUE(deno_execute(d, "a.js", "SendWrongByteLength()"));
|
||||||
// We pub the wrong sized message, it should throw.
|
// deno_send the wrong sized message, it should throw.
|
||||||
EXPECT_FALSE(deno_send(d, strbuf("abcd")));
|
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);
|
deno_delete(d);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue