Mercurial > irccd
diff tests/js-util/main.cpp @ 190:cb61cc16e2b6
Irccd: update all JavaScript to native code
author | David Demelier <markand@malikania.fr> |
---|---|
date | Sun, 05 Jun 2016 10:50:55 +0200 |
parents | ef527409e638 |
children | bdeda4baf684 |
line wrap: on
line diff
--- a/tests/js-util/main.cpp Fri Jun 03 13:28:10 2016 +0200 +++ b/tests/js-util/main.cpp Sun Jun 05 10:50:55 2016 +0200 @@ -43,12 +43,15 @@ TEST_F(TestJsUtil, formatSimple) { try { - auto ret = duk::pevalString(m_plugin->context(), + auto ret = duk_peval_string(m_plugin->context(), "result = Irccd.Util.format(\"#{target}\", { target: \"markand\" })" ); if (ret != 0) - throw duk::exception(m_plugin->context(), -1); + throw dukx_exception(m_plugin->context(), -1); + + ASSERT_TRUE(duk_get_global_string(m_plugin->context(), "result")); + ASSERT_STREQ("markand", duk_get_string(m_plugin->context(), -1)); } catch (const std::exception &ex) { FAIL() << ex.what(); } @@ -57,10 +60,11 @@ TEST_F(TestJsUtil, splituser) { try { - if (duk::pevalString(m_plugin->context(), "result = Irccd.Util.splituser(\"user!~user@hyper/super/host\");") != 0) - throw duk::exception(m_plugin->context(), -1); + if (duk_peval_string(m_plugin->context(), "result = Irccd.Util.splituser(\"user!~user@hyper/super/host\");") != 0) + throw dukx_exception(m_plugin->context(), -1); - ASSERT_EQ("user", duk::getGlobal<std::string>(m_plugin->context(), "result")); + ASSERT_TRUE(duk_get_global_string(m_plugin->context(), "result")); + ASSERT_STREQ("user", duk_get_string(m_plugin->context(), -1)); } catch (const std::exception &ex) { FAIL() << ex.what(); } @@ -69,10 +73,11 @@ TEST_F(TestJsUtil, splithost) { try { - if (duk::pevalString(m_plugin->context(), "result = Irccd.Util.splithost(\"user!~user@hyper/super/host\");") != 0) - throw duk::exception(m_plugin->context(), -1); + if (duk_peval_string(m_plugin->context(), "result = Irccd.Util.splithost(\"user!~user@hyper/super/host\");") != 0) + throw dukx_exception(m_plugin->context(), -1); - ASSERT_EQ("!~user@hyper/super/host", duk::getGlobal<std::string>(m_plugin->context(), "result")); + ASSERT_TRUE(duk_get_global_string(m_plugin->context(), "result")); + ASSERT_STREQ("!~user@hyper/super/host", duk_get_string(m_plugin->context(), -1)); } catch (const std::exception &ex) { FAIL() << ex.what(); }