luau/tests/BuiltinDefinitions.test.cpp
Andy Friesen 1fa8311a18
Sync to upstream/release/567 (#860)
* Fix #817 
* Fix #850 
* Optimize math.floor/ceil/round with SSE4.1
    * Results in a ~7-9% speedup on the math-cordic benchmark.
* Optimized table.sort.
* table.sort is now ~4.1x faster (when not using a predicate) and ~2.1x
faster when using a simple predicate. Performance may improve further in
the future.
* Reorganize the memory ownership of builtin type definitions.
* This is a small initial step toward affording parallel typechecking.

The new type solver is coming along nicely. We are working on fixing
crashes and bugs.

A few major changes to native codegen landed this week:
* Fixed lowering of Luau IR mod instruction when first argument is a
constant
* Added VM register data-flow/capture analysis
* Fixed issues with optimizations in unreachable blocks

---------

Co-authored-by: Arseny Kapoulkine <arseny.kapoulkine@gmail.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
2023-03-10 12:21:07 -08:00

47 lines
1.7 KiB
C++

// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
#include "Luau/BuiltinDefinitions.h"
#include "Luau/Type.h"
#include "Fixture.h"
#include "doctest.h"
using namespace Luau;
TEST_SUITE_BEGIN("BuiltinDefinitionsTest");
TEST_CASE_FIXTURE(BuiltinsFixture, "lib_documentation_symbols")
{
CHECK(!frontend.globals.globalScope->bindings.empty());
for (const auto& [name, binding] : frontend.globals.globalScope->bindings)
{
std::string nameString(name.c_str());
std::string expectedRootSymbol = "@luau/global/" + nameString;
std::optional<std::string> actualRootSymbol = binding.documentationSymbol;
CHECK_MESSAGE(
actualRootSymbol == expectedRootSymbol, "expected symbol ", expectedRootSymbol, " for global ", nameString, ", got ", actualRootSymbol);
const TableType::Props* props = nullptr;
if (const TableType* ttv = get<TableType>(binding.typeId))
{
props = &ttv->props;
}
else if (const ClassType* ctv = get<ClassType>(binding.typeId))
{
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;
CHECK_MESSAGE(actualPropSymbol == expectedPropSymbol, "expected symbol ", expectedPropSymbol, " for ", fullPropName, ", got ",
actualPropSymbol);
}
}
}
}