Clean up test that compiles example grammars
This commit is contained in:
parent
06cd18b483
commit
fd226a6bfe
2 changed files with 15 additions and 23 deletions
|
|
@ -1,5 +1,4 @@
|
|||
#include "compiler_spec_helper.h"
|
||||
#include "helpers/example_grammars.h"
|
||||
#include <fstream>
|
||||
|
||||
static string src_dir() {
|
||||
|
|
@ -8,20 +7,26 @@ static string src_dir() {
|
|||
return dir;
|
||||
}
|
||||
|
||||
namespace tree_sitter {
|
||||
namespace examples {
|
||||
Grammar arithmetic();
|
||||
Grammar json();
|
||||
}
|
||||
}
|
||||
|
||||
START_TEST
|
||||
|
||||
describe("compiling the example grammars", []() {
|
||||
string example_parser_dir = src_dir() + "/examples/parsers/";
|
||||
|
||||
it("compiles the arithmetic grammar", [&]() {
|
||||
Grammar grammar = examples::arithmetic();
|
||||
ofstream(example_parser_dir + "arithmetic.c") << compile(grammar, "arithmetic");
|
||||
});
|
||||
|
||||
it("compiles the json grammar", [&]() {
|
||||
Grammar grammar = examples::json();
|
||||
ofstream(example_parser_dir + "json.c") << compile(grammar, "json");
|
||||
});
|
||||
auto compile_grammar = [&](Grammar grammar, string language) {
|
||||
it(("compiles the " + language + " grammar").c_str(), [&]() {
|
||||
ofstream(example_parser_dir + language + ".c") << compile(grammar, language);
|
||||
});
|
||||
};
|
||||
|
||||
compile_grammar(examples::arithmetic(), "arithmetic");
|
||||
compile_grammar(examples::json(), "json");
|
||||
});
|
||||
|
||||
END_TEST
|
||||
|
|
|
|||
|
|
@ -1,13 +0,0 @@
|
|||
#ifndef tree_sitter_example_grammars_h
|
||||
#define tree_sitter_example_grammars_h
|
||||
|
||||
#include "tree_sitter/compiler.h"
|
||||
|
||||
namespace tree_sitter {
|
||||
namespace examples {
|
||||
Grammar arithmetic();
|
||||
Grammar json();
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue