Mercurial > irccd
comparison tests/js-elapsedtimer/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 |
comparison
equal
deleted
inserted
replaced
189:bb70bb9e41eb | 190:cb61cc16e2b6 |
---|---|
43 }; | 43 }; |
44 | 44 |
45 TEST_F(TestElapsedTimer, standard) | 45 TEST_F(TestElapsedTimer, standard) |
46 { | 46 { |
47 try { | 47 try { |
48 if (duk::pevalString(m_plugin->context(), "timer = new Irccd.ElapsedTimer();") != 0) | 48 if (duk_peval_string(m_plugin->context(), "timer = new Irccd.ElapsedTimer();") != 0) |
49 throw duk::exception(m_plugin->context(), -1); | 49 throw dukx_exception(m_plugin->context(), -1); |
50 | 50 |
51 std::this_thread::sleep_for(300ms); | 51 std::this_thread::sleep_for(300ms); |
52 | 52 |
53 if (duk::pevalString(m_plugin->context(), "result = timer.elapsed();") != 0) | 53 if (duk_peval_string(m_plugin->context(), "result = timer.elapsed();") != 0) |
54 throw duk::exception(m_plugin->context(), -1); | 54 throw dukx_exception(m_plugin->context(), -1); |
55 | 55 |
56 ASSERT_GE(duk::getGlobal<int>(m_plugin->context(), "result"), 250); | 56 ASSERT_TRUE(duk_get_global_string(m_plugin->context(), "result")); |
57 ASSERT_LE(duk::getGlobal<int>(m_plugin->context(), "result"), 350); | 57 ASSERT_GE(duk_get_int(m_plugin->context(), -1), 250); |
58 ASSERT_LE(duk_get_int(m_plugin->context(), -1), 350); | |
58 } catch (const std::exception &ex) { | 59 } catch (const std::exception &ex) { |
59 FAIL() << ex.what(); | 60 FAIL() << ex.what(); |
60 } | 61 } |
61 } | 62 } |
62 | 63 |
63 TEST_F(TestElapsedTimer, reset) | 64 TEST_F(TestElapsedTimer, reset) |
64 { | 65 { |
65 try { | 66 try { |
66 if (duk::pevalString(m_plugin->context(), "timer = new Irccd.ElapsedTimer();") != 0) | 67 if (duk_peval_string(m_plugin->context(), "timer = new Irccd.ElapsedTimer();") != 0) |
67 throw duk::exception(m_plugin->context(), -1); | 68 throw dukx_exception(m_plugin->context(), -1); |
68 | 69 |
69 std::this_thread::sleep_for(300ms); | 70 std::this_thread::sleep_for(300ms); |
70 | 71 |
71 if (duk::pevalString(m_plugin->context(), "timer.reset(); result = timer.elapsed();") != 0) | 72 if (duk_peval_string(m_plugin->context(), "timer.reset(); result = timer.elapsed();") != 0) |
72 throw duk::exception(m_plugin->context(), -1); | 73 throw dukx_exception(m_plugin->context(), -1); |
73 | 74 |
74 ASSERT_LE(duk::getGlobal<int>(m_plugin->context(), "result"), 100); | 75 ASSERT_TRUE(duk_get_global_string(m_plugin->context(), "result")); |
76 ASSERT_LE(duk_get_int(m_plugin->context(), -1), 100); | |
75 } catch (const std::exception &ex) { | 77 } catch (const std::exception &ex) { |
76 FAIL() << ex.what(); | 78 FAIL() << ex.what(); |
77 } | 79 } |
78 } | 80 } |
79 | 81 |