comparison tests/js-elapsedtimer/main.cpp @ 179:ef527409e638

Irccd: update JavaScript code
author David Demelier <markand@malikania.fr>
date Tue, 31 May 2016 21:03:01 +0200
parents 9f36f71a08c5
children cb61cc16e2b6
comparison
equal deleted inserted replaced
178:084081b24024 179:ef527409e638
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::pevalString(m_plugin->context(), "timer = new Irccd.ElapsedTimer();") != 0)
49 throw duk::error(m_plugin->context(), -1); 49 throw duk::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::pevalString(m_plugin->context(), "result = timer.elapsed();") != 0)
54 throw duk::error(m_plugin->context(), -1); 54 throw duk::exception(m_plugin->context(), -1);
55 55
56 ASSERT_GE(duk::getGlobal<int>(m_plugin->context(), "result"), 250); 56 ASSERT_GE(duk::getGlobal<int>(m_plugin->context(), "result"), 250);
57 ASSERT_LE(duk::getGlobal<int>(m_plugin->context(), "result"), 350); 57 ASSERT_LE(duk::getGlobal<int>(m_plugin->context(), "result"), 350);
58 } catch (const std::exception &ex) { 58 } catch (const std::exception &ex) {
59 FAIL() << ex.what(); 59 FAIL() << ex.what();
62 62
63 TEST_F(TestElapsedTimer, reset) 63 TEST_F(TestElapsedTimer, reset)
64 { 64 {
65 try { 65 try {
66 if (duk::pevalString(m_plugin->context(), "timer = new Irccd.ElapsedTimer();") != 0) 66 if (duk::pevalString(m_plugin->context(), "timer = new Irccd.ElapsedTimer();") != 0)
67 throw duk::error(m_plugin->context(), -1); 67 throw duk::exception(m_plugin->context(), -1);
68 68
69 std::this_thread::sleep_for(300ms); 69 std::this_thread::sleep_for(300ms);
70 70
71 if (duk::pevalString(m_plugin->context(), "timer.reset(); result = timer.elapsed();") != 0) 71 if (duk::pevalString(m_plugin->context(), "timer.reset(); result = timer.elapsed();") != 0)
72 throw duk::error(m_plugin->context(), -1); 72 throw duk::exception(m_plugin->context(), -1);
73 73
74 ASSERT_LE(duk::getGlobal<int>(m_plugin->context(), "result"), 100); 74 ASSERT_LE(duk::getGlobal<int>(m_plugin->context(), "result"), 100);
75 } catch (const std::exception &ex) { 75 } catch (const std::exception &ex) {
76 FAIL() << ex.what(); 76 FAIL() << ex.what();
77 } 77 }