Skip to content

Commit 66a1fca

Browse files
committed
trial 4
1 parent 988e46b commit 66a1fca

File tree

1 file changed

+53
-53
lines changed

1 file changed

+53
-53
lines changed

test/test_interpreter.cpp

Lines changed: 53 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -99,50 +99,16 @@ TEST_SUITE("execute_request")
9999
REQUIRE(result["status"] == "ok");
100100
}
101101

102-
// #if defined(XEUS_CPP_EMSCRIPTEN_WASM_BUILD)
103-
// TEST_CASE("headers found in sysroot/include/compat")
104-
// {
105-
// std::vector<const char*> Args = {
106-
// "-v",
107-
// "-Xclang", "-iwithsysroot/include/compat"
108-
// };
109-
110-
// xcpp::interpreter interpreter((int)Args.size(), Args.data());
111-
// std::string code = "#include <xlocale.h>";
112-
// nl::json user_expressions = nl::json::object();
113-
// xeus::execute_request_config config;
114-
// config.silent = false;
115-
// config.store_history = false;
116-
// config.allow_stdin = false;
117-
// nl::json header = nl::json::object();
118-
// xeus::xrequest_context::guid_list id = {};
119-
// xeus::xrequest_context context(header, id);
120-
121-
// std::promise<nl::json> promise;
122-
// std::future<nl::json> future = promise.get_future();
123-
// auto callback = [&promise](nl::json result) {
124-
// promise.set_value(result);
125-
// };
126-
127-
// interpreter.execute_request(
128-
// std::move(context),
129-
// std::move(callback),
130-
// code,
131-
// std::move(config),
132-
// user_expressions
133-
// );
134-
// nl::json result = future.get();
135-
// REQUIRE(result["status"] == "ok");
136-
// }
137-
// #endif
138-
139-
TEST_CASE("fetch_documentation")
102+
#if defined(XEUS_CPP_EMSCRIPTEN_WASM_BUILD)
103+
TEST_CASE("headers found in sysroot/include/compat")
140104
{
141-
std::vector<const char*> Args = {/*"-v", "resource-dir", "....."*/};
142-
xcpp::interpreter interpreter((int)Args.size(), Args.data());
105+
std::vector<const char*> Args = {
106+
"-v",
107+
"-Xclang", "-iwithsysroot/include/compat"
108+
};
143109

144-
std::string code = "?std::vector";
145-
std::string inspect_result = "https://en.cppreference.com/w/cpp/container/vector";
110+
xcpp::interpreter interpreter((int)Args.size(), Args.data());
111+
std::string code = "#include <xlocale.h>";
146112
nl::json user_expressions = nl::json::object();
147113
xeus::execute_request_config config;
148114
config.silent = false;
@@ -166,19 +132,17 @@ TEST_SUITE("execute_request")
166132
user_expressions
167133
);
168134
nl::json result = future.get();
169-
REQUIRE(result["payload"][0]["data"]["text/plain"] == inspect_result);
170-
REQUIRE(result["user_expressions"] == nl::json::object());
171-
REQUIRE(result["found"] == true);
172135
REQUIRE(result["status"] == "ok");
173136
}
137+
#endif
174138

175-
TEST_CASE("fetch_documentation_of_member_or_parameter")
139+
TEST_CASE("fetch_documentation")
176140
{
177141
std::vector<const char*> Args = {/*"-v", "resource-dir", "....."*/};
178142
xcpp::interpreter interpreter((int)Args.size(), Args.data());
179143

180-
std::string code = "?std::vector.push_back";
181-
std::string inspect_result = "https://en.cppreference.com/w/cpp/container/vector/push_back";
144+
std::string code = "?std::vector";
145+
std::string inspect_result = "https://en.cppreference.com/w/cpp/container/vector";
182146
nl::json user_expressions = nl::json::object();
183147
xeus::execute_request_config config;
184148
config.silent = false;
@@ -208,13 +172,13 @@ TEST_SUITE("execute_request")
208172
REQUIRE(result["status"] == "ok");
209173
}
210174

211-
212-
TEST_CASE("bad_status")
175+
TEST_CASE("fetch_documentation_of_member_or_parameter")
213176
{
214-
std::vector<const char*> Args = {"resource-dir"};
177+
std::vector<const char*> Args = {/*"-v", "resource-dir", "....."*/};
215178
xcpp::interpreter interpreter((int)Args.size(), Args.data());
216179

217-
std::string code = "int x = ;";
180+
std::string code = "?std::vector.push_back";
181+
std::string inspect_result = "https://en.cppreference.com/w/cpp/container/vector/push_back";
218182
nl::json user_expressions = nl::json::object();
219183
xeus::execute_request_config config;
220184
config.silent = false;
@@ -238,8 +202,44 @@ TEST_SUITE("execute_request")
238202
user_expressions
239203
);
240204
nl::json result = future.get();
241-
REQUIRE(result["status"] == "error");
205+
REQUIRE(result["payload"][0]["data"]["text/plain"] == inspect_result);
206+
REQUIRE(result["user_expressions"] == nl::json::object());
207+
REQUIRE(result["found"] == true);
208+
REQUIRE(result["status"] == "ok");
242209
}
210+
211+
212+
// TEST_CASE("bad_status")
213+
// {
214+
// std::vector<const char*> Args = {"resource-dir"};
215+
// xcpp::interpreter interpreter((int)Args.size(), Args.data());
216+
217+
// std::string code = "int x = ;";
218+
// nl::json user_expressions = nl::json::object();
219+
// xeus::execute_request_config config;
220+
// config.silent = false;
221+
// config.store_history = false;
222+
// config.allow_stdin = false;
223+
// nl::json header = nl::json::object();
224+
// xeus::xrequest_context::guid_list id = {};
225+
// xeus::xrequest_context context(header, id);
226+
227+
// std::promise<nl::json> promise;
228+
// std::future<nl::json> future = promise.get_future();
229+
// auto callback = [&promise](nl::json result) {
230+
// promise.set_value(result);
231+
// };
232+
233+
// interpreter.execute_request(
234+
// std::move(context),
235+
// std::move(callback),
236+
// code,
237+
// std::move(config),
238+
// user_expressions
239+
// );
240+
// nl::json result = future.get();
241+
// REQUIRE(result["status"] == "error");
242+
// }
243243
}
244244

245245
TEST_SUITE("inspect_request")

0 commit comments

Comments
 (0)