2021-10-30 04:25:12 +08:00
|
|
|
// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
|
|
|
|
#include "Luau/BuiltinDefinitions.h"
|
2023-01-05 04:53:17 +08:00
|
|
|
#include "Luau/Type.h"
|
2021-10-30 04:25:12 +08:00
|
|
|
|
|
|
|
#include "Fixture.h"
|
|
|
|
|
|
|
|
#include "doctest.h"
|
|
|
|
|
|
|
|
using namespace Luau;
|
|
|
|
|
|
|
|
TEST_SUITE_BEGIN("BuiltinDefinitionsTest");
|
|
|
|
|
2022-05-14 03:36:37 +08:00
|
|
|
TEST_CASE_FIXTURE(BuiltinsFixture, "lib_documentation_symbols")
|
2021-10-30 04:25:12 +08:00
|
|
|
{
|
2023-03-11 04:21:07 +08:00
|
|
|
CHECK(!frontend.globals.globalScope->bindings.empty());
|
2022-05-14 03:36:37 +08:00
|
|
|
|
2023-03-11 04:21:07 +08:00
|
|
|
for (const auto& [name, binding] : frontend.globals.globalScope->bindings)
|
2021-10-30 04:25:12 +08:00
|
|
|
{
|
|
|
|
std::string nameString(name.c_str());
|
|
|
|
std::string expectedRootSymbol = "@luau/global/" + nameString;
|
|
|
|
std::optional<std::string> actualRootSymbol = binding.documentationSymbol;
|
|
|
|
CHECK_MESSAGE(
|
2024-08-02 22:30:04 +08:00
|
|
|
actualRootSymbol == expectedRootSymbol, "expected symbol ", expectedRootSymbol, " for global ", nameString, ", got ", actualRootSymbol
|
|
|
|
);
|
2021-10-30 04:25:12 +08:00
|
|
|
|
2023-01-05 04:53:17 +08:00
|
|
|
const TableType::Props* props = nullptr;
|
|
|
|
if (const TableType* ttv = get<TableType>(binding.typeId))
|
2021-10-30 04:25:12 +08:00
|
|
|
{
|
|
|
|
props = &ttv->props;
|
|
|
|
}
|
2023-01-05 04:53:17 +08:00
|
|
|
else if (const ClassType* ctv = get<ClassType>(binding.typeId))
|
2021-10-30 04:25:12 +08:00
|
|
|
{
|
|
|
|
props = &ctv->props;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (props)
|
|
|
|
{
|
|
|
|
for (const auto& [propName, prop] : *props)
|
|
|
|
{
|
|
|
|
std::string fullPropName = nameString + "." + propName;
|
|
|
|
std::string expectedPropSymbol = expectedRootSymbol + "." + propName;
|
|
|
|
std::optional<std::string> actualPropSymbol = prop.documentationSymbol;
|
2024-08-02 22:30:04 +08:00
|
|
|
CHECK_MESSAGE(
|
|
|
|
actualPropSymbol == expectedPropSymbol, "expected symbol ", expectedPropSymbol, " for ", fullPropName, ", got ", actualPropSymbol
|
|
|
|
);
|
2021-10-30 04:25:12 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|