4
Copyright (c) 2021 МГТУ им. Н.Э. Баумана, кафедра ИУ-6, Михаил Фетисов,
6
https://bmstu.codes/lsx/simodo
9
/*! \file Утилита тестирования средств лексического анализа библиотеки SIMODO core. Проект SIMODO.
12
#include "simodo/module/ModuleCollector.h"
13
#include "simodo/inout/convert/functions.h"
17
using namespace simodo;
19
int main(int argc, char *argv[])
21
std::string module_name {"test"};
22
std::string module_setter {"set_test_string"};
23
std::string module_getter {"get_test_string"};
26
module_name = argv[1];
29
module_setter = argv[2];
32
module_getter = argv[3];
34
module::ModuleCollector collector({"bin/modules"});
36
// Проверка работы сетера и гетера
37
std::shared_ptr<variable::Object> object1 = collector.produceObject(module_name);
39
std::cout << collector.last_error() << std::endl;
43
variable::Value ret11 = collector.invoke(*object1, module_getter, {});
44
if (!collector.last_error().empty()) {
45
std::cout << collector.last_error() << std::endl;
49
std::cout << module_name << " object1" << "." << module_getter << " returned: "
50
<< inout::toU8(toString(ret11))
53
collector.invoke(*object1, module_setter, {{u"",{u"collector call 1"}}});
54
if (!collector.last_error().empty()) {
55
std::cout << collector.last_error() << std::endl;
59
variable::Value ret13 = collector.invoke(*object1, module_getter, {});
60
if (!collector.last_error().empty()) {
61
std::cout << collector.last_error() << std::endl;
65
std::cout << module_name << " object1" << "." << module_getter << " returned: "
66
<< inout::toU8(toString(ret13))
69
// Проверка, что нет зависимости между внешними модулями
70
std::shared_ptr<variable::Object> object2 = collector.produceObject(module_name);
72
std::cout << collector.last_error() << std::endl;
76
variable::Value ret21 = collector.invoke(*object2, module_getter, {});
77
if (!collector.last_error().empty()) {
78
std::cout << collector.last_error() << std::endl;
82
std::cout << module_name << " object2" << "." << module_getter << " returned: "
83
<< inout::toU8(toString(ret21))
86
collector.invoke(*object2, module_setter, {{u"",{u"collector call 2"}}});
87
if (!collector.last_error().empty()) {
88
std::cout << collector.last_error() << std::endl;
92
variable::Value ret23 = collector.invoke(*object2, module_getter, {});
93
if (!collector.last_error().empty()) {
94
std::cout << collector.last_error() << std::endl;
98
std::cout << module_name << " object2" << "." << module_getter << " returned: "
99
<< inout::toU8(toString(ret23))
102
variable::Value ret14 = collector.invoke(*object1, module_getter, {});
103
if (!collector.last_error().empty()) {
104
std::cout << collector.last_error() << std::endl;
108
std::cout << module_name << " object1" << "." << module_getter << " returned: "
109
<< inout::toU8(toString(ret14))
113
// test object1.get_test_string returned: "initial test string"
114
// test object1.get_test_string returned: "collector call 1"
115
// test object2.get_test_string returned: "initial test string"
116
// test object2.get_test_string returned: "collector call 2"
117
// test object1.get_test_string returned: "collector call 1"