File tests/srcml/cxx/srcml-cxx-parser.cpp changed (mode: 100644) (index d1cf74f..a76f9b6) |
... |
... |
TEST_CASE("Keywords are marked with types", "[.srcml][srcml-cxx][parser]") |
144 |
144 |
CHECK(findNode(tree, makePred(Type::Keywords, "switch")) != nullptr); |
CHECK(findNode(tree, makePred(Type::Keywords, "switch")) != nullptr); |
145 |
145 |
CHECK(findNode(tree, makePred(Type::Keywords, "default")) != nullptr); |
CHECK(findNode(tree, makePred(Type::Keywords, "default")) != nullptr); |
146 |
146 |
CHECK(findNode(tree, makePred(Type::Keywords, "break")) != nullptr); |
CHECK(findNode(tree, makePred(Type::Keywords, "break")) != nullptr); |
|
147 |
|
|
|
148 |
|
tree = parseCxx(R"( |
|
149 |
|
void f() { |
|
150 |
|
if (0) { |
|
151 |
|
} else if (this) { |
|
152 |
|
} |
|
153 |
|
} |
|
154 |
|
)"); |
|
155 |
|
CHECK(findNode(tree, makePred(Type::Keywords, "else")) != nullptr); |
|
156 |
|
CHECK(findNode(tree, makePred(Type::Keywords, "this")) != nullptr); |
|
157 |
|
auto test = [](const Node *node) { |
|
158 |
|
return node->label == "if" |
|
159 |
|
&& node->type == Type::Keywords |
|
160 |
|
&& node->line == 4; |
|
161 |
|
}; |
|
162 |
|
CHECK(findNode(tree, test) != nullptr); |
147 |
163 |
} |
} |
148 |
164 |
|
|
149 |
165 |
TEST_CASE("this is recognized as a keyword", "[.srcml][srcml-cxx][parser]") |
TEST_CASE("this is recognized as a keyword", "[.srcml][srcml-cxx][parser]") |