luau/tests/NonStrictTypeChecker.test.cpp

47 lines
1,023 B
C++
Raw Normal View History

2023-09-30 01:22:06 +01: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-06 18:31:16 +01:00
#include "Luau/Common.h"
#include "Luau/Ast.h"
#include "Luau/ModuleResolver.h"
#include "ScopedFlags.h"
2023-09-30 01:22:06 +01:00
#include "doctest.h"
2023-10-06 18:31:16 +01:00
#include <iostream>
2023-09-30 01:22:06 +01:00
using namespace Luau;
2023-10-06 18:31:16 +01:00
struct NonStrictTypeCheckerFixture : Fixture
{
2023-10-13 20:38:31 +01:00
CheckResult checkNonStrict(const std::string& code)
2023-10-06 18:31:16 +01:00
{
2023-10-13 20:38:31 +01:00
ScopedFastFlag flags[] = {
{"LuauCheckedFunctionSyntax", true},
};
2023-09-30 01:22:06 +01:00
2023-10-13 20:38:31 +01:00
return check(Mode::Nonstrict, code);
}
2023-09-30 01:22:06 +01:00
2023-10-13 20:38:31 +01:00
std::string definitions = R"BUILTIN_SRC(
2023-10-06 18:31:16 +01:00
declare function @checked abs(n: number): number
2023-10-13 20:38:31 +01:00
abs("hi")
2023-10-06 18:31:16 +01:00
)BUILTIN_SRC";
2023-10-13 20:38:31 +01:00
};
2023-10-06 18:31:16 +01:00
2023-10-13 20:38:31 +01:00
TEST_SUITE_BEGIN("NonStrictTypeCheckerTest");
2023-10-06 18:31:16 +01:00
2023-10-13 20:38:31 +01:00
TEST_CASE_FIXTURE(NonStrictTypeCheckerFixture, "simple_non_strict")
2023-10-06 18:31:16 +01:00
{
2023-10-13 20:38:31 +01:00
auto res = checkNonStrict(R"BUILTIN_SRC(
declare function @checked abs(n: number): number
abs("hi")
)BUILTIN_SRC");
2023-10-06 18:31:16 +01:00
2023-10-13 20:38:31 +01:00
// LUAU_REQUIRE_ERRORS(res);
2023-10-06 18:31:16 +01:00
}
2023-09-30 01:22:06 +01:00
TEST_SUITE_END();