From c24209a7abb0bd45d1fe1ea85ac156a923ba8198 Mon Sep 17 00:00:00 2001 From: JohnnyMorganz Date: Tue, 9 May 2023 16:39:21 +0100 Subject: [PATCH] Move to autocomplete fixture Removed scopedfastflag to show CI fail --- tests/Autocomplete.test.cpp | 20 ++++++++++++++++++++ tests/Frontend.test.cpp | 35 ----------------------------------- 2 files changed, 20 insertions(+), 35 deletions(-) diff --git a/tests/Autocomplete.test.cpp b/tests/Autocomplete.test.cpp index 3dc75d62..88e92a90 100644 --- a/tests/Autocomplete.test.cpp +++ b/tests/Autocomplete.test.cpp @@ -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(); diff --git a/tests/Frontend.test.cpp b/tests/Frontend.test.cpp index 150368f9..0b9c872c 100644 --- a/tests/Frontend.test.cpp +++ b/tests/Frontend.test.cpp @@ -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();