Move to autocomplete fixture

Removed scopedfastflag to show CI fail
This commit is contained in:
JohnnyMorganz 2023-05-09 16:39:21 +01:00
parent d75661b456
commit c24209a7ab
2 changed files with 20 additions and 35 deletions

View file

@ -3503,4 +3503,24 @@ local a: T@1
CHECK_EQ(ac.context, AutocompleteContext::Type);
}
TEST_CASE_FIXTURE(ACFixture, "frontend_use_correct_global_scope")
{
loadDefinition(R"(
declare class Instance
Name: string
end
)");
CheckResult result = check(R"(
local a: unknown = nil
if typeof(a) == "Instance" then
local b = a.@1
end
)");
auto ac = autocomplete('1');
CHECK_EQ(1, ac.entryMap.size());
CHECK(ac.entryMap.count("Name"));
}
TEST_SUITE_END();

View file

@ -1146,39 +1146,4 @@ TEST_CASE_FIXTURE(BuiltinsFixture, "module_scope_check")
CHECK_EQ(toString(ty), "number");
}
TEST_CASE_FIXTURE(BuiltinsFixture, "use_correct_global_scope")
{
ScopedFastFlag sff("LuauTypeCheckerUseCorrectScope", true);
GlobalTypes& globals = frontend.globalsForAutocomplete;
unfreeze(globals.globalTypes);
LoadDefinitionFileResult definitionsResult = frontend.loadDefinitionFile(globals, globals.globalScope, R"(
declare class Instance
end
)",
"@test", /* captureComments */ false);
freeze(globals.globalTypes);
if (definitionsResult.module)
dumpErrors(definitionsResult.module);
REQUIRE_MESSAGE(definitionsResult.success, "loadDefinition: unable to load definition file");
fileResolver.source["game/A"] = R"(
--!strict
local a: unknown = nil
if typeof(a) == "Instance" then
local b = a
end
)";
CheckResult result = frontend.check("game/A", FrontendOptions{false, true});
LUAU_REQUIRE_NO_ERRORS(result);
auto module = frontend.moduleResolverForAutocomplete.getModule("game/A");
REQUIRE(module);
auto ty = Luau::findTypeAtPosition(*module, *frontend.getSourceModule("game/A"), Luau::Position{4, 22});
REQUIRE(ty);
CHECK_EQ(toString(*ty), "Instance");
}
TEST_SUITE_END();