Mercurial > irccd
comparison tests/src/libirccd-js/jsapi-irccd/main.cpp @ 757:97b356010785
Irccd: create (command|jsapi)::registry
Make two list of constructor functions to initialize all command and all
Javascript modules to avoid duplicating efforts in case of change.
While here, update test fixtures to load all of them for simplicity.
author | David Demelier <markand@malikania.fr> |
---|---|
date | Mon, 06 Aug 2018 21:27:00 +0200 |
parents | e8c4ba5ed1c6 |
children |
comparison
equal
deleted
inserted
replaced
756:1b4f82c952d6 | 757:97b356010785 |
---|---|
17 */ | 17 */ |
18 | 18 |
19 #define BOOST_TEST_MODULE "Irccd Javascript API" | 19 #define BOOST_TEST_MODULE "Irccd Javascript API" |
20 #include <boost/test/unit_test.hpp> | 20 #include <boost/test/unit_test.hpp> |
21 | 21 |
22 #include <irccd/test/js_test.hpp> | 22 #include <irccd/test/javascript_fixture.hpp> |
23 | 23 |
24 namespace irccd { | 24 namespace irccd::test { |
25 | 25 |
26 namespace { | 26 namespace { |
27 | 27 |
28 BOOST_FIXTURE_TEST_SUITE(irccd_jsapi_suite, js_test<irccd_jsapi>) | 28 BOOST_FIXTURE_TEST_SUITE(irccd_jsapi_suite, javascript_fixture) |
29 | 29 |
30 BOOST_AUTO_TEST_CASE(version) | 30 BOOST_AUTO_TEST_CASE(version) |
31 { | 31 { |
32 auto ret = duk_peval_string(plugin_->get_context(), | 32 const auto ret = duk_peval_string(plugin_->get_context(), |
33 "major = Irccd.version.major;" | 33 "major = Irccd.version.major;" |
34 "minor = Irccd.version.minor;" | 34 "minor = Irccd.version.minor;" |
35 "patch = Irccd.version.patch;" | 35 "patch = Irccd.version.patch;" |
36 ); | 36 ); |
37 | 37 |
46 BOOST_TEST(IRCCD_VERSION_PATCH == duk_get_int(plugin_->get_context(), -1)); | 46 BOOST_TEST(IRCCD_VERSION_PATCH == duk_get_int(plugin_->get_context(), -1)); |
47 } | 47 } |
48 | 48 |
49 BOOST_AUTO_TEST_CASE(from_javascript) | 49 BOOST_AUTO_TEST_CASE(from_javascript) |
50 { | 50 { |
51 auto ret = duk_peval_string(plugin_->get_context(), | 51 const auto ret = duk_peval_string(plugin_->get_context(), |
52 "try {" | 52 "try {" |
53 " throw new Irccd.SystemError(1, 'test');" | 53 " throw new Irccd.SystemError(1, 'test');" |
54 "} catch (e) {" | 54 "} catch (e) {" |
55 " errno = e.errno;" | 55 " errno = e.errno;" |
56 " name = e.name;" | 56 " name = e.name;" |
83 return 0; | 83 return 0; |
84 }, 0); | 84 }, 0); |
85 | 85 |
86 duk_put_global_string(plugin_->get_context(), "f"); | 86 duk_put_global_string(plugin_->get_context(), "f"); |
87 | 87 |
88 auto ret = duk_peval_string(plugin_->get_context(), | 88 const auto ret = duk_peval_string(plugin_->get_context(), |
89 "try {" | 89 "try {" |
90 " f();" | 90 " f();" |
91 "} catch (e) {" | 91 "} catch (e) {" |
92 " errno = e.errno;" | 92 " errno = e.errno;" |
93 " name = e.name;" | 93 " name = e.name;" |
111 | 111 |
112 BOOST_AUTO_TEST_SUITE_END() | 112 BOOST_AUTO_TEST_SUITE_END() |
113 | 113 |
114 } // !namespace | 114 } // !namespace |
115 | 115 |
116 } // !irccd | 116 } // !irccd::test |