From fd226a6bfeb2735c34b3738eb4bb33020a505aae Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Mon, 24 Mar 2014 07:24:35 -0700 Subject: [PATCH] Clean up test that compiles example grammars --- spec/compiler/compile_examples.cc | 25 ++++++++++++++---------- spec/compiler/helpers/example_grammars.h | 13 ------------ 2 files changed, 15 insertions(+), 23 deletions(-) delete mode 100644 spec/compiler/helpers/example_grammars.h diff --git a/spec/compiler/compile_examples.cc b/spec/compiler/compile_examples.cc index 359410c0..b5973a23 100644 --- a/spec/compiler/compile_examples.cc +++ b/spec/compiler/compile_examples.cc @@ -1,5 +1,4 @@ #include "compiler_spec_helper.h" -#include "helpers/example_grammars.h" #include 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 diff --git a/spec/compiler/helpers/example_grammars.h b/spec/compiler/helpers/example_grammars.h deleted file mode 100644 index 4ade985b..00000000 --- a/spec/compiler/helpers/example_grammars.h +++ /dev/null @@ -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