test: fill critical coverage gaps in type checking, config, and diagnostics - #62
Merged
Conversation
…ostics Ran coverage collection and targeted the largest real gaps rather than chasing percentage alone: TypeNarrower's union-narrow-by-element-index path (90.6% -> 95.3%), TypeInferrer's union/intersection arity-mismatch and repeated-binding paths, Resolver's scattered error branches, and LuauGenerator's invalid luau_name-attribute diagnostic (90% -> 100%). Added Loom.Config test coverage from scratch (ConfigReader, ProjectTypeConverter, LoomConfig -> FilesConfig path joining) and CompilationUnit's declaration-file Globals population, both previously untested (72.7%/75%/88% -> 86.4%/100%/100%). DiagnosticBag.FailFast_WhenTrue_ExitsOnError was mislabeled: it set FailFast to false (not true), never restored the static afterward (real cross-test pollution risk on a global), and never exercised the exit path at all - Environment.Exit can't be tested in-process. Renamed it to reflect what it actually verifies and wrapped it in try/finally. TextSpan (45.5% -> 100%) and Location (75% -> 100%) needed only their missing operator/Equals overload cases. Compiler.cs's top-level exception-recovery catch block and some InvocationMacroReference/ MacroExpander/TypeChecker generic-inference edge cases are left as known remaining gaps - the former is a defensive catch-all that's fragile to trigger deliberately, and TypeInferrer's deepest gaps directly overlap the generic-function-argument inference issue #30 is about to touch, so covering them now would likely be rewritten shortly after. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Qodana for .NET261 new problems were found
☁️ View the detailed Qodana report Detected 1 dependencyThird-party software listThis page lists the third-party software dependencies used in Loom
Contact Qodana teamContact us at qodana-support@jetbrains.com
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Ran
dotnet test -c Release --collect:"XPlat Code Coverage" --settings Loom.Testing/coverlet.runsettingsand targeted the largest real gaps by absolute missed-line count, not just percentage, per direction to focus on files with substantial branching logic and aim for ~90%+ rather than chasing every last percent everywhere.TypeNarrower.csTypeInferrer.csResolver.csLuauGenerator.csDiagnosticBag.csConfig/ConfigReader.csConfig/ProjectTypeConverter.csCompilationUnit.csText/TextSpan.csText/Location.csHighlights:
TypeNarrower's union-narrow-by-element-index path (arr[i] == literalwherearris a union of array types) and logical AND/OR merge-of-unnarrowed-states path were completely untested.Loom.Confighad no dedicated test file at all — addedConfigReaderTest.cscoveringLocateFromDirectory's null-return branches, theProjectDirectory-into-Files.SourceDirectory/OutputDirectorypath-joining, andProjectTypeConverter's valid/invalid parsing.CompilationUnit.Compile()'s declaration-file →Globalspopulation loop had zero coverage — no existing test compiled a project with an actual.d.loomfile present.DiagnosticBagTest.FailFast_WhenTrue_ExitsOnErroractually setFailFast = false(not true), never restored the global static afterward (real cross-test pollution risk), and never exercised the exit path at all (Environment.Exitcan't be tested in-process). Renamed to reflect what it actually verifies and wrapped in try/finally.LuauGenerator.cs's invalidluau_nameattribute diagnostic (non-string-literal argument) had no test.Known remaining gaps, left deliberately:
Compiler.cs's top-level exception-recoverycatchblock — a defensive catch-all that's fragile to trigger deliberately without contriving an internal crash.TypeInferrer.cs's deepest generic-matching branches andInvocationMacroReference.cs's element-access/union-provider-resolution paths — these directly overlap the generic-function-argument-inference work issue Infer instantiated function types #30 is about to touch, so covering them now would likely need rewriting again shortly after.Test plan
dotnet build— succeeds, no warningsdotnet test— 1845/1845 pass (1809 existing + 36 new)🤖 Generated with Claude Code