luau/tests/NonStrictTypeChecker.test.cpp

47 lines
1023 B
C++
Raw Normal View History

2023-09-30 08:22:06 +08:00
// This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
#include "Luau/NonStrictTypeChecker.h"
#include "Fixture.h"
2023-10-07 01:31:16 +08:00
#include "Luau/Common.h"
#include "Luau/Ast.h"
#include "Luau/ModuleResolver.h"
#include "ScopedFlags.h"
2023-09-30 08:22:06 +08:00
#include "doctest.h"
2023-10-07 01:31:16 +08:00
#include <iostream>
2023-09-30 08:22:06 +08:00
using namespace Luau;
2023-10-07 01:31:16 +08:00
struct NonStrictTypeCheckerFixture : Fixture
{
2023-10-14 03:38:31 +08:00
CheckResult checkNonStrict(const std::string& code)
2023-10-07 01:31:16 +08:00
{
2023-10-14 03:38:31 +08:00
ScopedFastFlag flags[] = {
{"LuauCheckedFunctionSyntax", true},
};
2023-09-30 08:22:06 +08:00
2023-10-14 03:38:31 +08:00
return check(Mode::Nonstrict, code);
}
2023-09-30 08:22:06 +08:00
2023-10-14 03:38:31 +08:00
std::string definitions = R"BUILTIN_SRC(
2023-10-07 01:31:16 +08:00
declare function @checked abs(n: number): number
2023-10-14 03:38:31 +08:00
abs("hi")
2023-10-07 01:31:16 +08:00
)BUILTIN_SRC";
2023-10-14 03:38:31 +08:00
};
2023-10-07 01:31:16 +08:00
2023-10-14 03:38:31 +08:00
TEST_SUITE_BEGIN("NonStrictTypeCheckerTest");
2023-10-07 01:31:16 +08:00
2023-10-14 03:38:31 +08:00
TEST_CASE_FIXTURE(NonStrictTypeCheckerFixture, "simple_non_strict")
2023-10-07 01:31:16 +08:00
{
2023-10-14 03:38:31 +08:00
auto res = checkNonStrict(R"BUILTIN_SRC(
declare function @checked abs(n: number): number
abs("hi")
)BUILTIN_SRC");
2023-10-07 01:31:16 +08:00
2023-10-14 03:38:31 +08:00
// LUAU_REQUIRE_ERRORS(res);
2023-10-07 01:31:16 +08:00
}
2023-09-30 08:22:06 +08:00
TEST_SUITE_END();