43 lines
No EOL
1.3 KiB
C++
43 lines
No EOL
1.3 KiB
C++
#include "runtime_spec_helper.h"
|
|
#include "helpers/read_test_entries.h"
|
|
|
|
extern "C" ts_parser ts_parser_javascript();
|
|
extern "C" ts_parser ts_parser_json();
|
|
extern "C" ts_parser ts_parser_arithmetic();
|
|
extern "C" ts_parser ts_parser_golang();
|
|
|
|
START_TEST
|
|
|
|
describe("Languages", [&]() {
|
|
ts_document *doc;
|
|
|
|
before_each([&]() {
|
|
doc = ts_document_make();
|
|
});
|
|
|
|
after_each([&]() {
|
|
ts_document_free(doc);
|
|
});
|
|
|
|
auto run_tests_for_language = [&](string language, ts_parser (parser_constructor)()) {
|
|
describe(language.c_str(), [&]() {
|
|
before_each([&]() {
|
|
ts_document_set_parser(doc, parser_constructor());
|
|
});
|
|
|
|
for (auto &entry : test_entries_for_language(language)) {
|
|
it(entry.description.c_str(), [&]() {
|
|
ts_document_set_input_string(doc, entry.input.c_str());
|
|
AssertThat(ts_document_string(doc), Equals(entry.tree_string.c_str()));
|
|
});
|
|
}
|
|
});
|
|
};
|
|
|
|
run_tests_for_language("json", ts_parser_json);
|
|
run_tests_for_language("arithmetic", ts_parser_arithmetic);
|
|
run_tests_for_language("javascript", ts_parser_javascript);
|
|
run_tests_for_language("golang", ts_parser_golang);
|
|
});
|
|
|
|
END_TEST |