Comments and (failing) tests

This commit is contained in:
topisani 2017-12-22 04:09:48 +01:00
commit 037619964f
2 changed files with 28 additions and 2 deletions

View file

@ -24,7 +24,9 @@ namespace
if (skip_if(stream, "inline"))
is_inline = true;
// C++17 nested namespace declarations
// C++17 nested namespace declarations get one cursor per nested name.
// The first cursor starts with the `namespace` keyword, and the
// following start with the `::` separator. Either way, it is skipped.
if (!detail::skip_if(stream, "namespace"))
skip(stream, "::");
@ -40,7 +42,8 @@ namespace
auto other_attributes = parse_attributes(stream);
attributes.insert(attributes.end(), other_attributes.begin(), other_attributes.end());
// C++17 nested namespace declarations
// If the next token is not `::`, there are no more nested namespace
// names, and we expect to see an opening brace.
if (!detail::skip_if(stream, "::"))
skip(stream, "{");

View file

@ -33,6 +33,16 @@ namespace c
/// namespace {
/// }
namespace {}
/// namespace e{
/// namespace f{
/// }
/// }
namespace e::f {}
/// \entity e::f
/// namespace f{
/// }
)";
auto file = parse({}, "cpp_namespace.cpp", code);
@ -69,6 +79,19 @@ namespace {}
REQUIRE(!ns.is_inline());
REQUIRE(no_children == 0u);
}
else if (ns.name() == "e")
{
REQUIRE(!ns.is_anonymous());
REQUIRE(!ns.is_inline());
REQUIRE(no_children == 1u);
}
else if (ns.name() == "f")
{
REQUIRE(!ns.is_anonymous());
check_parent(ns, "e", "e::f");
REQUIRE(!ns.is_inline());
REQUIRE(no_children == 0u);
}
else
REQUIRE(false);
});