Remove unit test on parser
It wasn't adding any value
This commit is contained in:
parent
8da9219c3a
commit
9302080aa6
3 changed files with 0 additions and 143 deletions
|
|
@ -1,42 +0,0 @@
|
|||
#include "runtime/helpers/dummy_language.h"
|
||||
#include "tree_sitter/parser.h"
|
||||
|
||||
const TSParseAction parse_table[3][5] = {
|
||||
[0] = {
|
||||
[dummy_sym2] = SHIFT(12),
|
||||
[dummy_sym3] = SHIFT(12),
|
||||
},
|
||||
[1] = {
|
||||
[dummy_sym1] = ACCEPT_INPUT(),
|
||||
[dummy_sym2] = SHIFT(2),
|
||||
[dummy_sym3] = SHIFT(4),
|
||||
},
|
||||
[2] = {
|
||||
[dummy_sym1] = SHIFT(3),
|
||||
[dummy_sym2] = SHIFT(12),
|
||||
[dummy_sym3] = SHIFT(12),
|
||||
},
|
||||
};
|
||||
|
||||
const TSStateId lex_states[3] = {
|
||||
[0] = 100,
|
||||
[1] = 101,
|
||||
[2] = 102,
|
||||
};
|
||||
|
||||
const int hidden_symbols[5] = {
|
||||
[dummy_sym1] = 0,
|
||||
[dummy_sym2] = 0,
|
||||
[dummy_sym3] = 1,
|
||||
};
|
||||
|
||||
static TSLanguage language = {
|
||||
.symbol_count = 5,
|
||||
.parse_table = (const TSParseAction *)parse_table,
|
||||
.lex_states = lex_states,
|
||||
.hidden_symbol_flags = hidden_symbols,
|
||||
};
|
||||
|
||||
const TSLanguage * dummy_language() {
|
||||
return &language;
|
||||
}
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
#ifndef HELPERS_DUMMY_LANGUAGE_H_
|
||||
#define HELPERS_DUMMY_LANGUAGE_H_
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "tree_sitter/runtime.h"
|
||||
#include "tree_sitter/parser.h"
|
||||
|
||||
enum {
|
||||
dummy_sym1 = 2,
|
||||
dummy_sym2 = 3,
|
||||
dummy_sym3 = 4,
|
||||
};
|
||||
|
||||
const TSLanguage * dummy_language();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif // HELPERS_DUMMY_LANGUAGE_H_
|
||||
|
|
@ -1,78 +0,0 @@
|
|||
#include "runtime/runtime_spec_helper.h"
|
||||
#include "runtime/helpers/spy_reader.h"
|
||||
#include "runtime/helpers/dummy_language.h"
|
||||
#include "runtime/tree.h"
|
||||
#include "runtime/parser.h"
|
||||
#include "tree_sitter/parser.h"
|
||||
|
||||
TSTree *lex_fn_node_to_return;
|
||||
TSStateId lex_fn_state_received;
|
||||
TSLexer *lex_fn_lexer_received;
|
||||
|
||||
TSTree * fake_lex(TSLexer *lexer, TSStateId state_id) {
|
||||
lex_fn_lexer_received = lexer;
|
||||
lex_fn_state_received = state_id;
|
||||
return lex_fn_node_to_return;
|
||||
}
|
||||
|
||||
START_TEST
|
||||
|
||||
describe("LR Parsers", [&]() {
|
||||
TSParser parser;
|
||||
SpyReader *reader;
|
||||
TSLanguage language;
|
||||
|
||||
before_each([&]() {
|
||||
language = *dummy_language();
|
||||
language.lex_fn = fake_lex;
|
||||
parser = ts_parser_make(&language);
|
||||
|
||||
reader = new SpyReader("some structured text", 5);
|
||||
});
|
||||
|
||||
after_each([&]() {
|
||||
ts_parser_destroy(&parser);
|
||||
delete reader;
|
||||
});
|
||||
|
||||
describe("when starting at the beginning of the input (edit is NULL)", [&]() {
|
||||
before_each([&]() {
|
||||
ts_parser_start(&parser, reader->input, nullptr);
|
||||
});
|
||||
|
||||
it("runs the lexer with the lex state corresponding to the initial state", [&]() {
|
||||
lex_fn_node_to_return = ts_tree_make_leaf(dummy_sym2, 5, 1, 0);
|
||||
ts_parser_step(&parser);
|
||||
AssertThat(lex_fn_state_received, Equals(100));
|
||||
});
|
||||
|
||||
describe("when the returned symbol indicates a shift action", [&]() {
|
||||
before_each([&]() {
|
||||
lex_fn_node_to_return = ts_tree_make_leaf(dummy_sym2, 5, 1, 0);
|
||||
});
|
||||
|
||||
it("advances to the state specified in the action", [&]() {
|
||||
ts_parser_step(&parser);
|
||||
AssertThat(ts_stack_top_state(&parser.stack), Equals(12));
|
||||
});
|
||||
|
||||
it("continues parsing (returns NULL)", [&]() {
|
||||
auto result = ts_parser_step(&parser);
|
||||
AssertThat(result, Equals((TSTree *)nullptr));
|
||||
});
|
||||
});
|
||||
|
||||
describe("when the returned symbol indicates an error", [&]() {
|
||||
before_each([&]() {
|
||||
lex_fn_node_to_return = ts_tree_make_leaf(dummy_sym1, 5, 1, 0);
|
||||
});
|
||||
|
||||
it("ends the parse, returning an error tree", [&]() {
|
||||
auto result = ts_parser_step(&parser);
|
||||
AssertThat(result->symbol, Equals(ts_builtin_sym_error));
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
END_TEST
|
||||
Loading…
Add table
Add a link
Reference in a new issue