luau/tests/VisitType.test.cpp

42 lines
915 B
C++
Raw Normal View History

2022-05-05 20:03:43 -04:00
// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
#include "Fixture.h"
#include "Luau/RecursionCounter.h"
#include "doctest.h"
using namespace Luau;
LUAU_FASTINT(LuauVisitRecursionLimit)
TEST_SUITE_BEGIN("VisitTypeVar");
2022-06-23 21:56:00 -04:00
TEST_CASE_FIXTURE(Fixture, "throw_when_limit_is_exceeded")
2022-05-05 20:03:43 -04:00
{
ScopedFastInt sfi{"LuauVisitRecursionLimit", 3};
CheckResult result = check(R"(
local t : {a: {b: {c: {d: {e: boolean}}}}}
)");
TypeId tType = requireType("t");
CHECK_THROWS_AS(toString(tType), RecursionLimitException);
2022-05-05 20:03:43 -04:00
}
2022-06-23 21:56:00 -04:00
TEST_CASE_FIXTURE(Fixture, "dont_throw_when_limit_is_high_enough")
2022-05-05 20:03:43 -04:00
{
ScopedFastInt sfi{"LuauVisitRecursionLimit", 8};
CheckResult result = check(R"(
local t : {a: {b: {c: {d: {e: boolean}}}}}
)");
TypeId tType = requireType("t");
(void)toString(tType);
}
TEST_SUITE_END();