Add onerror test to mock_runtime_test.cc

This commit is contained in:
Ryan Dahl 2018-06-22 14:57:49 +02:00
parent 9315adb8c5
commit 1330553be1
3 changed files with 32 additions and 3 deletions

View file

@ -96,6 +96,19 @@ TEST(MockRuntimeTest, SnapshotBug) {
deno_delete(d);
}
TEST(MockRuntimeTest, ErrorHandling) {
static int count = 0;
Deno* d = deno_new(nullptr, [](auto deno, auto channel, auto buf) {
count++;
EXPECT_STREQ(channel, "ErrorHandling");
EXPECT_EQ(static_cast<size_t>(1), buf.len);
EXPECT_EQ(buf.data[0], 42);
});
EXPECT_FALSE(deno_execute(d, "a.js", "ErrorHandling()"));
EXPECT_EQ(count, 1);
deno_delete(d);
}
int main(int argc, char** argv) {
testing::InitGoogleTest(&argc, argv);
deno_init();