Skip to content

Commit e4405a7

Browse files
authored
Merge branch 'main' into wasm
2 parents 49c8f48 + 160dce0 commit e4405a7

File tree

4 files changed

+49
-2
lines changed

4 files changed

+49
-2
lines changed

docs/environment.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,6 @@ channels:
55

66
dependencies:
77
- breathe
8+
- graphviz
89
- pip:
9-
- sphinx_rtd_theme
10+
- sphinx_rtd_theme

environment-wasm-host.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ channels:
33
- https://repo.prefix.dev/emscripten-forge-dev
44
- https://repo.mamba.pm/conda-forge
55
dependencies:
6-
- nlohmann_json
6+
- nlohmann_json=3.11.3
77
- xeus-lite
88
- xeus
99
- CppInterOp

src/xinspect.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ namespace xcpp
132132
if (std::regex_search(to_inspect, method, std::regex(R"((.*)\.(\w*)$)")))
133133
{
134134
std::string type_name = find_type_slow(method[1]);
135+
type_name = (type_name.empty()) ? method[1] : type_name;
135136

136137
if (!type_name.empty())
137138
{

test/test_interpreter.cpp

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,43 @@ TEST_SUITE("execute_request")
134134
REQUIRE(result["status"] == "ok");
135135
}
136136

137+
TEST_CASE("fetch_documentation_of_member_or_parameter")
138+
{
139+
std::vector<const char*> Args = {/*"-v", "resource-dir", "....."*/};
140+
xcpp::interpreter interpreter((int)Args.size(), Args.data());
141+
142+
std::string code = "?std::vector.push_back";
143+
std::string inspect_result = "https://en.cppreference.com/w/cpp/container/vector/push_back";
144+
nl::json user_expressions = nl::json::object();
145+
xeus::execute_request_config config;
146+
config.silent = false;
147+
config.store_history = false;
148+
config.allow_stdin = false;
149+
nl::json header = nl::json::object();
150+
xeus::xrequest_context::guid_list id = {};
151+
xeus::xrequest_context context(header, id);
152+
153+
std::promise<nl::json> promise;
154+
std::future<nl::json> future = promise.get_future();
155+
auto callback = [&promise](nl::json result) {
156+
promise.set_value(result);
157+
};
158+
159+
interpreter.execute_request(
160+
std::move(context),
161+
std::move(callback),
162+
code,
163+
std::move(config),
164+
user_expressions
165+
);
166+
nl::json result = future.get();
167+
REQUIRE(result["payload"][0]["data"]["text/plain"] == inspect_result);
168+
REQUIRE(result["user_expressions"] == nl::json::object());
169+
REQUIRE(result["found"] == true);
170+
REQUIRE(result["status"] == "ok");
171+
}
172+
173+
137174
TEST_CASE("bad_status")
138175
{
139176
std::vector<const char*> Args = {"resource-dir"};
@@ -861,6 +898,14 @@ TEST_SUITE("xinspect"){
861898
cmp.child_value = "nonexistentMethod";
862899
REQUIRE(cmp(node) == false);
863900
}
901+
902+
TEST_CASE("is_inspect_request"){
903+
std::string code = "vector";
904+
std::regex re_expression(R"(non_matching_pattern)");
905+
std::pair<bool, std::smatch> result = xcpp::is_inspect_request(code, re_expression);
906+
REQUIRE(result.first == false);
907+
}
908+
864909
}
865910

866911
#if !defined(XEUS_CPP_EMSCRIPTEN_WASM_BUILD)

0 commit comments

Comments
 (0)