Skip to content

Commit

Permalink
test for duplicated figures revisited.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ducasse committed Aug 2, 2024
1 parent 8879ada commit 79d731e
Showing 1 changed file with 46 additions and 30 deletions.
76 changes: 46 additions & 30 deletions src/Microdown-BookTester-Tests/MicReferenceCheckerTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,32 @@ See *@Eq1@*
^ defAnCS0DoubleEq2DoubleEq1RefEq1
]

{ #category : 'tests - reporting' }
MicReferenceCheckerTest >> defAncS0DoubleFig1Fig2RefAncS1 [

| doubleFig1 |
doubleFig1 := dir / 'defAncS0DoubleFig1Fig2RefAncS1.md'.
doubleFig1 writeStreamDo: [ :stream |
stream nextPutAll: '# Section
@ancS0
![a caption 1](figures/f.png anchor=fig1)
![a caption 2](figures/f.png anchor=fig1)
![a caption 2](figures/f.png anchor=fig1)
![a caption 2](figures/f.png anchor=fig1)
![a caption 3](figures/f.png anchor=fig2)
See *@ancS1@*
' ].
doubleFig1 ensureCreateFile.
^ doubleFig1
]

{ #category : 'helpers - anchors & references' }
MicReferenceCheckerTest >> defEq1AndReferToEq1 [

Expand Down Expand Up @@ -337,6 +363,26 @@ MicReferenceCheckerTest >> testDuplicatedAnchorInDifferentFilesOfTheSameDir [



]

{ #category : 'tests - duplicated' }
MicReferenceCheckerTest >> testDuplicatedFigures [

| doubleFig1 checker dict dup1 |
doubleFig1 := self defAncS0DoubleFig1Fig2RefAncS1.
checker := MicReferenceChecker new.
self deny: (checker checkList: { doubleFig1 }).
self
assert: (checker results collect: [ :each | each anchorLabel ])
equals: OrderedCollection <- #( 'fig1' 'fig1' 'fig1' 'ancS1' ).

dict := checker results groupedBy: [ :each | each class ].

dup1 := (dict at: MicDuplicatedAnchorResult) first.
self assert: dup1 source equals: '/myDirectory/defAncS0DoubleFig1Fig2RefAncS1.md'.
self assert: dup1 anchorLabel equals: 'fig1'.


]

{ #category : 'tests - duplicated' }
Expand Down Expand Up @@ -604,36 +650,6 @@ See *@ancS1@*
equals: OrderedCollection <- #( 'ancS1' )
]

{ #category : 'tests - reporting' }
MicReferenceCheckerTest >> testReportingDuplicatedFiguresInFile [

| file visitor |
file := (dir / 'file.txt') asFileReference.
file writeStreamDo: [ :stream |
stream nextPutAll: '# Section
@ancS0
![a caption 1](figures/f.png anchor=fig1)
![a caption 2](figures/f.png anchor=fig1)
![a caption 2](figures/f.png anchor=fig1)
![a caption 2](figures/f.png anchor=fig1)
![a caption 3](figures/f.png anchor=fig2)
See *@ancS1@*
' ].
file ensureCreateFile.
visitor := MicReferenceChecker new.
self deny: (visitor checkList: { file }).
self
assert: (visitor results collect: [ :each | each anchorLabel ])
equals: OrderedCollection <- #( 'fig1' 'fig1' 'fig1' 'ancS1')
]

{ #category : 'tests - reporting' }
MicReferenceCheckerTest >> testReportingDuplicatedSectionAnchorsInFile [

Expand Down

0 comments on commit 79d731e

Please sign in to comment.