Expand token_user_fields unit test
This commit is contained in:
parent
f9b4563f94
commit
d440d0442d
@ -1623,7 +1623,7 @@ drop /#(.*)\\n/ <<
|
||||
token id /\\w+/;
|
||||
Start -> IDs;
|
||||
IDs -> ;
|
||||
IDs -> id IDs;
|
||||
IDs -> id:id IDs;
|
||||
EOF
|
||||
elsif language == "c"
|
||||
write_grammar <<EOF
|
||||
@ -1665,7 +1665,7 @@ drop /#(.*)\\n/ <<
|
||||
token id /\\w+/;
|
||||
Start -> IDs;
|
||||
IDs -> ;
|
||||
IDs -> id IDs;
|
||||
IDs -> id:id IDs;
|
||||
EOF
|
||||
else # C++
|
||||
write_grammar <<EOF
|
||||
@ -1690,7 +1690,7 @@ drop /#(.*)\\n/ <<
|
||||
token id /\\w+/;
|
||||
Start -> IDs;
|
||||
IDs -> ;
|
||||
IDs -> id IDs;
|
||||
IDs -> id:id IDs;
|
||||
EOF
|
||||
end
|
||||
run_propane(language: language)
|
||||
|
||||
@ -19,6 +19,22 @@ int main()
|
||||
context = p_context_new((uint8_t const *)input, strlen(input));
|
||||
assert(p_parse(context) == P_SUCCESS);
|
||||
Start * start = p_result(context);
|
||||
assert(start->pIDs);
|
||||
assert(start->pIDs->id);
|
||||
#ifdef __cplusplus
|
||||
assert(start->pIDs->id->comments == "# c1\n# c2\n");
|
||||
#else
|
||||
assert(start->pIDs->id->comments);
|
||||
assert(strcmp(start->pIDs->id->comments, "# c1\n# c2\n") == 0);
|
||||
#endif
|
||||
assert(start->pIDs->pIDs);
|
||||
assert(start->pIDs->pIDs->id);
|
||||
#ifdef __cplusplus
|
||||
assert(start->pIDs->pIDs->id->comments == "# s1\n# s2\n");
|
||||
#else
|
||||
assert(start->pIDs->pIDs->id->comments);
|
||||
assert(strcmp(start->pIDs->pIDs->id->comments, "# s1\n# s2\n") == 0);
|
||||
#endif
|
||||
|
||||
#ifndef __cplusplus
|
||||
free(context->comments);
|
||||
|
||||
@ -21,4 +21,10 @@ unittest
|
||||
context = p_context_new(input);
|
||||
assert(p_parse(context) == P_SUCCESS);
|
||||
Start * start = p_result(context);
|
||||
assert(start.pIDs);
|
||||
assert(start.pIDs.id);
|
||||
assert(start.pIDs.id.comments == "# c1\n# c2\n");
|
||||
assert(start.pIDs.pIDs);
|
||||
assert(start.pIDs.pIDs.id);
|
||||
assert(start.pIDs.pIDs.id.comments == "# s1\n# s2\n");
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user