mirror of
https://github.com/yhirose/cpp-peglib.git
synced 2024-12-22 11:55:30 +00:00
Added more unit tests
This commit is contained in:
parent
1594ee5613
commit
9a9b63ac2c
@ -976,3 +976,21 @@ TEST(GeneralTest, ParentReferencesShouldNotBeExpired) {
|
||||
EXPECT_FALSE(ast->nodes[0]->parent.expired());
|
||||
}
|
||||
|
||||
TEST(GeneralTest, EndOfInputTest) {
|
||||
auto parser = peg::parser(R"(
|
||||
S <- '[[' (!']]' .)* ']]'
|
||||
)");
|
||||
|
||||
auto ret = parser.parse("[[]]]");
|
||||
EXPECT_FALSE(ret);
|
||||
}
|
||||
|
||||
TEST(GeneralTest, DisableEndOfInputCheckTest) {
|
||||
auto parser = peg::parser(R"(
|
||||
S <- '[[' (!']]' .)* ']]' !.
|
||||
)");
|
||||
|
||||
auto ret = parser.parse("[[]]]");
|
||||
EXPECT_FALSE(ret);
|
||||
}
|
||||
|
||||
|
@ -1228,7 +1228,7 @@ TEST(DicTest, Dictionary_invalid) {
|
||||
|
||||
TEST(ErrorTest, Default_error_handling_1) {
|
||||
parser pg(R"(
|
||||
S <- '@' A B
|
||||
S <- '@' A B !.
|
||||
A <- < [a-z]+ >
|
||||
B <- 'hello' | 'world'
|
||||
%whitespace <- [ ]*
|
||||
@ -1253,7 +1253,7 @@ TEST(ErrorTest, Default_error_handling_1) {
|
||||
|
||||
TEST(ErrorTest, Default_error_handling_2) {
|
||||
parser pg(R"(
|
||||
S <- '@' A B
|
||||
S <- '@' A B !.
|
||||
A <- < [a-z]+ >
|
||||
B <- 'hello' / 'world'
|
||||
%whitespace <- ' '*
|
||||
@ -1279,7 +1279,7 @@ TEST(ErrorTest, Default_error_handling_2) {
|
||||
TEST(ErrorTest, Default_error_handling_fiblang) {
|
||||
parser pg(R"(
|
||||
# Syntax
|
||||
START ← STATEMENTS
|
||||
START ← STATEMENTS !.
|
||||
STATEMENTS ← (DEFINITION / EXPRESSION)*
|
||||
DEFINITION ← 'def' ↑ Identifier '(' Identifier ')' EXPRESSION
|
||||
EXPRESSION ← TERNARY
|
||||
@ -1326,7 +1326,7 @@ for n frm 1 to 30
|
||||
|
||||
TEST(ErrorTest, Error_recovery_1) {
|
||||
parser pg(R"(
|
||||
START <- __? SECTION*
|
||||
START <- __? SECTION* !.
|
||||
|
||||
SECTION <- HEADER __ ENTRIES __?
|
||||
|
||||
@ -1512,7 +1512,7 @@ TEST(ErrorTest, Error_recovery_2) {
|
||||
TEST(ErrorTest, Error_recovery_3) {
|
||||
parser pg(R"~(
|
||||
# Grammar
|
||||
START <- __? SECTION*
|
||||
START <- __? SECTION* !.
|
||||
|
||||
SECTION <- HEADER __ ENTRIES __?
|
||||
|
||||
@ -1723,7 +1723,7 @@ sss | ttt
|
||||
|
||||
TEST(ErrorTest, Error_recovery_Java) {
|
||||
parser pg(R"(
|
||||
Prog ← PUBLIC CLASS NAME LCUR PUBLIC STATIC VOID MAIN LPAR STRING LBRA RBRA NAME RPAR BlockStmt RCUR
|
||||
Prog ← PUBLIC CLASS NAME LCUR PUBLIC STATIC VOID MAIN LPAR STRING LBRA RBRA NAME RPAR BlockStmt RCUR !.
|
||||
BlockStmt ← LCUR (Stmt)* RCUR^rcblk
|
||||
Stmt ← IfStmt / WhileStmt / PrintStmt / DecStmt / AssignStmt / BlockStmt
|
||||
IfStmt ← IF LPAR Exp RPAR Stmt (ELSE Stmt)?
|
||||
|
Loading…
Reference in New Issue
Block a user