summaryrefslogtreecommitdiff
path: root/source/Test
diff options
context:
space:
mode:
authoradelon <22380201+adelon@users.noreply.github.com>2026-08-01 15:14:40 +0200
committeradelon <22380201+adelon@users.noreply.github.com>2026-08-01 15:14:40 +0200
commit2b178e06b18063945cb5521c1e0ba7488f11bcc1 (patch)
tree8d52a38a60230f3805bd19ad8ebde68236447272 /source/Test
parent0a9bfc93260ac744899e1ed0e8855f5ea0373dde (diff)
Retain source markers in parsed occurrences
Diffstat (limited to 'source/Test')
-rw-r--r--source/Test/Unit/Source.hs58
1 files changed, 52 insertions, 6 deletions
diff --git a/source/Test/Unit/Source.hs b/source/Test/Unit/Source.hs
index c444cff..f2bdd22 100644
--- a/source/Test/Unit/Source.hs
+++ b/source/Test/Unit/Source.hs
@@ -2859,6 +2859,7 @@ retainsMultiItemSyntaxOccurrences =
, locLine
(Parse.parsedSyntaxOccurrenceLocation
occurrence)
+ , Parse.parsedSyntaxOccurrenceMarker occurrence
, marker
)
entry ->
@@ -2867,15 +2868,25 @@ retainsMultiItemSyntaxOccurrences =
Right summaries ->
assertEqual
"block association and scanner order"
- [ (0, 2, "multi_item")
- , (0, 4, "itemzero")
- , (0, 5, "itemsucc")
+ [ (0, 2, "multi_item", "multi_item")
+ , (0, 4, "itemzero", "itemzero")
+ , (0, 5, "itemsucc", "itemsucc")
]
summaries
Left entry ->
assertFailure
("expected an expression occurrence, got "
<> show entry)
+ case (Parse.parsedModuleBlocks root, occurrences) of
+ ( Raw.BlockData _location _title blockMarker _datatype : _
+ , firstOccurrence : _
+ ) ->
+ assertEqual
+ "first occurrence is the declaration-head anchor"
+ blockMarker
+ (Parse.parsedSyntaxOccurrenceMarker firstOccurrence)
+ _ ->
+ assertFailure "expected a datatype block and its occurrences"
propagatesImportedSyntax :: Assertion
propagatesImportedSyntax =
@@ -3405,16 +3416,51 @@ acceptsBuiltinSourceDeclaration =
symbolMarker
case Parse.parsedModuleSyntaxOccurrences root of
[occurrence] ->
- case Parse.parsedSyntaxOccurrenceEntry
- occurrence of
+ case Parse.parsedSyntaxOccurrenceEntry occurrence of
Interface.CanonicalExpressionFunction
_pattern
occurrenceMarker
- _fixity ->
+ _fixity -> do
+ assertEqual
+ "occurrence retains source marker"
+ "source_zero"
+ (Parse.parsedSyntaxOccurrenceMarker
+ occurrence)
assertEqual
"occurrence uses fixed marker"
"zero"
occurrenceMarker
+ fileId <- expectJust
+ "fixed occurrence file id"
+ (locFileId
+ (Parse.parsedSyntaxOccurrenceLocation
+ occurrence))
+ decoded <- expectRight
+ (Parsed.decodeCanonicalParsedPayload
+ fileId
+ (Parse.parsedModulePayload root))
+ case Parsed.decodedParsedOccurrences decoded of
+ [ ( _blockIndex
+ , _location
+ , storedMarker
+ , Interface.CanonicalExpressionFunction
+ _storedPattern
+ storedEntryMarker
+ _storedFixity
+ )
+ ] -> do
+ assertEqual
+ "payload source marker"
+ "source_zero"
+ storedMarker
+ assertEqual
+ "payload authoritative marker"
+ "zero"
+ storedEntryMarker
+ stored ->
+ assertFailure
+ ("unexpected decoded fixed occurrence: "
+ <> show stored)
entry ->
assertFailure
("unexpected fixed occurrence: "