Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Roblox
GitHub Repository: Roblox/luau
Path: blob/master/tests/BuiltinDefinitions.test.cpp
2723 views
1
// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
2
#include "Luau/BuiltinDefinitions.h"
3
#include "Luau/Type.h"
4
5
#include "Fixture.h"
6
7
#include "doctest.h"
8
9
using namespace Luau;
10
11
TEST_SUITE_BEGIN("BuiltinDefinitionsTest");
12
13
TEST_CASE_FIXTURE(BuiltinsFixture, "lib_documentation_symbols")
14
{
15
CHECK(!getFrontend().globals.globalScope->bindings.empty());
16
17
for (const auto& [name, binding] : getFrontend().globals.globalScope->bindings)
18
{
19
std::string nameString(name.c_str());
20
std::string expectedRootSymbol = "@luau/global/" + nameString;
21
std::optional<std::string> actualRootSymbol = binding.documentationSymbol;
22
CHECK_MESSAGE(
23
actualRootSymbol == expectedRootSymbol, "expected symbol ", expectedRootSymbol, " for global ", nameString, ", got ", actualRootSymbol
24
);
25
26
const TableType::Props* props = nullptr;
27
if (const TableType* ttv = get<TableType>(binding.typeId))
28
{
29
props = &ttv->props;
30
}
31
else if (const ExternType* etv = get<ExternType>(binding.typeId))
32
{
33
props = &etv->props;
34
}
35
36
if (props)
37
{
38
for (const auto& [propName, prop] : *props)
39
{
40
std::string fullPropName = nameString + "." + propName;
41
std::string expectedPropSymbol = expectedRootSymbol + "." + propName;
42
std::optional<std::string> actualPropSymbol = prop.documentationSymbol;
43
CHECK_MESSAGE(
44
actualPropSymbol == expectedPropSymbol, "expected symbol ", expectedPropSymbol, " for ", fullPropName, ", got ", actualPropSymbol
45
);
46
}
47
}
48
}
49
}
50
51